title: Create Cross Promoting Categories in Wordpress Using 'pre_get_posts'

text: # What am I trying to do? Assign more than 1 category to a post so that it would appear in each category template without 1 main category in the URL. WP's default behavior when you select more than one category for a post is to assign the post to the category with the lowest ID. For example: If "Apple" category has an ID of 6 and "Peach" category has an ID 4. If the post is added to the Apple category, then the permalink will be /apple/post-title (pretty permalinks). If the post is added to Apple and Peach categories, then the permalink will be /peach/post-title. # Constraints   1. Category must appear in the permalink   2. Permalinks cannot change if additional categories are added # What I've tried First, I create a new taxonomy called "crosscategory". This will allow me to create a second set of categories with the same name as the main categories. So that I could select Apple as the category and Peach as the "cross category."               function crosspromote_taxonomies() {         $crosscatlabels = array(             'name'              => _x( 'Cross Promote Categories', 'taxonomy general name' ),             'singular_name'     => _x( 'Cross Promote Category', 'taxonomy singular name' ),             'search_items'      => __( 'Search Cross Promote Categories' ),             'popular_items'     => __( 'Popular Cross Promote Categories' ),             'all_items'         => __( 'All Cross Promote Categories' ),             'parent_item'       => __( 'Parent Cross Promote Category' ),             'parent_item_colon' => __( 'Parent Cross Promote Category:' ),             'edit_item'         => __( 'Edit Cross Promote Category' ),              'update_item'       => __( 'Update Cross Promote Category' ),             'add_new_item'      => __( 'Add New Cross Promote Category' ),             'new_item_name'     => __( 'New Cross Promote Category' ),         );         register_taxonomy(              'crosscategory',              array(                 'post'             ),              array(                  'hierarchical'      => true,                  'labels'            => $crosscatlabels,                 'show_ui'           => true,                 'query_var'         => true,                 'rewrite'           => false,             )         );     }      Now I need to create a filter that only runs on the category.php template. If I navigate to /apple/ I need to see all posts in the Apple category as well as any posts in another category that was also cross-promoted in Apple.               function cross_category_filter($query){         // only run this filter on the actual category page         if ( is_admin() || $query->is_home() || !$query->is_main_query() || $query->is_singular || !$query->is_category )             return;              $category_name = $query->query_vars['category_name'];              // Required to include posts from category-x used for cross-promoting posts in other categories without changing the URL         $query->set(              'tax_query',              array(                 'relation' => 'OR',                 array(                     'taxonomy'  => 'crosscategory',                     'field'     => 'slug',                     'terms'     => array($category_name),                     'operator'  => 'IN'                 )             )          );     }     add_action( 'pre_get_posts', 'cross_category_filter', 1 );      **The Problem** It simply doesn't seem to work at all. When I navigate to /apple, I either see a tag page (instead of a category template -- not sure why) or I may see no posts at all. The header.php, sidebar.php and footer.php would load but where the posts should be is empty as if the has_posts() has no posts. The output of the $query object looks like:               WP_Query Object     (         [query_vars] => Array             (                 [category_name] => apple                 [error] =>                  [m] => 0                 [p] => 0                 [post_parent] =>                  [subpost] =>                  [subpost_id] =>                  [attachment] =>                  [attachment_id] => 0                 [name] =>                  [static] =>                  [pagename] =>                  [page_id] => 0                 [second] =>                  [minute] =>                  [hour] =>                  [day] => 0                 [monthnum] => 0                 [year] => 0                 [w] => 0                 [tag] =>                  [cat] =>                  [tag_id] =>                  [author_name] =>                  [feed] =>                  [tb] =>                  [paged] => 0                 [comments_popup] =>                  [meta_key] =>                  [meta_value] =>                  [preview] =>                  [s] =>                  [sentence] =>                  [fields] =>                  [menu_order] =>                  [category__in] => Array                     (                     )                      [category__not_in] => Array                     (                     )                      [category__and] => Array                     (                     )                      [post__in] => Array                     (                     )                      [post__not_in] =>                  [tag__in] => Array                     (                     )                      [tag__not_in] => Array                     (                     )                      [tag__and] => Array                     (                     )                      [tag_slug__in] => Array                     (                     )                      [tag_slug__and] => Array                     (                     )                      [tax_query] => Array                     (                         [relation] => OR                         [0] => Array                             (                                 [taxonomy] => crosscategory                                 [field] => slug                                 [terms] => Array                                     (                                         [0] => apple                                     )                                      [operator] => IN                             )                          )                  )              [tax_query] => WP_Tax_Query Object             (                 [queries] => Array                     (                         [0] => Array                             (                                 [taxonomy] => category                                 [terms] => Array                                     (                                         [0] => apple                                     )                                      [include_children] => 1                                 [field] => slug                                 [operator] => IN                             )                          )                      [relation] => AND             )              [meta_query] =>          [post_count] => 0         [current_post] => -1         [in_the_loop] =>          [comment_count] => 0         [current_comment] => -1         [found_posts] => 0         [max_num_pages] => 0         [max_num_comment_pages] => 0         [is_single] =>          [is_preview] =>          [is_page] =>          [is_archive] => 1         [is_date] =>          [is_year] =>          [is_month] =>          [is_day] =>          [is_time] =>          [is_author] =>          [is_category] => 1         [is_tag] =>          [is_tax] =>          [is_search] =>          [is_feed] =>          [is_comment_feed] =>          [is_trackback] =>          [is_home] =>          [is_404] =>          [is_comments_popup] =>          [is_paged] =>          [is_admin] =>          [is_attachment] =>          [is_singular] =>          [is_robots] =>          [is_posts_page] =>          [is_post_type_archive] =>          [query_vars_hash] => 47f5cb8591c9e310161e42fa4bffbf43         [query_vars_changed] =>          [thumbnails_cached] =>          [query] => Array             (                 [category_name] => apple             )          )      I'm using pre_get_posts to reduce the number of queries and to do it the proper way. It should find all posts in the Apple category and any posts that is in the crosscategory Apple as well. I assume even if there are no posts in the crosscategory Apple, it should still find posts in the Apple category. Neither of which is happening and I'm stumped at this point.


title: Error when adding custom taxonomy to wp nav menu

text: I have the plugin CustomPress from wpmudev. I know longer have my membership there as it was just to pricey. I am also using there theme wpmu_dixi with some of my own customizations and tweaks. None of those tweaks where to its cor files i just added some new widget locations and messed with the css. Anyways when i go to add a menu item from the custom taxonomy (ie action) which is under the taxonomy type Movies it spits out the following error in the custom menu area (wp-admin/nav-menus.php)               Catchable fatal error: Object of class WP_Error could not be converted to string     path-to-site/entertain/wp-admin/includes/nav-menu.php on line 73      *i removed out my path I am using wordpress in network mode and have tried creating a tag that was far off and still nothing. The tag action appears on another sub-site but since i tried using a random tag this should not be the problem. I have searched on a few articles and the closest i could find is this one http://premium.wpmudev.org/forums/topic/custompress-error-adding-custom-post- type-via-taxonomies-to-menu


title: Buddypress send admin notification email when new subscriber registers

text: I am running a Buddypress site, but I am not getting emails when a new subscriber registers. I have used a code in my functions.php that removes the activation email the user would receive (I want them auto activated and I am using a mailchimp auto responder to contact them upon registering instead). I don't see where this code would disable the email that I should receive when they register, but I am a very novice wordpress user. Can anyone see something that I can change to allow me (the admin) to be notified when a user registers, but not send an activation email to the user?               function disable_validation( $user_id ) {       global $wpdb;       $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->users SET user_status = 0 WHERE ID=%d", $user_id ) );     }     add_action( 'bp_core_signup_user', 'disable_validation' );     function fix_signup_form_validation_text() {       return false;     }     add_filter( 'bp_registration_needs_activation', 'fix_signup_form_validation_text' );          function disable_activation_email() {     return false;     }          add_filter( 'bp_core_signup_send_activation_key', 'disable_activation_email' );      Thanks in advance.


title: How Can I Always Display A Particular Post First Using WP_Query?

text: My apologies if this question has already been asked somewhere else, I searched but couldn't find anything. I am working on a tours website, there will be individual package pages that show some text, images and some other stuff. On the right hand side of my single package pages I have a comparison table which is merely a custom WP_Query pulling out all packages from the database using the following code:               // Package fetching arguments     $pargs = array(         "numberposts" => -1,         "post_status" => "publish",         "post_type" => "packages",     );          // Get out packages     $cpackages = new WP_Query($pargs);      I however would like the first item of this comparison table to be the current package the visitor is viewing. Say for example the user is viewing a package called "Tour A" on the right hand side I would like to pull out all packages but make sure that Tour A is at the beginning and highlighted then the other posts displayed. I've looked into sticky posts, but they don't really apply to what I am wanting to do, because if someone is on Tour B, then it needs to be displayed first in the comparison table and then so on.


title: How to force jQuery to load as a first script in header in frontend?

text: How to force jquery to load as a first script in header? Right now it's the last ;( like:               <link type="text/css" rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" />     <link type="text/css" rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/jquery.selectboxit/3.6.0/jquery.selectBoxIt.css" />     <link type="text/css" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.css" />          <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>     <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.selectboxit/3.6.0/jquery.selectBoxIt.min.js"></script>                         <script type='text/javascript' src='http://localhost/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>      and I want them to be in this order:               <script type='text/javascript' src='http://localhost/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>                         <link type="text/css" rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" />     <link type="text/css" rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/jquery.selectboxit/3.6.0/jquery.selectBoxIt.css" />     <link type="text/css" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.css" />          <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>     <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.selectboxit/3.6.0/jquery.selectBoxIt.min.js"></script>      And my head looks like this:               <head>     <meta charset="<?php bloginfo( 'charset' ); ?>" />     <meta name="viewport" content="width=device-width" />     <title><?php wp_title( '|', true, 'right' ); ?></title>     <link rel="profile" href="http://gmpg.org/xfn/11" />          <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />     <?php // Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions. ?>     <!--[if lt IE 9]>     <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>     <![endif]-->          <?php wp_enqueue_script("jquery"); ?>          <link type="text/css" rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" />     <link type="text/css" rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/jquery.selectboxit/3.6.0/jquery.selectBoxIt.css" />     <link type="text/css" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.css" />               <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>     <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.selectboxit/3.6.0/jquery.selectBoxIt.min.js"></script>          <?php wp_head(); ?>          </head>


title: Integrating Html5Boilerplate's Builder into a WP Theme

text: So Im planning to use Html5Boilerplate as a base to build a new WP Theme on. The Boilerplate comes with the Builder, a handy Tool for minifiying, concatenating and compressing ones Website for obvious reasons: speed/performance-gain, easier mobile access and so on. I would very much like to use this feature with my theme. Problem: The builder outputs the processed files into a subdir /publish. Without WP one could use a .htaccess rule to reroute the base domain, e.g. mysite.net to mysite.net/publish. This is the method proposed by Html5Boilerplate. Since I can't possibly use this approach in a Theme, I would need a way to tell WP to go looking for the Theme's files in the /publish subdir of the actual Theme dir. Anyone know a way to do that? Alternatively, is there a way to tell The build script to look for the source Files in a subdir, and to subsequently publish the files into the theme root?


title: Display a widget on a specific type of archive

text: I have two sidebar widgets, I need to display 1 widget on the archive pages for the standard post categories and the other widget needs to show on just the archive pages for a specific custom post type. If I use the conditional tag is_archive() then both widgets will show up on both archive pages. How can I determine which archive page the widgets should be displayed on? I'm using the plugin 'Widget Logic' Thanks in advance


title: Populate meta select box with child pages

text: I'm trying to populate a drop down select meta box with a list of child pages of that page. I am using the wp_list_pages function to retrieve the list of child pages, no problem there. The problem is that the list is return as li items. What is the best way to get these into an `<option>` format suitable for a dropdown box?


title: If Specific Post, Link Elsewhere

text:
I would like to create a conditional statement that checks the loop for a specific post ID, then if true, it outputs a link elsewhere. This is what I have so far:               <?php query_posts('post_type=team&orderby=title&order=ASC'); ?>     <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>                  <div class="post grid" id="<?php echo get_the_ID(); ?>">
                                               <?php if ( is_singular( '2295' ) ) : ?>                         <?php the_post_thumbnail('team-thumb'); ?>                     <?php else : ?>                         <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail('team-thumb'); ?>                     <?php endif; ?>

<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>

          <?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
     <?php endif; ?>


title: Make plugin page follow standard enqueueing procedures

text: I am writing an administrator plugin that helps a user write some simple shortcodes. When the user clicks on a new button in the TinyMCE editor a ThickBox window appears and loads a PHP template I created with a heap of prompting fields. If I want to access new scripts or stylesheets in this window I have to hard code them into the PHP template. I.e.               <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">     <html xmlns="http://www.w3.org/1999/xhtml">         <head>             <title></title>             <script src="./scripts/myscript.js"></script>             <style src="./css/mystyles.css"></style>         </head>      I would much prefer to use best practice enqueuing methods as opposed to this method. Is there a way to make this PHP document in my plugins folder do all the normal WordPress processes (e.g. enqueue script and styles) as if it were just another page?


title: Remove last character in get_post_meta

text: I have a custom field that contains a sentence along with a punctuation mark at the end. I am looking to use this field as a title of the article on my homepage, but in doing so I would like to remove the last character of that custom field (so that the ending period of the sentence is not included in the title). **Here is the code I use to display the custom field on my homepage:**               <?php echo get_post_meta($post->ID, one_line_summary, true); ?>      I'm not great with PHP programming, so specific examples with my code would be preferred. Thanks in advance!


title: Sticky wp_dropdown_categories on Front End Form

text: I have built a front end posting form and I am trying to make the entire form sticky. I have used wp_dropdown_categories but I can not seem to figure out how to make it remember the selection if there are errors in other parts of the form after posting it. I appreciate any help/advice you can give.               <!-- post Category -->     <fieldset class="category">         <label for="cat" class="selection-title">Reason For closure and/or delay:</label>         <?php wp_dropdown_categories(array('echo' => 1, 'hide_empty' => 0, 'name' => 'cat', 'orderby' => 'name', 'selected' => $category->parent, 'hierarchical' => true, 'show_option_none' => __('Select a reason for closure/delay'))); ?>     </fieldset>     <!-- post Content -->


title: Is there any reason why using the same wp-config file might not work in MAMP?

text: I'm not sure why but when i just want to create a copy of a site that i'm working on in MAMP, that say i just downloaded from the web. I just copy the same wp-config file from another local version that i've been working on. But when i try to go to that new htdocs directory (which is essentially just a copy of the old one) it doesn't recognize the db. Can anyone see why this might be a problem or possibly warn me of other reasons why this would be a fail? Here is my process, I'm using a hosted version because I have another team working on it. I prefer to work locally so what i do is   1. download the files and images through a plugin    2. Create a new server in MAMP (titled Site2)    3. copy the contents of the backup zip (that i just downloaded from my server) into my new local server (title Site2)    4. Update the config file to be exactly like the current version that I have on MAMP (Site1) and when I go to that site I'm able to get onto the correct first page but then when I go into other pages I re-direct to the Site1 interior pages Could this be because I'm using the exact same wp-config file as Site1? Would this mean that with every copy or version of the site that I work on that I should created a new unique WP-config file? I realize that if I had worked with Git from the beginning this would be more manageable but I'm already in the site process Updated to illustrate my point: Currently in my wp-config file i have this:               // ** MySQL settings - You can get this info from your web host ** //     /** The name of the database for WordPress */     define('DB_NAME', 'wp_site1');          /** MySQL database username */     define('DB_USER', 'root');          /** MySQL database password */     define('DB_PASSWORD', 'root');          /** MySQL hostname */     define('DB_HOST', 'localhost');          /** Database Charset to use in creating database tables. */     define('DB_CHARSET', 'utf8');          /** The Database Collate type. Don't change this if in doubt. */     define('DB_COLLATE', '');


title: Custom taxonomy template

text: I make two custom post type called (movies and serials) and one custom taxonomy called (directors). When I go to `/directors/namedirector` I don't see movie. I need help to make query or template for `taxonomy-directors.php`.


title: Is there a way to call on just the content of a Page without actually using that Page?

text: The question sounds weird i know, but what i'm trying to do is add a gravity form into a template that i made. But all of their tutorials seem to be more along the lines of adding a form to a page and not so much to a template. So the idea was to use a get_content() from a specific Page that i created (called "Form" in this case) put that into it's own content-form.php file and then call a get_template_part() into the section of my template where i need it in. First off, is this too much abstraction? If it's just better to somehow call the form from this specific Form Page into my template of choice i'll do that but i'm just not sure how to go about this. Thanks.


title: Can a users profile be put under the dashboard menu

text: I was reading an article today and it covered some very valid points on user experience with WordPress. One of its points was that the profile should go under the Dashboard menu. I like this idea but not sure if it could be done.


title: Question about Menus on Wordpress

text: I have a question regarding something that is not working properly, I have a menu that is not working, currently with my theme I have 10 menus, one being the main nav and the rest are needed for special purposes, the thing is, the main one is not working, is taking the menu values from one of the other menus, but I'm sure I'm referring that menu in the right way. In my header I'm calling my menu like this:               <?php wp_nav_menu( array('menu' => 'Main', 'menu' => 'menu_center' )); ?>      And in my `functions.php` I have this:               add_theme_support('nav-menus');      if ( function_exists('register_nav_menus')) {         register_nav_menus( array(             'main' => 'Main Nav',             /* FOOTER MD USA */             'footer-opinion' => 'Footer Opinion',             'footer-noticias-economicas' => 'Footer Noticias Economicas',             'footer-consumo' => 'Footer Consumo',             'footer-empresas' => 'Footer Empresas',             'footer-noticias-actualidad' => 'Footer Noticias de Actualidad',             'footer-suplementos' => 'Footer Suplementos',             'footer-finanzas' => 'Footer Finanzas',             'footer-spotlight' => 'Footer Spotlight',             'footer-otras-publicaciones' => 'Footer Otras Publicaciones'         ) );     }      But the main nav menu is not working is displaying one of the footer menus and this is driving me crazy, any idea guys what I'm doing wrong? Thanks!


title: Display of comment_date within get_comments?

text:
Any way to change how the date is displayed with get_comments..? I have the following..                <?php            $comments = get_comments( array(            'post_id' => $post->ID,            'number' => 4,            'status' => 'approve'            ) );                 foreach($comments as $comment) :            echo "
            {$comment->comment_content}            {$comment->comment_date}            By {$comment->comment_author}
";            endforeach;          ?>      Comes out with something like.. 2012-02-20 17:09:07 when i just want something like 6th January 2011


title: Keep Logged in Users out of Admin Panel

text: So I'm creating user registration. Just simply `<?php wp_register(); ?>` but then it gives them a link to the admin panel, which in my situation they really don't need. How do I remove the "Site Admin" link and redirect a subscriber if they try to access the admin panel? I guess once they log in I will need to redirect them to a certain page also.


title: Emailing Authors only when a CUSTOM POST TYPE post is published- not when edited later

text: I have the following function that emails authors of a **custom post type** when the post is published which is great, but I would like it so that it does not email them on any future edits after that to avoid sending them loads of emails by accident. This is the function I have at the moment:               //email authors     function authorNotification($post_id) {        $post = get_post($post_id);        $author = get_userdata($post->post_author);             $message = "Hi ".$author->display_name.".     A document for you, ".$post->post_title." has just been published or edited and requires your attention.      You will be taken to the document after you log in from this link: ".get_permalink( $post_id ).".        ";        wp_mail($author->user_email, "An online document has been made or edited for you.", $message);     }     add_action('publish_portaldocuments', 'authorNotification');      I'm wondering if it has something to do with the The {$old_status} _to_ {$new_status} and {$new_status}_{$post->post_type} hooks as on this page: Post publish only hook? Could someone help please as I'm not sure how I would implement it WITH A CUSTOM POST TYPE. Thanks :-) **Update** : This worked for me:               // SEND EMAIL TO AUTHOR OF A CUSTOM POST TYPE ONCE POST IS PUBLISHED          function authorNotification($post_id) {         if( ( $_POST['post_status'] == 'publish' ) && ( $_POST['original_post_status'] != 'publish' ) ) {      $post = get_post($post_id);        $author = get_userdata($post->post_author);             $message = "Hi ".$author->display_name.".     A document for you, ".$post->post_title." has just been published or edited and requires your attention.      You will be taken to the document after you log in from this link: ".get_permalink( $post_id ).".        ";        wp_mail($author->user_email, "An online document has been made or edited for you.", $message);         }     }          add_action( 'publish_portaldocuments', 'authorNotification' );


title: Notification to Admin or Author upon new post

text: I am using a custom function with 'publish_post' hook for a notification to the author when the post has been published but the issue I am facing right now is that the notification is being sent out twice and as well when the post is updated. Here is how my function looks.               function authorNotification($post_id) {        $post = get_post($post_id);        $author = get_userdata($post->post_author);             $message = "           Hi ".$author->display_name.",           New post, ".$post->post_title." has just been published at ".get_permalink( $post_id ).".        ";        wp_mail($author->user_email, "New Post Published", $message);     }     add_action('publish_post', 'authorNotification');      am I missing something here?


title: Filter causing loss of _wp_attachment_metadata

text: A while back I asked this question: Save camera info as metadata on image upload? Long story short, it works in that the custom field is saved into wp_postmeta and I can access that value. But as I'm revisiting the project, I've noticed a side-effect. With the following code in place to save the extra photo metadata, _wp_attachment_metadata no longer gets saved to the database. This obviously leads to several issues with image sizes and the image editor in WP:               add_filter( 'wp_generate_attachment_metadata', 'mvt_save_photo_credit', 10, 2 );          function mvt_save_photo_credit( $metadata, $attachment_id ) {         add_post_meta($attachment_id, '_mvt_credit', $metadata['image_meta']['credit'], true);     }      I can't figure out why _wp_attachment_metadata no longer gets saved with this filter in place. Everything seems to line up as it should, and the filter itself successfully writes the data it's meant to. Removing the filter returns the expected functionality (_wp_attachement_metadata is correctly saved to the DB), so I know the issue has to do with this filter. Any help would be greatly appreciated. Thanks.


title: Automatically Facebook Debug Posts on Publish

text: I am looking to do something similar to this plugin which adds an "FB- Debugger" link on the admin of pages/posts: http://xlino.com/projects/facebook-debug-link-wordpress-plugin/ However, I'd like to make this even more automated by sending the post url directly to the Facebook Debugger on publish or re-publish by opening the debugger in a new browser tab with the results for the url. This seems pretty possible because the url that would be passed to the debugger looks like http://developers.facebook.com/tools/debug/og/object?q=mysite.com/my-post I guess my question is how can I automatically open up a new tab with: http://developers.facebook.com/tools/debug/og/object?q=[ **post-url** ] a second or two after the post is published or changed (there would need to be time delay for FB to find the post) ? I know a little PHP and it seems like a pretty simple command, but what core WP file would I edit? Im using WP 3.3.1 . I've done some frontend template tweaking but nothing that changes or adds on to the admin. Thanks!


title: Migration: Copying database content to a different server

text: I'm migrating our WordPress site from one server to another. I need some hint on how to deploy a database dump (which I have) from the original server to the new one. There is no phpmyadmin (at least I don't have access to it), so I need to copy the dump using console. Or maybe there is some WordPress plugin for this? Thanks in advance!


title: How to disable "insert into post" only when selecting the Featured Image?

text: I wish to restrict the user from putting inline images in the article. I am using the Wordpress Attachments plugin to allow the user to attach images, which I then position and stylize the way I want. I also managed to remove the Upload/Insert link from the post through adding a hook to my functions.php of my theme. (Thanks to an answer here.) However, I noticed that the "Insert into post" link is still there when the user presses the "Set Featured Image" link. I want to allow him to set a featured image but not insert into post. I tried another solution I found (inverting the logic here) and added this function:               add_filter( 'get_media_item_args', 'force_send' );     function force_send($args)     {        $args['send'] = false;        return $args;     }      Which does the job and disables the "Insert into post" button, but on the other hand it also stops the Attachments plugin from working (the Attach button disappears) and also other plugins using the same image uploading dialog stopped working. Is there any way I can detect that the "Set featured image" link was clicked in the function `force_send()` above so that I only disable the button when the user clicks the set featured image? Alternatively, is there any better way to stop the user from putting images in the WYSIWYG editor? There doesn't seem to be any permission setting anywhere to stop a user from doing so. **UPDATE (ACTUAL SOLUTION)** Just want to post my solution, based on the answer below, just for completeness in case anyone needs it. It also hides the "Insert into Post" button.               add_filter( 'get_media_item_args', 'force_send' );     function force_send($args)     {       // for the media upload popup we get the Post ID from the $_GET URL parameter list       $post_id = $_GET['post_id'];            // with post ID in hand we now get current post_type              $post_type  = get_post_type($post_id);            // define list of our restricted post_types       $restricted = array('post', 'page');            // check current post_type against array of restricted post_types       if (in_array($post_type, $restricted))        {         // if our current post_type as returned from get_post_type is in array          // we return false to void inserting image into post editor         $args['send'] = false;       }             return $args;     }


title: Can't Get 'tag' Page To Display only Tagged Posts

text:
I made a tag.php under my theme folder in order to style all of the tagged post pages from urls like 'www.mywebsite.com/tag/kittens'. However, if I go to 'www.mywebsite.com/tag/kittens' it displays all of my posts, even the ones that are not tagged 'kittens' or at all. I used the the standard loop, and I can't find a way to alter it to grab the tag page name and only return those posts without making a separate 'tag-kittens.php' type page for every single tag. Help? * * *               <?php         get_header();         query_posts( 'posts_per_page=5' ); ?>          <?php the_tags( $before, $sep, $after ); ?>           <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>
                 <?php the_time('F jS, Y') ?>
         <?php the_content(); ?>

            <?php endwhile; else: ?>
Sorry, no posts matched your criteria.
      <?php endif;         get_footer();      ?>


title: Nested Admin panel sub menus in single menus

text: i know how to add custom menu in the admin panel and how to add multiple sub menus in the custom menu. But i want to know can we add nested sub menus in the custom menu (WordPress admin panel)? Means Custom Menu-->submenu 1 --> submenu 1.1--> and goes on.


title: Hide Meta Boxes for Non-Admins

text: I have a review based wordpress site where I have a page for each different company where there users can review them. The theme I use adds a custom post type called "review" and I have used Press Permit to create limited user accounts that can modifying some parts of these review pages. I wanted to hide some of the Meta Boxes that they should not have access to such as Yoast SEO, GD Star Ratings, etc. I followed the instructions from some other posts on this website, however it does not hide the meta boxes as it should. I have added the following code at the end of the "functions.php" in my Theme directory as per the instructions at WordPress SEO by Yoast: Hide Meta boxes in posts for non-admins               add_action('add_meta_boxes', 'hide_yoastseo_metabox', 99);          function hide_yoastseo_metabox()     {         if (!current_user_can('activate_plugins'))         {             remove_meta_box('wpseo_meta', 'review', 'normal');         }     }


title: Removing taxonomy base using WP rewrite

text: I´m trying to create the following URL structure:               example.com/attractions                     <-- post type archive     example.com/attractions/taxonomy_term       <-- taxonomy archive     example.com/attractions/van-gogh-museum     <-- custom post type      Unfortunately this isn´t possible by default: WordPress needs the taxonomy base in the URL, as SE user sanchothefat wrote in his answer to this question: > _...if you don't want the taxonomy-slug to be there then you're out of luck, > you can't have the same slug as your post type or another taxonomy as it > won't know what term is from which taxonomy and what's a post._ In other words, WordPress needs this permalink structure:               example.com/attractions/taxonomy_base/taxonomy_term      **My question:** Is there a way to make this work using WordPress rewrite API? I suppose it involves 2 steps:   1. Removing the taxonomy base from the URL    2. Tell WordPress what post type it needs to display * * * ## Update #1 I found a code snippet that should remove the taxonomy base from the URL:               global $wp_rewrite;     $wp_rewrite->extra_permastructs['taxonomy_base'] = array('%taxonomy_base%', EP_NONE);      (Source - see last answer on bottom of page) This isn´t the complete solution though, since WordPress can´t tell if the post is a taxonomy archive or a post type... * * * ## Update #2 The author of this great article on _Advanced Taxonomy Queries with Pretty URLs_ wrote me: > _What you're asking isn't too difficult, but it could be a bit tricky. The > rewrite rules need to know what type of thing the second term is(..) That's > why the category/tag/taxonomy name prefix is prepended. You could create a > rewrite so that _everything_ after /attractions/ is treated as a taxonomy > URL, but doing both gets a little tricky._ * * * ## Update #3 For anyone having the same issue, have a look at this discussion on WordPress Answers. Especially MikeSchinkel´s plugin code might help. Here´s an interesting example of WPCandy combining the taxonomy base and term in the URL: `http://wpcandy.com/pros/experienced/with-multisite`


title: get_template_directory_uri() and other URL tags not working in theme

text: So, I'm trying to add get_template_directory_uri or bloginfo() to my header.php file to create relative paths for the CSS and JS files in the theme. E.g.,                   <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/style.css">      In theory this should show                   <link rel="stylesheet" href="http://mysite.com/wp-content/themes/myTheme/css/style.css">      Problem is, when I view the `<head>` tag in source all I see is:                   <link rel="stylesheet" href="/css/style.css">      All the other template tags work in my files (get_permalink(), the_title(), etc.), but this one isn't. `echo get_bloginfo('url')` Also works. I was thinking of messing with the `wp-config.php` file and doing something like:               define('WP_HOME','http://example.com/blog');     define('WP_SITEURL','http://example.com/blog');      ...but, I'm not sure if that's the best practice for rewriting the URL. Am I missing something?


title: wp_mail and BCC headers

text: I'm using WP 3.3.1 I am trying to add BCC onto the headers of an email I'm sending out, but the BCC is not being added.               public $from = "sender@example.com";     public $replyTo = "sender@example.com";     public $bcc = "bccaddress@example.com";          $headers['From']    = "From: ".$this->from;            $headers['Reply-To'] = "Reply-To: ".$this->replyTo;     $headers['Bcc'] = "Bcc: ".$this->bcc;          wp_mail("example@example.com", "My Subject Line" , $html, $headers);      I've looked at this article, which says the problem was suppose to be fixed in WP 3.2...but for me, it's still not working. I am using a local SMTP server application called Papercut to monitor the emails that are being sent. **Related:** wp_mail not recognizing cc and bcc headers


title: Editing Wordpress Permissions in LAMP - Ubuntu 11.10

text: I'm hosting a local version of my wordpress theme on Ubuntu 11.10. However, LAMP is installed in a directory that requires sudo privileges. When I try to add images or any outside content to my theme, it fails because it cannot create a folder/write to a folder. How do I edit the permissions to allow Wordpress the access it needs?


title: How to process shortcode on post save and update only

text: Below is a simple shortcode I have so that in an article, I can simply link keywords to **tag taxonomy** pages in my site. So if I were to wrap the term `Web Service` like this `[taglink]Web Service[/taglink]` then the function below would replace the space with a `-` to make `Web- Service` which would be my **tag taxonomy** so I could then link to that page. **This...**   `[taglink]Web Service[/taglink]` **Becomes this...**   `<a href="/tag/web-service" title="Web Service tagged articles">Web Service</a>` **The code**               function taglink_func($atts, $tag='') {         $formattedTag = str_replace(' ', '-', $tag);         $formattedTag = strtolower($formattedTag);         return '' .$tag. '';     }     add_shortcode('taglink', 'taglink_func');      * * * This solkution works fairly well but to improve performance even more, I would like to run this function when I create a new article and when I edit and article, so basicly only when an article is saved, I would like to run this function on any tags in the article and then replace the `[taglink]Web Service[/taglink]` in the actual database with the result. So instead of running this on each page view, it will be ran on page save and simply replace the code in the database with the URL link. Does anyone know how I can do this?


title: Display sidebar that created in functions.php

text: I'm currently using Wordpress theme for my website. Decide to create my own sidebar, but the styling of it must be remain the same one as original sidebar. I'm had create a new sidebar in functions.php using register_sidebar. How my theme create sidebar was just `<?php get_sidebar(); ?>` nothing else. In my theme folder, there is not extra sidebar php file created. I'm try to use `<?php dynamic_sidebar( $index ); ?>` but it does not works for me. I just want to **add new widget to my second sidebar that I created and the style will be default.** **Functions.php**               if (function_exists('register_sidebar')) {     register_sidebar(array(     'name'=>'Sidebar-Aries',     'id' => 'sidebar-aries',     'description' =>'Display all the contents of sidebar at Aries page.',     'before_widget' => '',     'after_widget' => '',     'before_title' => '',     'after_title' => '',     ));     }      **Using dynamic sidebar,**               <?php dynamic_sidebar('sidebar-aries'); ?>


title: Extra richtext admin textfield for custom posttype with toolbar tabs?

text: I am trying to add an extra rich text input field (like so, http://wordpress.org/support/topic/how-can-i-use-the-tinymce-editor-for- fields-in-my-custom-post-type) So just by adding the class class="theEditor", brings up tiny mce for my extra textfield. So far so good, but 1/ how do i add the editor toolbar with the wysiwyg/HTML tabs for the newly created textfield? 2/ As i am using the plugin qTranslate i also like to add the language tabs Any tips? regards


title: Insights into WordPress Multi-Site, Domain Mapped, and Multilanguage site using WPML

text: I have a project with WordPress for a multi-language, multi-country site. I want to have a structure like:   * domain.com     * domain.com/es     * domain.com/de     * domain.com/fr   * domain.es     * domain.es/en   * domain.fr     * domain.fr/en   * domain.de     * domain.de/en I was wondering if anyone had any useful articles, tips or insights. The idea is that the .com site be the 'parent' site. The other satellite sites would be in their native language by default, but might have other languages available. Ideally, each individual satellite site could have some leeway to have styles/content that would be different than the parent site. I also want the parent site to use canonicalization, so that the 'satellite' (country-specific, top-level-domain) sites have priority. I guess I'm most curious to know about: Domain mapping and compatibility with WMPL Thanks


title: Using pre_get_posts with WP_Query

text: I was reading Stephen Harris's excellent answer to this question regarding the use of WP_query(), query_posts() and pre_get_posts. He says "pre_get_posts is a filter, for altering **any** query. It is most often used to alter only the 'main query'." It is possible to use pre_get_posts to filter **only** a specific secondary query created with WP_Query? eg.               $my_secondary_loop = new WP_Query(...);     if( $my_secondary_loop->have_posts() ):         while( $my_secondary_loop->have_posts() ): $my_secondary_loop->the_post();            //The secondary loop         endwhile;     endif;     wp_reset_postdata();      Any help much appreciated.


title: How To Remove The Author(s) From Certain Posts

text: There are certain posts on the website I'm developing, that don't need the author(s) by-line. (such as press releases) Is there any method, that allows me to remove the author (and co-authors) for certain posts?


title: What is generating my meta og:description?

text: My site has Facebook social graph meta tags in its page:               <meta property="og:title" content="First Look at Dwarves from The Hobbit"/>     <meta property="og:description" content="Movie"/>      The only Facebook-related plugin I have installed Facebook Page Publish. Why is it only picking up the category of the post? There are no options to configure the og meta tags of this plugin. **UPDATE** I now figure I can use the post excerpt as the value for og:description, but whenever I use either of these functions:   * get_the_excerpt();   * the_excerpt(); the page outputs the following code:               <!-- AddThis Button Begin -->     <script type="text/javascript">var addthis_product = 'wpp-261';     var addthis_config = {"data_track_clickback":true,"ui_508_compliant":true};</script>      <script type="text/javascript" src="//s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4df74bc61d613ae9"></script>"/>      I then configured the AddThis Wordpress plugin to remove Add This from the post excerpt, but the same code is still spat out by the excerpt functions.


title: Post publish date

text: if I have more than one posts that publish in the same day, `the_date()` function does not print publish date. How can I fix it? thanks I solve this by: "`the_time(get_option('date_format'));`"


title: WordPress | Date not always appear

text:
> **Possible Duplicate:**   >  WordPress the_date() not working I try to create a theme. In that theme I have create a custom post type and I quering the WordPress by using the wp_query to get the posts from that post type with the code that following :               $args = array(         'post_type'         =>  'portfolio',         'posts_per_page'    =>  18     );          $projects = new WP_Query($args);          while($projects->have_posts())     {         $projects->the_post();     ?>
<?php the_title(); ?>
     <?php the_date(); ?>     <?php     }          wp_reset_postdata();      the problem is, that while I get the title for all of my posts, I do not get the date for all of my posts. Some posts have the date, other they don't Any idea for that issue ?


title: Sort on meta value but include posts that don't have one

text: I've been modifying the built in WP search using the `pre_get_posts` filter, allowing the user to sort the posts (including a bunch of custom post types) by different fields. The problem I'm having though is that when I tell WP to sort by a meta value it will exclude all posts that don't have that meta value set. This causes the number of results to change if you change sorting from say "Price" to "Date" because "Posts" don't have "Price" set but "Items" do. This is not what I want, so I'd like to know if there's a way to include ALL posts - even those that lack the meta value I'm sorting on - and put the one's without the value last. I know how to sort on more than one field but that doesn't help. Thanks Seems I'm not the only one with this question: Way to include posts both with & without certain meta_key in args for wp_query? but there's no solution there. **Update** I've tried the answer but not sure if I understood correctly, here's what I have right now:               <?php     function my_stuff ($qry) {         $qry->set('meta_query', array(array(             'key' => 'item_price',              'value' => '',              'compare' => 'NOT EXISTS'         )));              $qry->set('orderby', 'meta_value date'); # Sorting works with meta_value as well as meta_value_num - I've tried both         $qry->set('order', 'ASC DESC');         $qry->set('meta_key', 'item_price');     }      The meta value is a number (it is used to store a price as the name suggests) **Update 2** I've commented out the order-stuff and all I have now is this:               <?php     $qry->set('meta_query', array(array(         'key' => 'item_price',          'value' => '',          'compare' => 'NOT EXISTS'     )));      With this code the query seems to return all posts that don't have the `item_price` key and none of the posts that have it. I.E. the problem is now reversed. If I add in the order-code as well I get 0 results.


title: When creating a WordPress page, a "-2" suffix is added to new pages' permalinks

text: I have noticed after deleting an original page in WordPress with lets say a permalink of `your_domain.com/contact/` and then trying to recreate the same page with the same name/slug, my WP is generating a " _-2_ " at the end of the link, like: `your_domain.com/contact-2/`. I don't understand why, since the original page was deleted. Why is WordPress treating new pages as if the original still exists? How to I clean WP caches, if such a thing even exists?   Thank you ahead of time for clearing this up for me.


title: Reload meta box content with AJAX

text:
I want to build a meta box that contains multiple textfields which get filled if a submit button is pressed. The data is set by a function which should get called if the button is pressed. How can I do this with AJAX, without reloading the page? My attempt for the meta box content was the following (everything is written in a plugin **.php file /plugins/myplugin.php** ):               <?php          // register metabox     add_action( 'admin_init', 'my_admin' );          // add metabox     function my_admin() {         add_meta_box( 'movie_info_div',             'Fetched information:',             'display_info_mbox',             'my_custom_post_type',             'normal',             'high' );     }               add_action('wp_ajax_fetch_action', 'fetch_action_callback');          // function that should be called if button is pressed     function fetch_action_callback() {         $input = esc_html( $_POST['input'] );         $input .= ' + fetched data';         echo $input;         die();     }      The function to display the metabox content:               // Display metabox content     function display_info_mbox( $movie_review ) {         ?>             Start fetching             <input id="source" type="text" value="" />             <input id="content" type="text" value="" />

                               <?php } ?>      Actually I just want to build **a button that triggers a php script** which returns some fetched data to a form, depending on a text-input but with a submit-button it reloads the whole page. As I am completely new to AJAX and jQuery I'm kind of lost. I would appreciate your help.


title: Why was my plugin rejected from the WordPress.org repository?

text: I have made a WordPress plugin, and it works. But when I send it to the WordPress.org plugin team, they responded: > Calling wp-load.php directly > > Including wp-config.php, wp-blog-header.php, wp-load.php, or pretty much any > other WordPress core file that you have to call directly via an include is > not a good idea and we cannot approve a plugin that does so unless it has a > very good reason to load the file(s). It is prone to failure since not all > WordPress installs have the exact same file structure. Usually plugins will > include wp-config.php or wp-load.php in order to gain access to core > WordPress functions, but there are much better ways to do this. It's best if > you tie your processing functions (the ones that need but don't have access > to core functions) into an action hook, such as "init" or "admin_init". > > Please consult the Plugins API reference for more information: > http://codex.wordpress.org/Plugin_API If you're trying to use AJAX, please > read this: http://codex.wordpress.org/AJAX_in_Plugins I don't know what to do :( This is my plugin http://szymoon.nazwa.pl/plugins/Printer-Friendly-WP.zip Where is a good example of making the correct plugin? Or one that was accepted by the WordPress.org team.


title: Copy Widget Settings because of changed IDs

text: I want to update a customers blog to a child theme that is based on a newer version of the actual deployed theme. My problem is, the developers of the theme changed the IDs of sidebars. In the old version `register_sidebar()` was called without providing an ID, therefor WP used numeric IDs. Now developers named the IDs alphanumerical (`home-1`, `home-2`, etc). I couldn't find out how to copy the widget settings in the database from one sidebar to another. Therefor I registered the new sidebar IDs in the old theme and the old sidebars in the new theme. Than I used the Duplicate Widget Plugin to replicate the widgets in the new sidebars. When I preview the new theme, everything looks good, but upon activation my widgets are gone. Looking into the widget backend and my sidebars are mostly empty, except one or two. Reactivating the old theme and everything's fine. I also tried to export and import widget settings, but one plugin didn't install correctly and the other one exported a mostly empty `widget_settings.xml` file shown below. ` <?xml version="1.0" encoding="ISO-8859-1"?><widget_settings></widget_settings> `


title: How do i use the use the wooCommerce functions in a wordpress plugin?

text: How would i use the wooCommerce hooks in my wp plugin? Here is what i am trying to do:                   add_filter('woocommerce_edit_product_columns', 'pA_manage_posts_columns');         function pA_manage_posts_columns($columns, $post_type = 'product') {         global $woocommerce;     if ( in_array( $post_type, array( 'product') ) ) {             $columns['offering_price'] = __( 'offering price', 'your_text_domain' ); // this offering price title              $columns['offering_qty'] = __( 'Qty', 'your_text_domain' ); // add the quantity title     }         unset($columns['name']);     return $columns;      } I have included the woocommerce class:               $ds = DIRECTORY_SEPARATOR;     $base_dir = realpath(dirname(__FILE__)  . $ds . '..') . $ds;     $file = "{$base_dir}woocommerce{$ds}woocommerce.php";      include_once($file);


title: Featured Image not shown and getting error "Object of class WP_Error could not be converted to int"

text: First of all I'm using twentyeleven theme, I created a custom template page to insert posts. **It has 4 submit forms. it is working well, also setting feature image is ok for 3 forms except the first one it is not setting feature image for the post even it upload the image (using upload form and also using image from link) and attach it to the post** , what makes me crazy is that I'm using the same function to set feature image, but I don't know why it is not working with the first submit form This is my code for setting feature image:               $pid = wp_insert_post($new_post);     $upload_dir = wp_upload_dir();     $image_data = file_get_contents($image_url);     $filename = basename($image_url);     if(wp_mkdir_p($upload_dir['path'])){         $file = $upload_dir['path'] . '/' . $filename;     }else{         $file = $upload_dir['basedir'] . '/' . $filename;     }     file_put_contents($file, $image_data);          $wp_filetype = wp_check_filetype($filename, null );     $attachment = array(         'post_mime_type' => $wp_filetype['type'],         'post_title' => sanitize_file_name($filename),         'post_content' => '',         'post_status' => 'inherit'     );     $attach_id = wp_insert_attachment( $attachment, $file, $pid );     require_once(ABSPATH . 'wp-admin/includes/image.php');     $attach_data = wp_generate_attachment_metadata( $attach_id, $file );     wp_update_attachment_metadata( $attach_id, $attach_data );          set_post_thumbnail( $pid, $attach_id );      I'm getting these errors 1- In the the **home** page and **edit post** in admin area: `Object of class WP_Error could not be converted to int in SITE_ROOT/public_html/wp-includes/post.php on line 4294` which leads me to `wp_attachment_is_image` function in the main post.php page               function wp_attachment_is_image( $post_id = 0 ) {         $post_id = (int) $post_id;         if ( !$post = get_post( $post_id ) )             return false;              if ( !$file = get_attached_file( $post->ID ) )             return false;              $ext = preg_match('/\.([^.]+)$/', $file, $matches) ? strtolower($matches[1]) : false;              $image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );              if ( 'image/' == substr($post->post_mime_type, 0, 6) || $ext && 'import' == $post->post_mime_type && in_array($ext, $image_exts) )             return true;         return false;     }      I tested `$post_id` by is_int and fount that is is integer 2- In the home page : `Object of class WP_Error could not be converted to int in SITE_ROOT/public_html/wp-includes/functions.php on line 3814` which leads me to `_get_non_cached_ids` in `functions.php` page               function _get_non_cached_ids( $object_ids, $cache_key ) {         $clean = array();         foreach ( $object_ids as $id ) {              $id = (int) $id;             if ( !wp_cache_get( $id, $cache_key ) ) {                 $clean[] = $id;             }         }              return $clean;     }      I tested `$id` by is_int() and I got that **it is not integer** How can I fix that problem, and why only this first form is not setting feature image even it is attach the image to the post


title: Include title and content of one page in another page

text: In this question contents of another page can be rendered to another page, but how do I do it for the title too? Can I just go `$content = apply_filters('the_title', $post->post_content);`? But what do I add at the second argument? From how it looks like, it's an array right? Which one stores the actual title of the page?


title: How to get "custom post type"-archive with working permalink to it?

text: First I will show my permalink structure: `/%category%/%post-name%/` Then, I created a custom post type. And now I want to create an archive for those posts related to my custom post type. So I wonder, how will I do that? Viewing it in the WordPress documentation, there is something about create a `archive-{post-type}.php` file, but I still don't understand how it works, and it says nothing about how the permalinks will look like. What should I do?


title: Use a language specific thousand separator

text: I have a views counter on each post. When it reaches for example 1000, it adds a dot as the thousand separator, the result is 1.000. This is odd in my language, I should have a space as separator or nothing. How can I change that?!


title: How to get current term in my custom taxonomy in WordPress?

text: I need to display the current term in my custom taxonomy in a single post. **example:**   * My custom taxonomy is _products_ and term of them is _product-1_ , _product-2_ and _products-3_.   * My post is assigned to _product-2_   * And I want to print the current products = _products-2_ in my post In fact, I need a function like WordPress's `the_category();` but for my taxonomy like `the_customtaxonomy();` UPDATE : in facts i know i need to get id of this becuse i need to show a icon for this in my single , for example a function like `the_category_ID();`


title: Parked domain redirecting to wrong error404 page

text: I have 3 different WordPress sites on my host provider in a linux shared hosting package. The main domain is domain-a.com. A secondary add-on domain is domain-b.com. I have a parked domain domain-c.com that redirects to domain-b.com. All are registered elsewhere and the a-record points to this host provider. Here's the problem: when a user types domain-c.com it properly redirects to domain-b.com. No problem there. The problem occurs when a user types domain-c.com/something.html (anything that is not found on the domain-b.com). It produces my error404 page for domain-a.com, not domain-b.com. I am told by the host providers (at the registrar and this host) that this is a WordPress issue because of the htaccess file and how WP resolves the domains. I have tried a plugin named Simple 301 Redirects but it has no effect here. Any suggestions? Thanks, Larry


title: How to force buddypress users to complete profile after registration?

text: Seems logical for any other network, not for buddypress though :( We all know the extended user profiles in buddypress - problem is, even though some fields are marked as required, that "required" seems to have no real significance for buddypress developers. So we have some "required" fields, which nobody EVER asks the user to fill in ... "Great" job so far ... So the question is... how can we force the newly registered user to first fill in all those required fields from the extended user profile, BEFORE he is able to use anything on the site !? Like he registers with name, prename, email and once he logs in he will be presented with a page/screen where he will have to first complete all the other missing required fileds, before he'll be able to see ANY content on the site !!? Anyone please an idea about how to achieve this? It's more than 1 year I think I search for a solution ... :-(


title: Memory question on Wordpress Multisite

text: Im currently using WP-Memory-Usage plugin on my wordpress multisite network to monitor my memory usage. The memory usage displays **39.1 MByte**. Does it mean **39.1 MByte** per blog?


title: Remove taxonomy slug from a custom hierarchical taxonomy permalink

text: I created a 'forum' taxonomy, using these rules:               register_taxonomy(       'forum',       array('topic'),       array(         'public' => true,         'name' => _a('Forums'),         'singular_name' => _a('Forum'),         'show_ui' => true,         'show_in_nav_menus' => true,         'hierarchical' => true,              'labels' => array(           'name' => _a('Forums'),           'singular_name' => _a('Forum'),           'search_items' => _a('Search Forums'),           'popular_items' => _a('Popular Forums'),           'all_items' => _a('All Forums'),           'parent_item' => _a('Parent Forum'),           'parent_item_colon' => _a('Parent Forum:'),           'edit_item' => _a('Edit Forum'),           'update_item' => _a('Update Forum'),           'add_new_item' => _a('Add New Forum'),           'new_item_name' => _a('New Forum Name'),         ),         'query_var' => true,         'rewrite' => array('slug' => 'forums', 'with_front' => false, 'hierarchical' => true),         )     );      In the front-end the URLs looks like:               forums/general-discussion/sub-forum      How can I remove the front slug ("forums")? Ie, change the URLs to:               general-discussion/sub-forum      If I pass a empty slug argument to register_taxonomy() it works, but that causes issues with the permalinks of the post type associated with this taxonomy


title: Shortcode content filter?

text: I'm looking for something, but don't exactly know what. I have a shortcode, let's call it [shortcode]. Users will input HTML tags inside, mostly images, but also links, images in links, etc., for example:               [shortcode]               (...)     [/shortcode]      The point is I want to format URLs, differently, I want every img src to start with files/myimagescript? So the code above should output:                                      (...)           So basically I need to simply change src of images. And it should work for any number of images, from 1 to unlimited. I'm thinking about foreach PHP loop, but I'm not sure how to grab each img src line from shortcode and process it before displaying?


title: if (has_custom_menu())?

text: I've taken this line from header.php of TwentyTen where its loading the custom menus...               <?php /* Our navigation menu.       If one isn't filled out, wp_nav_menu falls back to wp_page_menu.       The menu assiged to the primary position is the one used.       If none is assigned, the menu with the lowest ID is used.  */ ?>     <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>      I understand their fallback plan, but for mine, if no custom menu has been assigned to my custom menu selector, I don't want to return anything. What's the function to determine if my custom menu has an assigned menu?


title: Remove li from wp_nav_menu

text: How can I remove the li from wp_nav_menu? I know I can remove ul but is it also possible to remove the li? I would want to do this on just one menu not all the menus on my site.


title: Post/Page Preview Template

text: Is there a way to have a custom template php file that is only used for previews instead of it using the single.php file? This way the user knows they are in preview mode?


title: Resizing the wordpress editor

text: I've been looking around on how to re-size the WYSIWYS editor for wordpress and have used firebug to re-size the #post-body-content but it doesn't resize ever. It will resize in the firebug application but not when I go to put it into my style.css for my toolbox theme.               #post-body-content {         width:650px !important;     }      Is there something I have to put in the functions.php page? Site is here UPDATE I've placed the provided code into my function.php file and it worked but only half of it. I've tried to place another style for another part I see but it doesn't apply the style. Am I only allowed one style in the new function? ![enter image description here](http://i.stack.imgur.com/2NuZP.png) The line just behind the content is the newly resized editor, but the content is still spilling past it. Would it be because of the Tiny MCE toolbar?


title: How to looping taxonomy terms?

text: is there any way to loop terms in a way they display in menu? Eg: Let say I have 2 taxonomies in a post type - tax1 and tax2. They are not hierarchical to each other. If I have posts that have terms like this:   * post 1 => tax1 = p1 ,tax2 = term1   * post 2 => tax1 = p1 ,tax2 = term2   * post 3 => tax1 = p1 ,tax2 = term3   * post 4 => tax1 = p2 ,tax2 = termA   * post 4 => tax1 = p2 ,tax2 = termB   * ......etc Can I use               if(tax1=p1) echo 'term1,term2, term3... in menu/widget'     elseif if(tax1=p2) echo 'termA,termB, termC... in menu/widget'      in my template to display the tax2 terms in the sidebar menu? Somebody might wondering why I don't want to use parent-child terms. Well, this is because I expects have hundreds of term in tax2. If I use hierarchical taxonomy, that will be very long list in single taxonomy. I don't know whether WP able to process them or not.


title: Forcing absolute <img> src links in the RSS feed

text: We are using relative image URLs in the post's HTML code. Looks like relative src links break on many RSS readers. By default, Wordpress does not seem to prepare post's HTML for feed too much. Does there exist any solution for post-processing the feed URL and encoring all links and src attributes to be absolute?


title: Is it possible to install BuddyPress with blogs installed on several servers?

text: As far as I know, if you want to install BuddyPress you've got to have a WordPress MU installation (I know WordPress 3.x already is MU in itself) **with a unique database** , which has different tables for each blog. But my situation is quite different: we have a blog network, and **we would like to have a buddypress installed** for all our blogs. This way users could register once and comment on the blogs automatically, see their activity, link to other users, etc. But **the blogs are on different servers** :( Our current physical division of blogs (some of them are together in the same server, but others are in different servers, **each with its own database** ) makes me think this is quite difficult to do. I know that the Multi-DB plugin could help us with the database thing, but... what if the blogs are, as in our situation, in different servers/VPS's?


title: SHOPP breadcrumbs (that work!)

text: Anyone who has used SHOPP, the ecommerce plugin, will know that the breadcrumbs are a little crappy... I would like them to work throughout the site. I currently use Yoast Breadcrumbs plugin, but the chain for SHOPP stops after the 'store' part. For example; the url would be http://example.com/store/category/a-category/ and the breadcrumbs would only show 'home >> Store', with home being the only link... Not sure why this is, but would really like a fix for it if anyone has any experience with SHOPP! Thanks


title: How can I grant capabilities directly to users (not roles) in wp-admin?

text: I want to create dynamic capabilities using WP_Role::add_cap(), something like               $author_role = get_role('author');          foreach ($sections as $section) {         $author_role->add_cap( "edit_{$section}_pages", /* grant= */ false );     }      and then let administrators grant certain of those capabilities to certain authors only (e.g., Jane can edit_school_pages) in wp-admin ( **not** programmatically, via WP_User::add_cap()). I assume a plugin can help with this, but those I've found (e.g., Capability Manager) seem to emphasize creating new Roles or Capabilities and adding/moving Capabilities among Roles, not granting capabilities directly to users (though I could be wrong). Advice? Thanks, s


title: Comments Reply Form

text: When I click on Reply, the reply form appears at the bottom of the page (under the last comment). How can I add the Reply Form inside the comment to which I am going to add the reply?


title: How do I add media to a custom post type?

text: I want to add some custom fields to allow a user to select items from the Media library for the custom post (in the add/edit view) Is there a way to do this?


title: Display in category ( taxonomy) a number of post that I want

text: How can I display a number of 20 posts in my Page Archive (Taxonomy Archive)? For example: in wordpress settings in Reading I use: Blog pages show at most 10 posts.   This works in arhive page, but when I click on the categories (taxonomy's) it display only 10 posts. I have this function that displays the archive:               function iti_custom_posts_per_page($query)         {             switch ( $query->query_vars['post_type'] )             {                 case 'trailers':  // Post Type named 'iti_cpt_1'                     $query->query_vars['posts_per_page'] = 20;                     break;                      case 'persoane':  // Post Type named 'iti_cpt_2'                     $query->query_vars['posts_per_page'] = 6;                     break;                           case 'serial':  // Post Type named 'iti_cpt_3'                     $query->query_vars['posts_per_page'] = 6;                     break;                      default:                     break;             }             return $query;         }              if( !is_admin() )         {             add_filter( 'pre_get_posts', 'iti_custom_posts_per_page' );         }


title: How to let the users edit their user names?

text: Is there a way to let the users edit their usernames? Today, I googled for such a code for a while and had no luck finding a solution except a few plugins. I didn't find any tutorial for doing so. These are the plugins I found- Username changer and BuddyPress user name changer. The first plugin's interface is no good and I want to offer the users a native interface to edit user names. Brajesh's BuddyPress user name changer is similar to what I expected. But that works only if BuddyPress is setup. Could any suggest me a nice way to let the users edit their user names? Plugins would help me. But I can also manage to code if someone guide me through. **Update:** I am looking for a solution to edit the default **usernames** because sometimes, there would be a problem with the default user name appearing for the public. When you use Social Networks via OAuth(Twitter and Google etc.) for your member login , the user accounts will created with prefixes like _Yourfullname-Google_ or sometimes _Yourfullemailaddress-Google_. The author URLs appear like this- _site.com/author/twitter-random-name_ or _site.com/author/google-profile-address-uglyurl_. Here the user's profile URL appears ugly or lengthy and doesn't look in a normal way like-site.com/the- author-name Also I use a plugin named Quick Subscribe which helps us to get users subscribe and register account just using their email addresses creating random passwords. Here the problem is that the the user names will be created based on the email address(ex: userfullemailaddressgmail.com). The plugin is not popular as it has to be, but that helps people like me to let the users subscribe with single email address. The author URLs appear like this- _http://site.com/author/author-full-email- addressgmailcom_. The user's email address is blown out to the spammers. I can't resist using this subscribe plugin because of it's usability. In such cases I want to let users edit their user names to save themselves being their email addresses revealed to the public.


title: Multiple Stylesheets For Post and post type?

text: Hi i'm asking this question here because i don't know exactly how to put this into words on google lol. But I have a blog and i am using custom post type and each post type will have a different stylesheet. The Post types will all have the same way of displaying content but the homepage will be different. I realize that importing the header may be a problem. her are the examples. ![enter image description here](http://i.stack.imgur.com/W7Zx4.jpg) ![enter image description here](http://i.stack.imgur.com/iME0X.jpg) Notice the first photo is the index, the home page, the second photo is a custom post type page. On the home page there is no banner at the top but on the custom post type page it is. Is there an easier way for me to implement the header and different css styles so that i won't have to go in and rearrange all custom post type pages if i decide to make a change to the header of the site. Right now All i know is, taking the header and the index.php file putting them together in the custom post type template and creating it's own css template as well. Is there an easier way for me to have the "php get header" function and add the banner without having to go in each post type template to edit the header.


title: How should I structure my post types?

text: For the site I am making, I have a few post types: News, Events, Projects, Placements. Each one of these post types will need its own archive page, accessible through the navigation. I am able to create these post types using the Types plugin, but my question is how do I create a archive page for them? I can't figure out what the URL will be. `/projects` for the post type with slug `projects` gives me nothing. I think I understand how the templates for custom post types work (`archive-{post-slug}.php`), but I don't know how to make these pages accessible.


title: Get single image from custom fields made with WCK custom fields creator

text:
I used WCK Custom Fields Creator to create a repeatable custom field for uploading pairs of images (one color, one black and white) to posts. So for example, one post may have three fields, with two images (one color and one bw) each making a total of six images per post. I am trying to create a page that outputs the first field of two entries for every post in that specific category. Here is the code I have now, which spits out all of the image pairs. I dont know PHP well enough to figure out how to fix this code.
       <?php if ( have_posts() ) : while ( have_posts() ) : the_post();        $productimgs = get_post_meta( $post->ID, 'productimg', true );             if (is_array($productimgs) & $productimgs != '' ) {              foreach($productimgs as $productimg) {         $image_color = wp_get_attachment_image_src( $productimg['product-image-color'], 'grid-large' );         $image_bw = wp_get_attachment_image_src( $productimg['product-image-bw'], 'grid-large' );         echo '
';         echo '';         echo '';         echo '
';         }     }     ?>     <?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
     <?php endif; ?>
      I did a var_dump to see what the `$productimgs` variable outputs which I copied below:                   array(3) {      [0]=> array(2) {      ["product-image-bw"]=> string(3) "211"      ["product-image-color"]=> string(3) "212" }      [1]=> array(2) {      ["product-image-bw"]=> string(3) "214"      ["product-image-color"]=> string(3) "215" }      [2]=> array(2) {      ["product-image-bw"]=> string(3) "216"      ["product-image-color"]=> string(3) "217" }     }                array(2) {      [0]=> array(2) {          ["product-image-bw"]=> string(3) "253"          ["product-image-color"]=> string(3) "254" }     [1]=> array(2) {      ["product-image-bw"]=> string(3) "255"      ["product-image-color"]=> string(3) "256" } }           array(3) {      [0]=> array(2) {          ["product-image-bw"]=> string(3) "211"          ["product-image-color"]=> string(3) "212" }     [1]=> array(2) {          ["product-image-bw"]=> string(3) "214"          ["product-image-color"]=> string(3) "215" }      [2]=> array(2) {          ["product-image-bw"]=> string(3) "216"          ["product-image-color"]=> string(3) "217" } }


title: Insert a div class inside wordpress menu

text:
About Assetline
Products & Services

Commercial Credit

Portfolio Management

News & Events
      This is the menu structure what I want to integrate into wordpress . But there's an issue to add a div id ( ) inside of a menu . Any idea to achieve this ?


title: Wordpress show different custom post type

text: In wordpress I want two different types of custom post. In one section I want to post all the `latest news` and in other I want to use as `blog`. In `latest news` post type when I will make a news it should display in the news section and in blog section when I will add a blog it should show in blog section. So can someone kindly tell me how to do that? Kindly remember that I have two different types of styles in the two different custom post in fronted. So can someone kindly tell me how to do this? I am currently using wordpress twentytweleve theme. Any help and suggestions will be really appreciable.


title: How to create content automatically when a post is published?

text: **Goal:** Ability to automatically create content in WordPress posts/pages. **Goal Details:** When a post is created/published, it will automatically create or configure content based on the base data inputs of: Post Title, Category, Tag, Image File Name, Website Name, and or a "select" set of keywords or phrases and a standard set of generic content. **Image of Concpet** Automatic Post Creation Concept   **Question:**   1. Is there a plugin that will automatically create content "inside" the post editor?   2. Is there a coded solution that will automatically create content when a post is created? **Process Concept** : Below describes the steps & how I envision this process operarting:   1. An image will be added to a post via media library.   2. A title is added to post   3. A category is added to post   4. A tag is added to post.   5. Post is published.   6. **RESULT:** Automatically a set DISPLAY OF CONTENT will be displayed in the post. On the front end, the content will be displayed. Various labels will automatically display the various keywords based on the image name, post title, category, tag labels, thereby creating a unique post. The rest of the content will be standard. To help inspire thoughtful discussion & research, the ideas I came up with include the following. However, it still begs the question how in each case & what's the best method. **Possible Ideas/Solutions:**   1. Create a custom Field that automatically produces the content   2. Create a widget I can click on that will produce the content via short code. Then I I’ll be able to edit the customized set of content (Template 1 or Template 2, etc) from a different area.   3. Create ability to automatically import a bulk set of posts with content that will automatically adjust to a set of label/keyword identifiers.


title: Setting a default placeholder image WITHOUT link

text:
Can anyone help? I'm trying to show a default placeholder image on my posts when the user hasn't uploaded an image. I have the below code BUT i need to rewrite it so that the link isn't applied to the placeholder image - only the uploaded image. Unfortunately my PHP isn't great at all so would appreciate some help..
<a href="<?php the_permalink(); ?>">                <?php         // Must be inside a loop.              if ( has_post_thumbnail() ) {             the_post_thumbnail('size-2');         }         else {             echo '';         }         ?>


title: Redirect A URL Pattern In WordPress Using .htaccess

text: I am new to WordPress and just converted from Blogger to WordPress. Now as you know that Blogger URLs are too different from WordPress URLs so after migrating I started receiving 404 error in Google WebMaster as its still crawling my old links because I have about 10lac backlink according to Google Webmaster. So now Someone said to me to use .htaccess to make Google crawled 404 error URL to your new WordPress URLs so I moved on but when I saw that I have 900+ articles so it mean to loose precious time. Now I am thinking to use Pattern Redirect using .htaccess so that from one .htaccess rule I can handle my all URL and can able to remove 404 error from Google WebMaster. I want to redirect the below pattern so can you help me?   1. `/search/label/website` to `/category/website`   2. `/year/month/post-title.html/?m=0` to `/year/month/post-title.html`   3. `/year/month/post-title.html/?m=1` to `/year/month/post-title.html`   4. `/year/month/post-title.html?m=0` to `/year/month/post-title.html`   5. `/year/month/post-title.html?m=1` to `/year/month/post-title.html`   6. `/search` to `/` Please keep in mind that sometime there are variable in URL so we also want to avoid that that always start from `?variable=value&variable=value`.


title: Get content from WordPress posts in Boostrap modal window - Javascript side?

text:
I have a WordPress page with a grid that pull posts. Each post is in a box showing the title + thumbnail and upon clicking on it the content of the post should also appear in the modal (namely, pulling the data from the post which is clicked). I have been looking at this example: Open WordPress Posts in Bootstrap Modal and can get it working via data attributes, namely:
          <?php       $labels = new WP_Query(array(      'post_type' => 'x',       'posts_per_page' => 1000       ));        while ( $labels->have_posts() ) :        $labels->the_post();       ?>
            <?php echo '
';?>          <a href="<?php echo get_permalink(); ?>">       <?php the_post_thumbnail('');?>            **<button type="button" data-toggle="modal"        data-target="#myModal-<? the_ID(); ?>"><?php the_title();?></button>**
           <div id="myModal-<? the_ID(); ?>" class="modal hide fade"       tabindex="-1" role="dialog" aria-labelledby="myModalLabel"        aria-hidden="true">

           <?php the_title();?>

           <?php the_content();?>

         <?php the_post_thumbnail(); ?>

         <button type="button" class="close" data-dismiss="modal"         aria-hidden="true">×</button>

                <?php endwhile; ?>      <?php wp_reset_query(); ?>
      But unfortunately I just cannot get it working via Javascript. Would be great if anyone can help me with the code and how I can implement the dynamic feature in it? The following just doesnt work, if I have instead of the button:               <a href="#myModal-<? the_ID(); ?>" data-toggle="modal" id="clickme">       <?php the_title();?>           and then in the js file the following:                 **$(document).ready(function(){          $("#clickme").on        ("click", function(){ $("myModal-<?the_ID();>").modal();});        });**      Thank you SO much!


title: Output HTML only on individual post view

text: I am looking for a way to output some html (javascript actually) on a post view only and not on a main page, tag, category view (where WP outputs several posts). E.g it would be output on this page blog.yourdomain.com/2012/05/some-post/ But not on blog.yourdomain.com/ blog.yourdomain.com/category/xxx/ blog.yourdomain.com/tag/yyy/ etc. **The HTML to be output is different for each post**


title: Woocommerce - Add a product to cart programmatically via JS or PHP

text: I am using the Woocommerce plugin to facilitate a small e-commerce part of a site and need to add products to it's cart via some call or function rather than using it's own 'add-to-cart' buttons. By this I basically mean send Woocommerce a SKU and quantity for example and have the cart update.               sendToCart('123456', 55);      etc I've looked through the documentation and can't seem to find a reference to this sort of thing. Can anyone suggest how I might achieve this?


title: How to place HTML tags in content from the_content()?

text: Firstly, I am new to Wordpress so thank you for your patience. I have a list of posts (with excerpts) being displayed in the page using Short Tags. The output is fine , However, I wish to add and change some tags which is coming as a content from the_content as I see under page.php file of my theme files. Any direction / guidance is greatly appreciated. Many thanks.


title: Custom Post Type, WP_Query and 'orderby'

text: I do have a custom post type with the following setup:               $supports = array(         'title'         , 'editor'         , 'thumbnail'         , 'revisions'         , 'page-attributes'     );          $args = array(       'hierarchical' => true       , 'supports' => $supports       [...]     );          register_post_type('myType', $args);      I would like to show all posts and have them sorted like in the wp-admin area (indention is for readability):               1,      2,      3,         1, (parent 3)        2, (parent 3)     4      Therefore I tried the following query with the order-type set to 'menu_order':               $loop = new WP_Query( array(            'post_type' => 'myType'          , 'posts_per_page' => 50          , 'orderby' => 'menu_order'          , 'order' => 'ASC'     ));      Unfortunately all post are sorted by `menu_order`, but by `menu_order` exclusively, ignoring the parent relationship (`post_parent` attribute). So I get something like this               1,     1, (parent 3)     2,      2, (parent 3)     3,     4      Changing the query to `'orderby' => 'parent menu_order'` leads to the following               1,     2,      3,     4     1, (parent 3)     2, (parent 3)      So all in all it looks to me, as everything works as designed and the orderby- value is directly translated to the corresponding SQL 'Order By'. ### Question What is the easiest way to get the desired order? ### SQL I assume this is the main sql-query wordpress creates:               SELECT SQL_CALC_FOUND_ROWS wp_2_posts.ID      FROM wp_2_posts      WHERE 1=1 AND wp_2_posts.post_type = 'inhalt' AND (wp_2_posts.post_status = 'publish' OR wp_2_posts.post_status = 'private')      ORDER BY wp_2_posts.post_parent, wp_2_posts.menu_order ASC LIMIT 0, 50      which is then followed up with:               SELECT wp_2_posts.*      FROM wp_2_posts      WHERE ID IN (40,42,44,46,48,50,52,54,56,58,60,76,62,65,69,71,74)          SELECT post_id, meta_key, meta_value      FROM wp_2_postmeta      WHERE post_id IN (40,42,44,46,48,50,52,54,56,58,60,62,65,74,69,71,76)      ### Workaround A known workaround, but not an answer is to give all posts higher and more "spaced" order values, like               100,     200,      300,        310,        320,     400


title: SQL update post category by post starting letter

text: I need to update post category based on post first letter.   E.g. all post starting with "A" should go into "A" category. so far i can only select posts starting with "A".               SELECT * FROM wp_posts     LEFT JOIN wp_term_relationships ON     (wp_posts.ID = wp_term_relationships.object_id)     LEFT JOIN wp_term_taxonomy ON     (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)     WHERE wp_posts.post_status = 'publish'      AND wp_posts.post_title  LIKE 'A%'     AND wp_term_taxonomy.taxonomy = 'category'     AND wp_term_taxonomy.term_id = 1     ORDER BY post_date DESC        Any ideas?


title: Update Post Taxonomy Automatically Based On Date

text: I am using the below function to set a custom post type taxonomy to a certain term based on the current date. This is for an event that lists upcoming, ongoing, and future events at a venue. I need the taxonomy term to automatically update based on the current date. Right now, this function only works if I go into the post and click update so that the function runs on save_post. Someone else mentioned I need to use javascript for this, but I'm dumb when it comes to js. Here is the function:               //Set post_status based on the current date     function set_event_status($post_ID) {         $start = strtotime(get_field('start_date'));          $end = strtotime(get_field('end_date'));         $now = strtotime('now - 7 hours');         if ($start && $end) {             if (($start <= $now) && ($end >= $now)) {                 $status = 'playing_now';             } elseif ($start >= $now) {                  $status = 'opening_soon';             } elseif ($end < $now) {                 $status = 'closed';             }         } elseif ($start) {             if ($start <= $now) {                 $status = 'closed';             } elseif ($start >= $now) {                 $status = 'opening_soon';             } elseif ($start == $now) {                 $status = 'playing_now';             }         } else {             $status = 'closed';         }         wp_set_post_terms( $post_ID, $status, 'event_status' );         return $post_ID;     }     add_action( 'save_post', 'set_event_status' );


title: background images WP Supersized on homepage

text: I'm using the WP Supersized plugin to load background images on posts and works fine. The problem I have at this point is I want to show the latest post in cat 17, with custom field key FeaturedOnHomepage, with value yes on my homepage and display the background images from that post. Below the query I use:                       <?php query_posts('cat=17&posts_per_page=1&meta_key=FeaturedOnHomepage&meta_value=yes'); ?>             <?php if (have_posts()) : ?>             <?php while (have_posts()) : the_post(); ?>                 <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?>                <?php endwhile; ?>                 <?php else : ?>                 <?php endif; ?>      Somehow WP Supersized is getting confused and is showing the default image folder (like all images in the Media Library. Do I need to include code to make this work?


title: Unique Post Meta Values

text: I want to use Unique IDs like YouTube video IDs and WordPress post IDs in a custom field 'youtube_id'. I just created a front-end add post page and want to check if 'youtube_id' used or not used in a older post.                   $title = 'blah blah blah';         $different=mysql_query("SELECT post_title FROM wp_posts WHERE post_title='$title'");         if(mysql_num_rows($different)>0) {         echo 'Dude, we already have this post.';         }      this code looks for post title is unique or not. I need something similar with this. But I need to use postmeta, not post_title. Any idea to check it with WordPress functions or mysql? PS: Sorry for my poor English.


title: How does WordPress know if a URL doesn't exist?

text: The WordPress theme I am using didn't come with a proper Error 404 handler and I'd like to add one to the code. I am having a hard time how WordPress determines if a URL does exist as a post, is a search query, or doesn't exist. I'd like to know where the code WordPress uses is located, or how WordPress determines this as I need to implicate it in the theme files.


title: Pagination for custom post types

text: Hi I have a custom post type and its posts are called via a shortcode on any other post or page. I'd like to paginate this post type, say display 10 items. So the page in the URL remains the same, but the content inside (via shortcode) changes when I go to the 2nd page from the pagination buttons. How do I do this?


title: Creating Tables in WordPress Database

text: I'm planning to make a database for my wordpress website. It is to store (and retrieve) information about the products the members want to sell. As far as i understand, i have to make the tables in wp database self. ( I'd used this source ) But i'm new in php and wp and i don't know how i can create tables in wp_database. Thanks a lot!


title: Upgrade wordpress core programmatically with PHP

text: **What I want to do** I want to upgrade Wordpress programmatically to a later version. That I want to do with PHP, lets say from http://www.example.com/?upgrade_wp=true I already know how to get the URL of the latest version so I don't having any problem with checking for versions or finding the right URL. **Answers I want**   * A link to a tutorial of how this is done.   * A plugin that does this and not so much more.   * A hint to the functions that I need to use. **Answers I don't want**   * The way to do it with SVN or subversion.   * Answers containing Wordpress MU.   * How to manually doing this.   * How to do this with other code than PHP.


title: Allow Google crawler to crawl specific Author pages

text: I have a WordPress website with thousands of registered users. For each user a profile page is created. Most of these pages are low quality because most users do not fill their profile with information, therefore, I don't want search engines indexing these pages. However, some Author pages are high quality. At the moment I'm using WordPress SEO plugin to add a noindex metatag in Author pages, I know I could also block the `/Author/` directory in robots.txt. But the thing is, I want to allow crawlers to crawl those specific high quality Author pages. Any ideas?


title: How to reset a custom theme

text: After making a lot of little changes to the current custom theme [zeeBizzCard] I'm using, I want to reset it back to it's original style. Being new to WP, I didn't make a backup of the default theme and can not find a quick and easy method of reseting the theme. Have I missed something, or is there no "reset" options for downloaded themes? Thanks


title: Help sorting by Meta Key value

text: using this https://github.com/growthspark/wp-advanced-search I am not sure how to sort by meta_key value. I currently have a meta key called "Due Date" with the date entered like 06/06/2012 (M/D/Y). The search framework is nothing special, as it is simply php and wordpress codex standards so I hope someone can help. I have something like this                              $args['fields'][] = array('type' => 'meta_key',                                             label' => 'Test',                                             'meta_key' => '',                                             'format' => 'select',                                             'values' => array());      but it is not right. Any ideas?


title: setting comments off as default for pages and custom post types?

text: I want to turn the comments off by default with pages and custom post-types Initially I simply used conditionals in the comments display function to avoid displaying the block on these pages, but I need the user to be able to turn the comments back on as required.


title: How to make get_template_part always check child theme first?

text: How can I force WP to always check the child theme folder first when running `get_template_part`? Example: child theme loads `get_template_part('content', 'inventory')` in `single.php`. Because all child themes (and there are a lot) share the same common inventory template base, the file `content-inventory.php` is in the parent theme. So far so good. I would like to add a small section to said inventory template that will be unique to each child theme. Adding `get_template_part('content', 'inventory- special')` into `content-inventory.php` will not check the child theme directory first.


title: Function to check whether the user is at the top level of the network?

text: I need a conditional to check to whether or not to execute code at the top level of network admin pages: `/wp-admin/network`


title: Switch Categories on a Specific Date?

text: I usually like to provide a code I've started with and have others help me out with it - but this is one where I don't even know where to begin. I would like to be able to set a date on posts in which the selected post will automatically be moved to another category. Has anybody attempted this?