title: WPAlchemy issue when using 2 select menus with the same values inside a repeating group

text:
I'm using v1.4.14 of the WPAlchemy MetaBox PHP Class. I have 2 select menus within a repeating group, `available_from` and `available_to`. If I select Monday in the first select menu, Wednesday in the 2nd, and then save the post, the 2nd select menu's value changes to the first. So both become Monday. The initial values however are stored correctly in the DB upon the first save (Monday and Wednesday), but if you update the post again, they would be changed to Monday and Monday. This happens when any day combination, but if I use the exact code below outside of the repeating group, it works as expected. I'm hoping someone has encountered this before and knows how to fix it. Really need the repeating group.               <?php while($mb->have_fields_and_multi('availability')): ?>     <?php $mb->the_group_open(); ?>          Day (from)     <?php $mb->the_field('available_from'); ?>     <select name="<?php $mb->the_name(); ?>" id="<?php $mb->the_name(); ?>">         <option value="">Select Day</option>         <option value="Monday"<?php $mb->the_select_state('Monday'); ?>>Monday</option>                      <option value="Tuesday"<?php $mb->the_select_state('Tuesday'); ?>>Tuesday</option>         <option value="Wednesday"<?php $mb->the_select_state('Wednesday'); ?>>Wednesday</option>         <option value="Thursday"<?php $mb->the_select_state('Thursday'); ?>>Thursday</option>         <option value="Friday"<?php $mb->the_select_state('Friday'); ?>>Friday</option>         <option value="Saturday"<?php $mb->the_select_state('Saturday'); ?>>Saturday</option>         <option value="Sunday"<?php $mb->the_select_state('Sunday'); ?>>Sunday</option>     </select>               Day (to)     <?php $mb->the_field('available_to'); ?>     <select name="<?php $mb->the_name(); ?>" id="<?php $mb->the_name(); ?>">     <option value="">Select Day</option>     <option value="Monday"<?php $mb->the_select_state('Monday'); ?>>Monday</option>                  <option value="Tuesday"<?php $mb->the_select_state('Tuesday'); ?>>Tuesday</option>     <option value="Wednesday"<?php $mb->the_select_state('Wednesday'); ?>>Wednesday</option>     <option value="Thursday"<?php $mb->the_select_state('Thursday'); ?>>Thursday</option>     <option value="Friday"<?php $mb->the_select_state('Friday'); ?>>Friday</option>     <option value="Saturday"<?php $mb->the_select_state('Saturday'); ?>>Saturday</option>     <option value="Sunday"<?php $mb->the_select_state('Sunday'); ?>>Sunday</option>     </select>
         Remove
          <?php $mb->the_group_close(); ?>     <?php endwhile; ?>          Add new day range


title: if statement in sidebar.php checking page id or template or title

text:
I have the following code in my sidebar.php file:
              <?php             $lastposts = get_posts('numberposts=5&orderby=date&cat=-52');             foreach($lastposts as $post) :             setup_postdata($post);              $page_name = $wp_query->post->post_name;                  if (is_page_template('news-page.php')) { ?>
yes!
              <?php } else { ?>             <li<?php if ( $post->ID == $wp_query->post->ID ) {             echo ' class="current"'; } else {} ?>>                 <a href="<?php the_permalink() ?>"><?php the_title(); ?>
                       <?php }  ?>         <?php endforeach; ?>
      The aim is that if the sidebar appears in any page except the template `news- page.php`, it executes the code listing all posts within the category. If not, it prints `<p>yes!</p>` (this code will change - it's just a placeholder atm). To be honest, I'm not married to the `is_page_template`, but I've tried `is_page`, `the_title` and `wp_title`, none of which seem to output `<p>yes</p>`. Am I going about this the wrong way? Is it not working because it's looking for the page template within the sidebar.php? I'm pretty new to WP, so specific advice is much appreciated! MTIA. * * * EDIT: Ok, this is really weird. I added 'get_page_template' to my code so I could see exactly which template it's using and it's _not_ using news-page.php even though I've specified this in the admin area. I've created a new page and have also used news-page.php as the template. Again, when I view the page it does _not_ use news-page.php as the template. In both these instances, the template that is being used is 'todaysmenu- page.php'. I have checked in both files that the correct template name is specified. They are:               <?php     /*     Template Name: Todays menu page     */     ?>      and               <?php     /*     Template Name: News page     */     ?>      Have I completely missed something? Do I need to flush a db or something? * * * EDIT no. 2: So the page _is definitely_ using news-page.php, however, the sidebar.php is still outputting that the template being used is todaysmenu-page.php. So why the heck isn't `is_page_template` spitting out the correct template? * * * EDIT no. 3: Answer: I put the `query_posts` in the wrong place. Not working code:               <?php get_header(); ?>                <?php              query_posts('cat=4');              if (have_posts()) : while (have_posts()) : the_post();           ?>

<?php get_sidebar(); ?>

News

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

                <?php the_excerpt(); ?>                <?php wp_link_pages(array('before' => 'Pages: ', 'next_or_number' => 'number')); ?>

           <?php endwhile; endif; ?>

     <?php get_footer(); ?>      Working code:               <?php get_header(); ?>

<?php get_sidebar(); ?>

News
                 <?php              query_posts('cat=4');              if (have_posts()) : while (have_posts()) : the_post();           ?>

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

                <?php the_excerpt(); ?>                <?php wp_link_pages(array('before' => 'Pages: ', 'next_or_number' => 'number')); ?>

           <?php endwhile; endif; ?>

     <?php get_footer(); ?>      Thanks all for your suggestions and comments!


title: Unable to save Theme Options when TinyMCE is enabled for the text area

text:
On the site I'm currently developing I have created a theme options page (under Appearance). All there is on this page is a text area so the client can add some summary text to appear above their posts. I am using TinyMCE on this textarea so they can format their text, but if I have TinyMCE enabled the 'Save Options' button doesn't do anything upon clicking it. If I comment out the following lines in my theme-options file to disable TinyMCE, then it saves correctly.               <?php         wp_tiny_mce( false , // true makes the editor "teeny"             array(                 "editor_selector" => "large-text"             )         );     ?>      _Note:_ The TinyMCE loads and displays correctly - text can be formatted, just not saved. Any idea what could be causing this? I am using WordPress 3.2. **Thanks!** **Edit:** The entire code in my _theme-options.php_ file is as follows               <?php          add_action( 'admin_init', 'theme_options_init' );     add_action( 'admin_menu', 'theme_options_add_page' );          /**      * Init plugin options to white list our options      */     function theme_options_init(){         register_setting( 'client_options', 'client_theme_options', 'theme_options_validate' );     }          /**      * Load up the menu page      */     function theme_options_add_page() {         add_theme_page( __( 'Intro/Welcome Text', 'client' ), __( 'Intro/Welcome Text', 'client' ), 'edit_theme_options', 'theme_options', 'theme_options_do_page' );     }               /**      * Create the options page      */     function theme_options_do_page() {         global $select_options, $radio_options;              if ( ! isset( $_REQUEST['settings-updated'] ) )             $_REQUEST['settings-updated'] = false;              ?>
             <?php screen_icon(); echo "
" . __( ' Intro/Welcome Text', 'client' ) . "
"; ?>                  <?php if ( false !== $_REQUEST['settings-updated'] ) : ?>

<?php _e( 'Options saved', 'client' ); ?>

             <?php endif; ?>                  <form method="post" action="options.php">                 <?php settings_fields( 'client_options' ); ?>                 <?php $options = get_option( 'client_theme_options' ); ?>                 <?php                 wp_tiny_mce( true , // true makes the editor "teeny"                     array(                         "editor_selector" => "large-text"                     )                 );                 ?>
                          <?php                     /**                      * A sample textarea option                      */                     ?>
<?php _e( 'Intro/Welcome Text' ); ?>	                                                      <textarea id="client_theme_options[intro_content]" class="large-text" cols="50" rows="10" name="client_theme_options[intro_content]"><?php echo esc_textarea( $options['intro_content'] ); ?></textarea>                             <?php _e( 'Enter content here to be displayed above the Posts.', 'client' ); ?>

                     <input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'client' ); ?>" />
             </form>
         <?php     }          /**      * Sanitize and validate input. Accepts an array, return a sanitized array.      */     function theme_options_validate( $input ) {         global $select_options, $radio_options;              // Our checkbox value is either 0 or 1         if ( ! isset( $input['option1'] ) )             $input['option1'] = null;         $input['option1'] = ( $input['option1'] == 1 ? 1 : 0 );              // Say our text option must be safe text with no HTML tags         $input['sometext'] = wp_filter_nohtml_kses( $input['sometext'] );              // Our select option must actually be in our array of select options         if ( ! array_key_exists( $input['selectinput'], $select_options ) )             $input['selectinput'] = null;              // Our radio option must actually be in our array of radio options         if ( ! isset( $input['radioinput'] ) )             $input['radioinput'] = null;         if ( ! array_key_exists( $input['radioinput'], $radio_options ) )             $input['radioinput'] = null;              // Say our textarea option must be safe text with the allowed tags for posts         $input['sometextarea'] = wp_filter_post_kses( $input['sometextarea'] );              return $input;     }          // adapted from http://planetozh.com/blog/2009/05/handling-plugins-options-in-wordpress-28-with-register_setting/


title: How to rewrite CPT-Permalinks the correct way (incorporating meta-box-data)?

text: Using the below hooks, I tried to rewrite the permalinks of my custom post type `magazine_issue` to be made of values of additional meta-fields I added to the edit screen. The problem with my actual code is that it seems to register URLs of all found custom posts in the desired way but unfortunately, when requesting those pages, it will only return the latest generic post ("Hello World") troughout. How can I fix this?               function magazine_issues_rewrite() {       global $wp_rewrite;       $queryarg = 'post_type=magazine_issue&p=';       $wp_rewrite->add_rewrite_tag('%issuenumber%', '([^/]+)', $queryarg);       $wp_rewrite->add_rewrite_tag('%issueyear%', '([^/]+)', $queryarg);       $wp_rewrite->add_permastruct('issue_url_by_meta', '/'.__('issues', 'doev').'/%issueyear%/%issuenumber%/', false);     }     add_action('init', 'magazine_issues_rewrite');          function magazine_issues_permalink($post_link, $id = 0, $leavename) {         global $wp_rewrite;         $post = &get_post($id);         if (is_wp_error($post)) return $post;              if ('magazine_issue'==get_post_type($post)) {             $newlink = $wp_rewrite->get_extra_permastruct('issue_url_by_meta');             $newlink = str_replace("%issuenumber%", get_post_meta($post->ID,'issuenumber',true), $newlink);              $newlink = str_replace("%issueyear%", get_the_date('Y'), $newlink);             $newlink = home_url(user_trailingslashit($newlink));             return $newlink;         }     }     add_filter('post_type_link', 'magazine_issues_permalink', 1, 3);


title: I copied my site to another site but all links point to old site

text: I copied my site: www.old_site.com to a new address: www.new_site.com All links in new_site point to the old site. What do I have to change so that new site points to new site? Thank you.


title: Remove Certain Fields From Review Form?

text: I'm using a plugin called WP Customer Reviews and I want to remove some fields that are currently required to fill in. How can I remove certain fields from the review form. I'd like to remove the name field and the check this box to confirm you are human field. Anyone know how I can do this? I've already asked this question on WP Customer Reviews forum but had no reply.


title: User driven content problems

text: I am trying to build a website that will allow users to post from the front end. I need to be able to have the user enter a title, a category, and tags. For the content of the post, I would ideally have the WordPress TinyMCE from the backend on this page, with the add media button included. I have stripped out the features of the TinyMCE that I don't want users to have access to, such as justify text, h1, indent, outdent, etc. I use jetpack to allow for oEmbeds, but I want to just give users instructions for how to use the form and let them handle it. They can have the text, images, and embedded video/audio arranged in whatever order they like if they are submitting content through a TinyMCE. It's kind of like what Kickstarter has for submitting a project. With that said, I can add a TinyMCE to a page, using the following PHP in my page template:               <?php         wp_editor($mytext_var,"mytext", array('textarea_rows'=>12, 'editor_class'=>'mytext_class'));     ?>      I can control what appears in theTinyMCE's toolbar with this code in my functions template:               // TinyMCE: First line toolbar customizations     if( !function_exists('base_extended_editor_mce_buttons') ){         function base_extended_editor_mce_buttons($buttons) {             // The settings are returned in this array. Customize to suite your needs.             return array(             'formatselect', 'bold', 'italic', 'sub', 'sup'         );         /* WordPress Default         return array(             'bold', 'italic', 'strikethrough', 'separator',              'bullist', 'numlist', 'blockquote', 'separator',              'justifyleft', 'justifycenter', 'justifyright', 'separator',              'link', 'unlink', 'wp_more', 'separator',              'spellchecker', 'fullscreen', 'wp_adv'         ); */     }     add_filter("mce_buttons", "base_extended_editor_mce_buttons", 0);     }          // TinyMCE: Second line toolbar customizations     if( !function_exists('base_extended_editor_mce_buttons_2') ){     function base_extended_editor_mce_buttons_2($buttons) {         // The settings are returned in this array. Customize to suite your needs. An empty array is used here because I remove the second row of icons.         return array(             'bullist', 'numlist', 'link', 'unlink', 'blockquote', 'removeformat', 'undo', 'redo'         );         /* WordPress Default         return array(             'formatselect', 'underline', 'justifyfull', 'forecolor', 'separator',              'pastetext', 'pasteword', 'removeformat', 'separator',              'media', 'charmap', 'separator',              'outdent', 'indent', 'separator',              'undo', 'redo', 'wp_help'         ); */     }     add_filter("mce_buttons_2", "base_extended_editor_mce_buttons_2", 0);     }          // Customize the format dropdown items     if( !function_exists('base_custom_mce_format') ){     function base_custom_mce_format($init) {         // Add block format elements you want to show in dropdown         $init['theme_advanced_blockformats'] = 'p,h3';         // Add elements not included in standard tinyMCE dropdown p,h1,h2,h3,h4,h5,h6         //$init['extended_valid_elements'] = 'code[*]';         return $init;     }     add_filter('tiny_mce_before_init', 'base_custom_mce_format' );     }      My problem is that I don't know how to make a form that will allow me to incorporate the TinyMCE into a form that will generate a post on my site that is posted under a custom post type when the user clicks the Submit button. I know how to make HTML forms, but I don't know how to make PHP forms, nor do I know how to make the TinyMCE take its raw HTML output and post that to the PHP form. If anyone can help me, I'd greatly appreciate it. and for those who desire, use the code snippets on client sites of your own you have any need to limit what the TinyMCE will allow you to do. I use that for clients all the time so that they can't do something like throw crazy rainbow colored paragraphs into the mix, or mess up their own SEO by using an H1 tag.


title: not able to add thumbnail custom field in dropdown

text: I am using custom fields. Whatever we define in "add new custom field" shows up in the dropdown on refreshing, but for some reason the thumbnail word doesn't add up in dropdown. Can I manually edit and add custom fields dropdown menus somewhere?


title: How to get a page array and category array going at the same time?

text:
I'm using the code below to add a logo in the header of certain pages and I'm wodering if there a way to add the logo(sublogo.jpg) to certain categories as well as "page-one", "page-two" and so on?                   <div id="header-logo" onclick="location.href='<?php bloginfo('url'); ?>'" style="cursor: pointer;" >         <?php if (is_page(array('page-one', 'page-two', 'page-three','page-four'))) $logo_image = 'subLogo.jpg';         else $logo_image = 'mainLogo.jpg';?>         <img src="<?php bloginfo('stylesheet_directory'); ?>/images/<?php echo $logo_image;?>" alt="<?php bloginfo('name'); ?>" />
      Thanks,


title: strip last comma from get_the_category

text: foreach((get_the_category()) as $category) {                                                     echo $category->cat_name . ', ';                                                   }      So I'm echoing it like this because I don't want the categories to appear as hyperlinks, I just want the cat names. The problem is I can't get rid of the last separator so it ends up like : category, category, category, I tried 'stripping' it (php seriously confuses me small design mind)                                                           foreach((get_the_category()) as $category) {                                                     echo $category->cat_name . ', ';                                                     echo rtrim($category, ", ");                                              }      That didn't trim it though.


title: How do I add a Custom Post Type that looks and behaves exactly the same as Posts?

text: I'd like to add a custom post type "News" that has it's own Tags and Categories and I'd like to add the appropriate code to my functions.php file. I've tried plugins but I don't get tags and categories columns in the list of posts in the new post type. Thanks


title: Advanced custom fields - If/ while field problem

text:
The way I am trying to set this up is that if a link has not been chosen then only the image will be displayed, but if a link is chosen as well as an image then I want the link to be wrapped around the image, here is an example of what I have at the moment:               <?php if(get_field('block_repeater')): ?>
                   <?php while(has_sub_field('block_repeater')): ?>
                                   <?php if( get_sub_field('block_link') ): ?>                           <?php while(has_sub_field('block_image')): ?>                         <a class="img" href="<?php the_sub_field('block_link'); ?>">                              <img src="<?php the_sub_field('block_image'); ?>" alt="" />                                                                              <?php endwhile; ?>                       <?php endif; ?>                                        <?php if( get_sub_field('block_image') ): ?>                      <img src="<?php the_sub_field('block_image'); ?>" alt="" />                  <?php endif; ?>
              <?php endwhile; ?>
     <?php endif; ?>      The does not seem to be working correctly though as its rendering out about a hundred of these:                                    Don't suppose anyone knows what I have done wrong please?


title: Wordpress Search on Multiple wp sites

text: I want to search different wordpress installations on the same domain al at once. Whe have some wp installations running different shops. I want users to search in shop One and find also results from shop2 and shop3 and so on. Anyone have some ideas on how to do that what code do i need to let wordpress search in all the databases. Kind regards Rene


title: Step by Step Instructions for Making Media/Uploads Private to Only Logged-In Users

text: all. I found this site via a Google search that led me to this topic: How to Protect Uploads, if User is not Logged In? It looks like that solution would work for my situation (including hakre's addition). However, I am struggling to find exactly how I would go about putting all of it together and implementing it on my WP site. So, I was wondering if anybody would be..."interested"... in putting together a step-by-step guide on how to implement that solution. For some background...   * My site is using the Members plugin (http://wordpress.org/plugins/members/) with OneAll Social Login (http://wordpress.org/plugins/oa-social-login/).   * Anyone can register on my site. However, they are initially registered in a restricted "role" via the Members plugin where they can only view one page. If they attempt to view any other page, they are redirected back to that one page. I then have the ability to review the registrant and move them to an "authorized" role, giving them access to the site.   * In an ideal world, I'd like to restrict all media to people in the "authorized" role. However, at this point, I'd settle for just requiring people to be registered/logged-in.   * My WP site just contains info about my family that I want to keep private. Photos are a big part of it, which is why I want to keep them private, just like my posts.   * The creator of the Members plugin said he may be interested in building this functionality into his plugin in the future, but I'd rather not wait for that. Thank you!!


title: Do we have to register JQuery if we want to use it in wp_enqueue_script()?

text: Or is it registered by default?   I am enqueuing a script with wp_enqueue_script()               wp_enqueue_script('validation', 'http://domain.com/wordpress/wp-content/themes/theme/js/validation.js', array('jquery'));      But I get this error in the console:   > `Uncaught TypeError: Property '$' of object [object Object] is not a > function` Also do I need to put the absolute path to link my js, or can I use a relative path? Relative to what?


title: WPDB SQL query with prepare() returning variable, not db value

text: I have been trying to get this to work for awhile now and I cannot seem to get any farther on my own. It seems to work fine as a normal SQL query but not within the WP framework using prepare(). Basically I am trying to insert a PHP variable within the SQL query but instead of returning the value I SELECTed, the function returns the value of the variable. I have searched for others having the same problem but most of them are dealing with problems with LIKE and the % wildcard. I cannot figure out what my problem is. I am using a bbPress variable which is the forum id. Any help would be appreciated.               global $wpdb;     $countquery = $wpdb->get_var($wpdb->prepare(     "SELECT meta_value FROM $wpdb->postmeta      WHERE meta_key = '_bbp_forum_subforum_count'      AND post_id=%d", bbp_forum_id()));     echo $countquery;


title: How to know if user choose to show full post or excerpt?

text: I've seen there is a setting to choose whether to see full posts or excerpts on feed. However I'm using a theme that doesn't seem to support this functionality (it always show the full post). For this reason I created a child theme and would like to know what function to use to check what the user chose from preferences. e.g:               <?php if ( did_the_user_choose_excerpts() ) : ?>     <div class="entry-summary">         <?php the_excerpt(); ?>     </div><!-- .entry-summary -->     <?php else : ?>         // Full post      How do I check if the user chose to see excerpts?


title: How to display code if it is not certain pages?

text: Im trying to set up an if statement to display certain code, if the user is on a certain page. I've got the links and student work pages to work, but when I add the if not link and not student work I get an unexpected T_BOOLEAN_AND error. How can I fix this so I can list the pages I don't want custom code for and use just page.php               <?php                  if (!is_page('links')) && (!is_page('student-work'))  {                     include(TEMPLATEPATH . '/pages/page.php');                 } elseif (is_page('links')) {                     query_posts('cat=2');                     include(TEMPLATEPATH . '/pages/links.php');                 } elseif (is_page('student-work')) {                     query_posts('cat=4');                     include(TEMPLATEPATH . '/pages/student-work.php');                 }     ?>


title: Get custom field values into the sidebar/widget?

text: I haven't seen this done, but I want to return the custom field values outside of the loop in the sidebar.


title: Plugin, add settings element

text: I'm new to WordPress and probably similar question already exist, but as far as I didn't find I make a new one. So I'm trying to make my first plugin in wordpress. I got to make plugin settings page and the settings I need.   * Input to set interval   * Text response for the interval My problem is I need to create many elements (boxes) which would require to write the same type of settings, but with different values. What I would like to do is lets say add a "+" button which would make me an element which would require me to add all the following settings information. Because I need client to set many intervals as the input will be validated by them. How could I achieve what I want?


title: How to Create a Cookieless Domain in Wordpress

text: How do you create a 'cookieless' domain for WordPress?


title: Test if post has a category

text: I need to display some HTML only if the post being displayed has a category - not a specific category, just any category at all. I tried `if (!is_empty(get_the_category($post->ID)))`, but for some reason this isn't working. Has anone else had the same issue?


title: Unable to display paging navigation with a custom post type loop

text:
I have used a starter pack for my WordPress theme development, but I can't display the navigation on a custom post type loop. The framework starter is : http://underscores.me/ There is my PHP Code into my template file to loop into the files               <?php                 wp_reset_postdata();                        $args = array(                       'post_type' => 'testimonial',                       'order' => 'ASC',                       'orderby' => 'menu_order',                       'posts_per_page' => 2,                       'paged' => get_query_var('paged') ? get_query_var('paged') : 1                       );                        // The Query                 $wp_testimonials = new WP_Query();                 $wp_testimonials->query($args);                        // The Loop                   while ( $wp_testimonials->have_posts() ) : $wp_testimonials->the_post();                      ?>                         <div  id="page-<?php the_ID(); ?>" <?php post_class('list-sub-page'); ?>>

<?php the_title(); ?>

                                     <?php the_content(); ?>
                                      <?php                                 if ( has_post_thumbnail() )                                  {                                 the_post_thumbnail('testimonial');                             }                             ?>

                              <?php                        endwhile;                          ?>
                     <?php                     miller_paging_nav();                     ?>
                          <?php                             // Reset Query                   wp_reset_postdata();                      ?>      And you can see for the function miller_paging_nav(); is generated by the framework and the function looks like this.               if ( ! function_exists( 'miller_paging_nav' ) ) :     /**      * Display navigation to next/previous set of posts when applicable.      */     function miller_paging_nav() {         // Don't print empty markup if there's only one page.         if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {             return;         }         ?>
<?php _e( 'Posts navigation', 'miller' ); ?>

                      <?php if ( get_next_posts_link() ) : ?>
<?php next_posts_link( __( '← Older posts', 'miller' ) ); ?>
                 <?php endif; ?>                      <?php if ( get_previous_posts_link() ) : ?>
<?php previous_posts_link( __( 'Newer posts →', 'miller' ) ); ?>
                 <?php endif; ?>
                  <?php     }     endif;      I have about 6 or 7 testimonials in my custom post type but the pagination just never shows. Any one could help me? -- **EDIT** I used the documentation of an other post on this website and the pagination shows but I think I might have a rewrite rule problem. My page : http://vincent.okidoomedia.com/miller/patient/testimonials/ The documentation : Pagination custom query If you try to click on the #2 or #3 on my page, it always return to the main page. If I change the permalink to default, it will works. Any ideas?


title: Show post categories names using apply_filters

text:
I'm trying to change a plugin for each post show his categories names. The plugin use `apply_filters` to show post name. But how can I show categories names?               $output .= $indent . '
ID.'">       '.apply_filters( 'the_title', $page->post_title, $page->ID ).'';


title: How to create a permalink for custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name

text: I found this link too much helpful. This is what I code so far and got it working for all scenarios except two scenarios.               register_post_type( 'article',         array(             'labels' => array(                 'name' => 'Article',                 'singular_name' => 'Article',                 'add_new' => 'Add Article',                 'add_new_item' => 'Add New Article',                 'edit' => 'Edit',                 'edit_item' => 'Edit Article',                 'new_item' => 'New Article',                 'view' => 'View',                 'view_item' => 'View Article',                 'search_items' => 'Search Article',                 'not_found' => 'No Article',                 'not_found_in_trash' => 'No Post found in Article',                 'parent' => 'Parent Article'             ),                  'public' => true,             'hierarchical' => true,             'menu_position' => 15,             'supports' => array( 'title', 'editor', 'comments', 'thumbnail' ),             'taxonomies' => array( '' ),             'menu_icon' => get_template_directory_uri().'/img/icon_article.png',             'query_var' => true,             'rewrite' => array(                 'slug' => 'articles/%article_category%',                 'with_front' => true             ),             'has_archive' => 'articles',             'register_meta_box_cb' => 'add_article_metaboxes'         )     );                    register_taxonomy('article_category','article',array(         'hierarchical' => true,         'labels' => $labels,         'query_var' => true,         'rewrite' => array('slug' => 'articles', 'hierarchical' => true),       ));          add_filter('rewrite_rules_array', 'mmp_rewrite_rules');     function mmp_rewrite_rules($rules) {         $newRules  = array();         $newRules['articles/(.+)/(.+)/(.+)/?$'] = 'index.php?article=$matches[3]';          $newRules['articles/(.+)/(.+)/?$'] = 'index.php?article=$matches[2]';         $newRules['articles/(.+)/?$'] = 'index.php?article_category=$matches[1]';               return array_merge($newRules, $rules);     }          function filter_post_type_link($link, $post)     {         if ($post->post_type != 'article')             return $link;              if ($cats = get_the_terms($post->ID, 'article_category'))         {             $link = str_replace('%article_category%', get_taxonomy_parents(array_pop($cats)->term_id, 'article_category', false, '/', true), $link); // see custom function defined below         }         return $link;     }     add_filter('post_type_link', 'filter_post_type_link', 10, 2);          // my own function to do what get_category_parents does for other taxonomies     function get_taxonomy_parents($id, $taxonomy, $link = false, $separator = '/', $nicename = false, $visited = array()) {             $chain = '';            $parent = &get_term($id, $taxonomy);              if (is_wp_error($parent)) {             return $parent;         }              if ($nicename)                 $name = $parent -> slug;                 else                 $name = $parent -> name;              if ($parent -> parent && ($parent -> parent != $parent -> term_id) && !in_array($parent -> parent, $visited)) {                 $visited[] = $parent -> parent;                 $chain .= get_taxonomy_parents($parent -> parent, $taxonomy, $link, $separator, $nicename, $visited);              }              if ($link) {             // nothing, can't get this working :(         } else {                $chain .= $name . $separator;             }         return $chain;         }      But this solution not working in two scenarios. 1st Scenario: On Child Taxonomy direct link   e.g: sitename.com/articles/parenttax/childtax/ 2nd Scenario: On Pagination of Custom Post page   e.g: sitename.com/articles/parenttax/childtax/postname/page/2 Do I have to create separate function for them or just need to add new rules for it?


title: What is the best way and how do I display posts from categories and users a user is following?

text: I am making a user/term following system where users can follow users and terms (inlcuding categories). Once the user follows another user and/or term I am saving the ids for each in a custom table. One table for user following and another table for term following. What I need to do now is to display the posts from those users and terms the user is following. For now, I am collecting all the users and terms ids a user is following into two separate arrays and using this for setting up two WP_Query, one for users (authors ids) and the other for terms.               foreach ( $following_users_ids as $following_user_id ) {         $authors[] = $following_user_id->follows_id;     }     foreach ( $following_terms_ids as $following_term_id ) {         $terms[] = $following_term_id->follows_id;     }          $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;           $authors_args = array(       'author__in' => $authors,        'posts_per_page' => -1     );     $authors_query = new WP_Query($authors_args);          $terms_args = array(       'category__in'   => $terms,       'posts_per_page' => -1     );     $terms_query = new WP_query($terms_args);      After setting up the queries, I fill two other sets of arrays with the posts ids, one for users and the other for terms. And merge them into one.               foreach ($authors_query->posts as $author_id ) {         $authors_ids[] = $author_id->ID;     }     foreach ($terms_query->posts as $term_id ) {         $terms_ids[] = $term_id->ID;     }     $result = array_unique(array_merge($authors_ids,$terms_ids));      Now that I have all the posts ids (from users and terms), I set up a third WP_query.               $args = array(       'post__in'     => $result,       'posts_per_page' => 12,       'paged'          => $paged,     );     $the_query = new WP_Query( $args );      ## TARGET To display posts from categories/terms and users a user is following in a custom template page. (The best way possible performance wise). ## PROBLEM   1. With my current code, it takes forever to fill in the arrays with all the ids.   2. There might be hundreds or even thousands of terms and users a user is following. ## ALTERNATIVES   1. I thought about using SQL direct queries to get the ids, but it would still take forever to fill in an array with all those ids.   2. I might sequentially get those ids, but I dont know how to do that.


title: There is way to improve this query? wordpress get post data and some meta data

text: Suppose we have 2 blog with different database A and B. I want to get some post from Blog B to show them on Blog A. The problem comes when the posts have much metadata (custom field for example) that i want to retrive with the post. My current query is below but it takes more than 16 sec...               SELECT post.ID, post.guid, post.post_title,              attachment_meta.meta_value AS upload_relative_path,              test.meta_value AS publish_carlton,              extest.meta_value AS exp_date,             pt.meta_value AS price_type,             pa.meta_value AS price,             post_title_EN.meta_value AS title_EN,             post_title_DE.meta_value AS title_DE,             post_title_FR.meta_value AS title_FR,             post_title_ES.meta_value AS title_ES     FROM cs_posts AS post         JOIN cs_postmeta AS post_meta ON (post_meta.post_id = post.ID AND post_meta.meta_key = 'service_service_a4_img_thumbnail_id')         JOIN cs_postmeta AS extest ON (extest.post_id = post.ID AND extest.meta_key = 'expiration_date')         JOIN cs_postmeta AS test ON (test.post_id = post.ID AND test.meta_key = 'vocs_carlton')         JOIN cs_postmeta AS pt ON (pt.post_id = post.ID AND pt.meta_key = 'service_price_type')         JOIN cs_postmeta AS pa ON (pa.post_id = post.ID AND pa.meta_key = 'service_price')         JOIN cs_postmeta AS post_title_EN ON (post_title_EN.post_id = post.ID AND post_title_EN.meta_key = 'custom_title_EN')         JOIN cs_postmeta AS post_title_DE ON (post_title_DE.post_id = post.ID AND post_title_DE.meta_key = 'custom_title_DE')         JOIN cs_postmeta AS post_title_FR ON (post_title_FR.post_id = post.ID AND post_title_FR.meta_key = 'custom_title_FR')         JOIN cs_postmeta AS post_title_ES ON (post_title_ES.post_id = post.ID AND post_title_ES.meta_key = 'custom_title_ES')         JOIN cs_postmeta AS attachment_meta ON (attachment_meta.post_id = post_meta.meta_value AND attachment_meta.meta_key = '_wp_attached_file')          WHERE post.post_status = 'publish'         AND post.post_type = 'service'         AND test.meta_value = '1'     ORDER BY post.menu_order ASC     LIMIT 20      Solved with some php code, now it takes 0,0030 in total, much different from 16 sec!               $sql = "SELECT post.ID, post.guid, post.post_title,              attachment_meta.meta_value AS upload_relative_path,              test.meta_value AS publish_carlton     FROM cs_posts AS post         JOIN cs_postmeta AS post_meta ON (post_meta.post_id = post.ID AND post_meta.meta_key = 'event_event_a4_img_thumbnail_id')         JOIN cs_postmeta AS test ON (test.post_id = post.ID AND test.meta_key = 'vocs_carlton')         JOIN cs_postmeta AS attachment_meta ON (attachment_meta.post_id = post_meta.meta_value AND attachment_meta.meta_key = '_wp_attached_file')          WHERE post.post_status = 'publish'         AND post.post_type = 'event'         AND test.meta_value = '1'     ORDER BY post.menu_order ASC     LIMIT 20";               $res = $wpdb2->get_results($sql);          //0.0030      foreach ($res as $r) {              $nsql = "SELECT post_meta.meta_value,post_meta.meta_key                  FROM cs_postmeta AS post_meta                  WHERE post_meta.post_id = '".$r->ID."';";         $metares = $wpdb2->get_results($nsql);              foreach($metares as $meta) {                  if ($meta->meta_key == 'event_price_adult')                 $r->price = $meta->meta_value;                  if ($meta->meta_key == 'custom_title_EN')                 $r->title_EN = $meta->meta_value;                  if ($meta->meta_key == 'custom_title_DE')                 $r->title_DE = $meta->meta_value;                  if ($meta->meta_key == 'custom_title_ES')                 $r->title_ES = $meta->meta_value;                  if ($meta->meta_key == 'custom_title_FR')                 $r->title_FR = $meta->meta_value;              }               }               return ($res);


title: integrate jQuery fileupload

text: I want to integrate jQuery file upload with wordpress. The basic function I want is to pass files[] to wordpress and let him handle this upload. I know it is possible becasue of this plugin here: http://wordpress.org/plugins/jquery-html5-file-upload/ I spent more then a day digging into his code, but I don't get a bit how he manages this.                     this is how my code looks now. and I have another file where I register my ajax calls like this.               function testUpload() {         die(var_dump($_POST));     }     add_action( 'wp_ajax_testUpload', 'testUpload' );      Can I manage this somehow to connect uploadHandler with my Wordpress. **Also to note, everything is fine with using default Handler except I want to pass`current_user_id` with it** Maybe I can require this inside my themes functions.php and construct new handler from there passing `user_id`, but then what to call with ajax? what url to pass?


title: User capability per post

text: According to Codex we can perform `current_user_can` checks for certain `post_ID`, but I fail to find any bit of info how to set a capability explicitly for that `post_ID`. A follow up question - how to set custom capability (for ex. `download_doc`) of the same type that could be later checked by `current_user_can( "download_doc", get_the_ID() );`


title: Implement location at wordpress post via custom taxonomies?

text: I would like to add a new custom hierarchical taxonomy (or 3 custom taxonomies... dependent your answer) which contain the location by: City + States&territories + Country. for example: Orlando + Florida + United States Monroeville + Pennsylvania + United States Noyabrsk + Yamalo-Nenets Autonomous Okrug + Russia In the final implementation the user can choose post (or posts list) by choosing Country (and or) states & territories (and or) City. One more thing for my example: if the user choosing Russia as Country he won't get the option for Florida as States&territories... Can I implement it as custom hierarchical taxonomy (or 3 custom taxonomies)?


title: Gravity Forms field entries into wp_query loop

text:
I have a simple function that filters the page content when form (ID 18) is submitted. It simply displays the entry of field (ID 13)...               add_action("gform_after_submission_18", "set_post_content", 10, 2);     function set_post_content($entry, $form){              //getting post         $post = get_post($entry["post_id"]);              //changing post content         $post->post_content = $entry[13];          }      Instead of simply displaying the entry, I need to use it as a variable within a wp_query loop.. The result I need is a loop of titles from all posts of the post type selected by form field (ID 13). The form field (ID 13) will be radio buttons with options for various custom post types..               <?php $loop = new WP_Query( array(          'post_type' => '$martinsposttype',         'orderby' => 'title',         'posts_per_page' => '-1',          'order' => 'ASC'     ) ); ?>
                 <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php the_title(); ?>
          <?php  endwhile; ?>
      How on earth do I tie this all up into my function so that the wp_query loop is performed upon submission and the $entry[13] is used for 'post_type' within that loop?


title: Custom post type blog pagination conflict

text:
I have a custom post type called 'emp_case-studies' and it has a page archive. Here is the code for archive-emp_case-studies.php:               <?php        $blog = $wp_query;        $wp_query= null;        $args= null;             $args = array(            'post_type' => 'emp_case-studies'         );             $postsperpage = 5;        $offset = $paged == 0 ? 0 : ($paged-1)*$postsperpage;                  $paging =   array(           'posts_per_page' => $postsperpage,           'offset' => $offset        );             $ordering =  array(           'orderby' => 'ID',           'order' => 'DESC'        );                  $args = array_merge($args, $ordering, $paging);          $wp_query = new WP_Query($args);          ?>          <?php        get_header();         get_template_part( 'include/content', 'head' );     ?>          <div class="postcontent nobottommargin<?php if( semi_option( 'blog_sidebar' ) == 'left' ) { echo ' col_last'; } ?> clearfix">     <?php             if ( $wp_query->have_posts() ) :             ?>
             <?php                 while ( $wp_query->have_posts() ) : $wp_query->the_post();                 ?>                                      <div id="post-<?php $wp_query->ID; ?>" <?php post_class('entry clearfix'); ?>>                                     <?php                                     get_template_part( 'include/blog/news/post', 'standard' );                                     ?>
                 <?php                                 endwhile;                 get_template_part( 'include/blog/navigation' );                 ?>
<?php             else :                 get_template_part( 'include/blog/error' );             endif;             $wp_query = $temp;             ?>
     <?php     get_sidebar('casestudies');     get_template_part( 'include/content', 'foot' );      get_footer();     ?>      I had a terrible time getting pagination to work correctly so that I could have: archive page: /case-studies single page: /case-studies/post-title Using the custom query got me the majority of the way. Page 1 and 2 worked fine, but page 3 onward did not. I found a post on the official WordPress forum with someone having the same issue. It was solved by changing Settings > Reading > Blog pages show at most to 1. This worked for me too. All the pagination on my custom post type archive pages work perfectly. However, it means that now my blog and search results page are only showing one post per page. Is there any way I can change this to 5 posts per page? P.S. My theme includes this function to provide pagination. It is used on both blogs and the search results page.               function semi_pagination( $pages = '', $range = 4 ) {               $showitems = ($range * 2) + 1;                 global $paged;               if( empty( $paged ) ) $paged = 1;               if( $pages == '' ) {                   global $wp_query;                   $pages = $wp_query->max_num_pages;                   if(!$pages) {                       $pages = 1;                   }               }                  if(1 != $pages) {                   echo "

";                   if( $paged > 2 && $paged > $range + 1 && $showitems < $pages ) echo "
⇐
";                   if( $paged > 1 && $showitems < $pages ) echo "
«
";                   for ( $i = 1; $i <= $pages; $i++ ) {                       if ( 1 != $pages && ( !( $i >= $paged + $range + 1 || $i <= $paged - $range - 1 ) || $pages <= $showitems )) {                           echo ( $paged == $i ) ? "
" . $i . "
" : "
" . $i . "
";                       }                   }                   if ( $paged < $pages && $showitems < $pages ) echo "
»
";                   if ( $paged < $pages-1 &&  $paged + $range - 1 < $pages && $showitems < $pages ) echo "
⇒
";                   echo "

\n";               }          }


title: wp_editor not adding paragraphs despite wpautop being set to true

text:
I'm using the following code to produce a `wp_editor` instance:               <?php if (version_compare($wp_version, "3.3") >= 0) { ?>
<?php wp_editor(  $answer->post_content, 'answer', array( 'media_buttons' => true, 'wpautop' => true ) ); ?>
     <?php } else { ?>
<textarea name="answer" class="wp32"><?php echo esc_textarea( $answer->post_content ); ?></textarea>
     <?php } ?>      Yet for some reason, the **answer** content isn't displaying with paragraphs. The HTML for the **question** content is:

I am somehow missing it.   When I go to the “Knowledge Base” and click on “Tetras”

I get one page of tetra descriptions starting with the “A”s.

How do I get to the next page????

      But the HTML content for the **answer** is:
                     Hi Jim,          The Tetras that you're seeing there are currently the only Tetras marked as being in that group!          Matt is working fervently to update the species database to our new website format, so at the moment, not every species is marked as being in the correct Knowledge Base groups.          Please bear with us!
      * * * **EDIT: Printing out the answer content**                   foreach ( $answers->posts as $answer ) {             setup_postdata( $answer );     ?>         <div id="answer-<?php echo $answer->ID; ?>" class="answer">             <?php the_answer_voting( $answer->ID ); ?>

                     <?php echo get_the_content(); ?>

                     <?php the_qa_action_links( $answer->ID ); ?>                     <?php the_qa_author_box( $answer->ID ); ?>

     <?php      * * * Any ideas? Thanks in advance,


title: Narrow Down a Shop Page Results Based on a Product Tag in WooCommerce

text: I have a shop page that displays a product (chairs) for a retailer in multiple cities. Each city is a tag for each product. What I want to be able to do is narrow down a category page like (chairs) or a shop page to only show product from that city. Is there a way to filter the product results?


title: unwanted P tags in shortcode, delay wpautop not working

text:
Like others, I'm having issues with WP adding unwanted p tags in my code. I have a shortcode I created that is to simply just spit out my javascript and html when I use it. Everything works fine except WP is wraping each in p tags. Adding many lines of blank unwanted space. I have tried the solution here: Automatically added brs and paragraphs? to no avail. Here is what I have in my functions.php file               <?php     remove_filter( 'the_content', 'wpautop' );     add_filter( 'the_content', 'wpautop' , 12);     remove_filter( 'the_excerpt', 'wpautop' );          /***************/     /**ShortCodes**/     /**************/          /*** Form to contact Us **/     function contact_us() {      return <<<HTML
 Here's the low down on what to do
         <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css"/>\n     <link rel="stylesheet" href="http://studiocloud.com/css/validationEngine.jquery.css" type="text/css"/>\n     \n     \n     \n     \n     \n     <form action="" id="signupform" name="signupform">                     <input type="hidden" id="tid" name="tid" value=""/>                     <input type="hidden" id="scid" name="scid" value="TPN02L48KAVJKVRD"/>                     <input type="hidden" id="fid" name="fid" value="392"/>
                                         <fieldset class="field_set""><legend>Contact Us For More Information</legend>     First Name *<input type="text" id="firstName" name="firstName"  class="validate[required] input_text"  placeholder="First Name" >     Last Name *<input type="text" id="lastName" name="lastName"  class="validate[required] input_text"  placeholder="Last Name" >     Phone<input type="text" id="workPhone" name="workPhone"  class="validate[optional] input_text"  placeholder="Phone" >     Email *<input type="text" id="email" name="email"  class="validate[required,custom[email]] input_text"  placeholder="Email" >     Comments *<textarea name="item5"  id="item5"  class="message" placeholder="Comments" ></textarea>     * Required Fields     <input type="button" id="item7"  name="item7" onClick="processContactUs(event)" class="button" value="Submit" >     </fieldset>
                 </form>

     HTML;     }               add_shortcode('contact_us','contact_us');      any ideas? using \n seems to get rid of unwanted br tags I was getting, but now still getting the p tags. thanks.


title: Force Network Admin Dashboard to 1 column on wordpress multisite

text: I am wondering whether anyone knows how to force the dasboard layout to 1 column on a wordpress Multisite install for the Network Admin Dashboard This is part of the solution but it does not force the number of columns to 1:               function so_screen_layout_columns( $columns ) {         $columns['dashboard-network'] = 1;         return $columns;     }     add_filter( 'screen_layout_columns', 'so_screen_layout_columns' );      The following should force it but it does not work on the Network Admin Dashboard page, Anyone knows of a solution?               function so_screen_layout_dashboard() {         return 1;     }     add_filter( 'get_user_option_screen_layout_dashboard', 'so_screen_layout_dashboard' );


title: Query from multiple category (and)

text: here is the request : get all post from category=11 (get 21 post), and then in the 21 post got from this category, refilter it, and show only post from category=10. So the request should be : cat=11&10. i what post that are from BOTH category at the same time, because my category are job and active. i what the listing of all the job, and then show just the one that are ative in the system !               $$mycat = "11&10"      $showPostsInCategory->query('cat='. $mycat.'&posts_per_page=-1');


title: put saved metabox values back into fields and then display on the front end

text:
i have a group of metaboxes which i finally are now saving but am struggling to get the saved values back into the input boxes they came from. so for example i have a meta field called link text and if i put 'link 1 text' in there and save I save it but it doesn't show back in the form. the code i use for this is:               function home_callout_meta_box_cb($post) {         global $post;         wp_nonce_field('home_callout_nonce', 'home_callout_meta_box_nonce');         $values = get_post_custom($post->ID);              for ($i = 1; $i <= 3; $i++) {                  $imagefield1[$i] = isset($values['imagefields'][$i]['image1']) ? esc_attr($values['imagefields'][$i]['image1'][0]): '';             $imagefield2[$i] = isset($values['imagefields'][$i]['image2']) ? esc_attr($values['imagefields'][$i]['image2'][0]): '';                  $linktext[$i] = isset($values['linktext'][$i]) ? esc_attr($values['linktext'][$i][0]): '';             $link[$i] = isset($values['link'][$i]) ? esc_attr($values['link'][$i][0]): '';                       echo '
Call out box ' . $i .' image 1
';             echo '
';             echo '<input type="text" id="imagefields[' . $i . '][image1]" name="imagefields[' . $i . '][image1]" class="upload-url image_url" readonly="readonly" value="' . $imagefield1[$i] .'" />';             echo '<input id="st_upload_button" class="st_upload_button button-secondary upload_image" type="button" name="upload_button" value="Upload" />';             echo '
';                  echo '
Call out box ' . $i .' image 2
';             echo '
';             echo '<input type="text" id="imagefields[' . $i . '][image2]" name="imagefields[' . $i . '][image2]" class="upload-url image_url" readonly="readonly" value="' . $imagefield2[$i] .'" />';             echo '<input id="st_upload_button" class="st_upload_button button-secondary upload_image" type="button" name="upload_button" value="Upload" />';             echo '
';                  echo '
Call out box ' . $i .' link text
';             echo '<input type="text" id="linktext[' . $i . ']" name="linktext[' . $i . ']" value="' . $linktext[$i] . '" />';                  echo '
Call out box ' . $i .' link
';             echo '<input type="text" id="link[' . $i . ']" name="link[' . $i . ']" value="' . $link[$i] . '" />';             // var_dump($values['imagefields'][0]);         }     }          function home_callout_save($post_id) {         if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;         if(!isset($_POST['home_callout_meta_box_nonce']) || !wp_verify_nonce($_POST['home_callout_meta_box_nonce'], 'home_callout_nonce')) return;         if(!current_user_can('edit_pages')) return;              if(isset($_POST['imagefields'])) {             update_post_meta($post_id, 'imagefields', $_POST['imagefields']);            }              if(isset($_POST['linktext'])) {             update_post_meta($post_id, 'linktext', $_POST['linktext']);         }         if(isset($_POST['link'])) {             update_post_meta($post_id, 'link', $_POST['link']);         }     }     add_action('save_post', 'home_callout_save');      I know the fields save because if i do a var_dump($values['linktext']); this is the array that is returned:               array(1) { [0]=> string(75) "a:3:{i:1;s:11:"link text 1";i:2;s:11:"Link 2 text";i:3;s:11:"Link 3 text";}" }       i am unsure how to get the saved values back into each field. the other small question i have is to retreieve the values of each meta box on the front end would i use:               get_post_meta($post_id, 'linktext'][1]', true);      thanks in advance for any help.


title: How to get last comments but not from admin (or other specific user role/capability)?

text: I'm using get_comments to show lastest comments i.e.:               <?php         global $comments, $comment;         $comments = get_comments( array( 'number' => '5', 'status' => 'approve', 'post_status' => 'publish' ) );              foreach ( (array) $comments as $comment) {          echo '<li>'.$comment->comment_author.' said '.$comment->comment_content .'</li>'         }     ;?>      Is there some way to override admin comments?! I know this tip using SQL but maybe Im'missing something in this function? Thanks for help. **Updated code** Place this code wherever template file such `sidebar.php`, `footer.php` and will list latest comments (displaying Admin comments tough).


title: If Query Post Returns 1 Post

text: I have been using Query Post for a newsticker which I have created so that the user navigate through the number of news by simply pressing Next & Previous buttons. But in case if there is only 1 news (i.e, only 1 post returned then there is no point of having Prev and Next button). I will simply assign css attribute Display: none to the prev and next button if there is only 1 post. But how to find out if the query post returned just 1 post.               query_posts('post_type=post&cat=20&post_status=publish&order=DESC');          while (have_posts()): the_post();


title: Word Press: new account

text: Is there an equivalent to this for Twitter? For both twitter and WordPress I can't open a new account: my computer keeps defaulting automatically to my WordPress or twitter account - and there I am stuck. I want to open a new account for different things on both.


title: Cross post type parent page added parent page to permalink but give 404

text: I have made some custom post types with Magicfields. I need to set the parent page for a custom post type to a standard wordpress page. Figured that out with the help of this: http://janina.tumblr.com/post/3588081423/post-parent- different-type But now the parent page and it's parent is being added to the permalink and the view page or the new URL is returning a 404. Example:   * Custom Post Type Products light and post x-rays   * Set Parent of x-rays Product Page to waves Page which is a standard WP Page and has a parent of science   * this creates this URL site.com/light/science/waves/x-rays - this breaks   * without a parent for x-rays, the URL is site.com/light/x-rays   * with the cross post type parent - the science/waves is added and view page gives 404, but if I removed the /science/waves from the URL, the site.com/light/x-rays works. So it seems the permalink structure doesn't know how to go from one post type to another. Which makes the get_permalink function not work, which causes all kinds of headaches. Suggestions, questions?


title: Listing all capabilities in dropdown is returning boolean

text: Trying to put a list of all possible caps in a dropdown. I can only get it to return 1s (boolean true). If I use var_dump($user->allcaps); it does produce the actual cap names, but when I plug this into my function, it goes to boolean. Have tried using various settype statements; nothing has worked. Here's the function currently:               add_shortcode('capsdropdown', 'sc_capsdropdown');     function sc_capsdropdown($attr) {     $user = get_user_by('id', '1');     $capslist = $user->allcaps;     $dropdown = '<select>';     foreach($capslist as $cap){     $dropdown .= '<option value="'.$cap.'">'.$cap.'</option>';     }     $dropdown .= '</select>';     return $dropdown;     }      Resolved. This works:               foreach($capslist as $cap=>$caps){ $dropdown .= '<option value="'.$cap.'">'.$cap.'</option>'; }


title: Rewirte the theme URLs

text: I was trying to implement the rewrite system of Roots on my theme. I followed this tutorial. In my `functions.php` I put the following:               include_once(THEME_LIB . '/rewrites.php');      And created the `rewrites.php` with:               <?php     // re-write /wp-content/themes/THEME_NAME/css/ to /assets/css/     // re-write /wp-content/themes/THEME_NAME/js/  to /assets/js/     // re-write /wp-content/themes/THEME_NAME/img/ to /assets/img/     // re-write /wp-content/plugins/ to /plugins/     function cd_add_rewrites($content)     {         global $wp_rewrite;         $cd_new_non_wp_rules = array(             'assets/css/(.*)'    => 'wp-content/themes/THEME_NAME/css/$1',             'assets/js/(.*)'     => 'wp-content/themes/THEME_NAME/js/$1',             'assets/images/(.*)' => 'wp-content/themes/THEME_NAME/images/$1',             'plugins/(.*)'       => 'wp-content/plugins/$1'         );         $wp_rewrite->non_wp_rules = array_merge($wp_rewrite->non_wp_rules, $cd_new_non_wp_rules);         return $content;     }          function cd_clean_urls($content) {         if (strpos($content, '/wp-content/plugins') === 0) {             return str_replace('/wp-content/plugins', wp_base_dir() . '/plugins', $content);         } else {             return str_replace('/wp-content/themes/THEME_NAME', '', $content);         }     }          /* Now we filter our WordPress URL's to use our New Re-writes */     if (!is_multisite() && !is_child_theme()) {         add_action('generate_rewrite_rules', 'cd_add_rewrites');              if (!is_admin()) {             $tags = array(                 'plugins_url',                 'bloginfo',                 'stylesheet_directory_uri',                 'template_directory_uri',                 'script_loader_src',                 'style_loader_src'             );             foreach($tags as $tag) {                 add_filter($tag, 'cd_clean_urls');             }         }     }          function cd_flush_rewrites()     {         global $wp_rewrite;         $wp_rewrite->flush_rules();     }     add_action('admin_init', 'cd_flush_rewrites');     ?>      But it doesn't work.


title: Custom Wordpress Theme: Publish Date and Display Date for posts right beside each other

text: What's currently happening is that for posts that have an 'update' time, the original publish and editor dates are rendering side by side (with no extra information in between, or even a space for that matter), and I'm not entirely sure where I should look to fix this. I need guidance in terms of **which files to look in for this output code** , or, if possible, some other manner in which to add a word or two in between the two dates. The theme is based off of _S - which explains why I do not know where my desired page is, and this problem persists in any area of the theme where you can see the dates (Blog, Search Results, actual posts themselves). I could hide one of the dates with CSS - but I'd definitely want to show the most recent update date, and that would leave me with the dilemma of making complex and unnecessary CSS to hide dates which could be handled in a much better way (I'm thinking of setting link display to none, then :last-child's display to true, but browser compatability would be hit, and it doesn't seem very prfoessional to me). ![Demo Of Problem](http://i.stack.imgur.com/21SUQ.png)


title: Strip HTML comments from plugins in header/footer

text: Would anyone know a function or how to remove `<!-- plugin inserted stuff-->` from the header and footer so that they won't be visible when viewing source?


title: How to remove Pingbacks and xmlrpc?

text: How can I remove totally the pingbacks and xmlrpc? I've already disabled the allow pingbacks in my `wp settings` but nothing happen. Also I put this code in `functions.php`.               function remove_x_pingback($headers) {         unset($headers['X-Pingback']);         return $headers;     }     add_filter('wp_headers', 'remove_x_pingback');      But when I put and save it and reload the site again.. it gives me a white blank page. Please help me. Thank you


title: How can I rotate images in Wordpress?

text: I'm receiving the following error while I attempt to edit images within Wordpress: > "Could not load the preview image. Please reload the page and try again." What would cause this? Wordpress attempts to do me a favor by rotating the image, but I need to adjust this particular image to face the appropriate direction. Reloading the page didn't help and trying other browsers doesn't work. I've disabled plugins & reverted back to the TwentyTen theme, but still see the same issue. ![Error in question](http://i.stack.imgur.com/XXfWh.png)


title: Error after editing functions.php

text: I was making minor changes to `functions.php` file but just as I made the changes I got an error, I used `FileZilla` and undo the function I added but now I am getting the following error, > Fatal error: Call to undefined function add_action() in > /home/content/93/7877293/html/wordpress/wp-includes/functions.php on line 51 I am sure that the file is now in its original condition. Can anyone help me by suggesting me how to deal with it? Thanks in advance.


title: Secret keys in SCM

text: I have a WordPress installation in a Git repository and I'm wondering, if it's safe to have the 8 "secret keys" stored in there, or if I should insert them during deploy.


title: How to log custom plugin error to debug.log file

text: I was searching google for this on how can log my plugin error's to debug.log after enabling the `define('WP_DEBUG_LOG', true);` but there is no luck for me, any expert have done this before? Please help me on this.


title: How to redirect 'file url' to 'post url' i.e. in attachment.php

text: I've just started using the attachment.php template on my site. What I'd like to do is redirect all images in posts that used 'file url' to 'post url' and my new attachment.php template. Is this possible? Thanks in advance for any help. EB


title: Linking Two Post Types

text: and thanks in advance for your help. I've done some searching, and this question has been answered a couple of times with reference to the "posts 2 posts" plugin, but the documentation on that is very "coder-centric" -- I am able to and comfortable getting my hands dirty, but I do require better Step-by-Step documentation than what is available there. :) Here's what I need. I am using gPress to generate "Places" using their custom post type. This is working amazingly well. What I need to do is to be able to add "Events" to a Place. I can use a custom post type to capture all event details, but then I'd like to be able to attach Events to a specific Place, and vice-versa. If someone was viewing the Event post, there would be a somewhat easy way to also pull the Place information related to the Event. Thanks very much -- any plugins or other suggestions are appreciated! Cheers, John


title: the_content() won't load galleries on homepage

text:
I need to show a gallery that's on the content of one of the pages I'm displaying on the homepage (I altered the query so it would display pages instead of posts). If I open the page directly I can see the gallery but on the homepage I can only see the text around it. This is the code I used to modify the home loop:               add_action( 'pre_get_posts', 'setup_site_loop' );     function setup_site_loop( $query ) {       if ( is_home() ) {         $query->set('post_type', 'seccion');          $query->set('orderby', 'menu_order title');          $query->set('order', 'ASC');        }     }      Here's the home.php
            <?php if (have_posts()) : while (have_posts()) : the_post();          <article id="section-<?php echo $post->post_name; ?>" <?php post_class( 'clearfix' ); ?> role="article">
           <?php the_content(); ?>

             endwhile;       endif; ?>


title: Custom style on profile options page

text:
is there any way to style the profile page on wordpress ? I will like to add something like: **Start of the page just below the`<h2>` tag**

      **Before each opening`<table>` tag** (note "the php_e('name')" )

<?php _e('Name') ?>

      **After each closing`</table>` tag**

      **After the`</form>` tag**

      I'm not interested in adding a custom CSS file, I will be happy to use what is there already. As a test I edited the user-edit.php from wp-admin and it looks fine, in my opinion much better. Is there any proper way to add these div's to the page. Edit, I'm aware of the following code, but I hope some body can help with the "preg_replace" to add the above div's.               function users_edited($buffer) {     if (!current_user_can('activate_plugins')) {             global $pagenow;             if ($pagenow == 'profile.php' || $pagenow == 'users.php' || $pagenow == 'user-edit.php') {                 //Hide the Name table                 $name = '#
Name
.+?
#s';                 $buffer=preg_replace($name,'',$buffer,1);                 $personal = array('#
Name
.+?
#s', '#
Personal Options
.+?
#s');                 $buffer=preg_replace($personal,'',$buffer,1);                      //Modiffy Contact Person header from h2 to h3                 $contactperson='#
Contact Person
#';                 $buffer=preg_replace($contactperson,'
Contact Person
',$buffer,1);                  }             return $buffer;         }     }     function users_edit_start() {      if (!current_user_can('activate_plugins')) {             ob_start("users_edited");          }     }     function users_edit_end() {      if (!current_user_can('activate_plugins')) {             ob_end_flush();          }     }     add_action('admin_head', 'users_edit_start');     add_action('admin_footer', 'users_edit_end');


title: Links In Sidebar not displaying

text: Ive placed a link in the sidebar, however its not showing up at all! Any ideas? The link is the blackburn text in the post. http://pcdconsultancy.co.uk/ thanks Kirsty


title: How does WooCommerce store products / product variations? / Free Script to import product variations?

text: So I'm just working for a client right now importing CSVs of products to WooCommerce. I've imported a lot of products so far using an existing plugin, but don't want to buy the CSV Product Import Suite for $99 to import product variations. So... Can anyone help me to answer one of the following two questions:   1. Does anyone know a free WooCommerce plugin / script that will let me import product variations?   2. If not, can anyone explain to me HOW WooCommerce stores product variations in the MySQL database, so that I can write a script to import product variations? Cheers!!


title: How to include parent terms in hierarchical taxonomy URLs?

text: For all custom taxonomies, the URLs look like: **/base/slug/**. I need a solution to for my hierarchical taxonomies to have: **/base/parentslug/childslug/**. Anybody knows how to redirect and or to have the same functionality like categories?


title: Using and saving custom dropdown boxes on user profiles

text:
Okay, so I'm creating a website and am in need of help for some custom meta fields for user profiles. Currently I have the following in my _functions.php_ file:               //hooks     add_action( 'show_user_profile', 'Add_user_fields' );     add_action( 'edit_user_profile', 'Add_user_fields' );          function Add_user_fields( $user ) { ?>
Size & Shape

             Top (neck, shoulders, arms) 	                              <?php                  //get dropdown saved value                 $selected = get_the_author_meta( 'user_top', $user->ID ); //there was an extra ) here that was not needed                  ?>                 <select name="user_top" id="user_top">                     <option value="gotguns" <?php echo ($topselected == "gotguns")?  'selected="selected"' : '' ?>>I got guns</option>                     <option value="yogatop" <?php echo ($topselected == "yogatop")?  'selected="selected"' : '' ?>>Yoga top</option>                     <option value="waifish" <?php echo ($topselected == "waifish")?  'selected="selected"' : '' ?>>Waif-ish</option>                 </select>

             Middle (bust, waist) 	                              <?php                  //get dropdown saved value                 $selected = get_the_author_meta( 'user_middle', $user->ID ); //there was an extra ) here that was not needed                  ?>                 <select name="user_middle" id="user_middle">                     <option value="handful" <?php echo ($middleselected == "handful")?  'selected="selected"' : '' ?>>Perfect handful</option>                     <option value="yogawaist" <?php echo ($middleselected == "yogawaist")?  'selected="selected"' : '' ?>>Yoga Waist</option>                     <option value="itsybitsy" <?php echo ($middleselected == "itsybitsy")?  'selected="selected"' : '' ?>>Itsy Bitsy</option>                 </select>

             Bottom (hips/thighs) 	                              <?php                  //get dropdown saved value                 $selected = get_the_author_meta( 'user_bottom', $user->ID ); //there was an extra ) here that was not needed                  ?>                 <select name="user_bottom" id="user_bottom">                     <option value="junktrunk" <?php echo ($bottomselected == "junktrunk")?  'bottomselected="bottomselected"' : '' ?>>Junk in the trunk</option>                     <option value="yogabottom" <?php echo ($bottomselected == "yogabottom")?  'bottomselected="bottomselected"' : '' ?>>Yoga Bottom</option>                     <option value="shrunktrunk" <?php echo ($bottomselected == "shrunktrunk")?  'bottomselected="bottomselected"' : '' ?>>Shrunk in the trunk</option>                 </select>

          <?php }          add_action( 'personal_options_update', 'save_user_fields' );     add_action( 'edit_user_profile_update', 'save_user_fields' );          function save_user_fields( $user_id ) {              if ( !current_user_can( 'edit_user', $user_id ) )             return false;              //save top         update_usermeta( $user_id, 'user_top', $_POST['user_top'] );              //save middle         update_usermeta( $user_id, 'user_middle', $_POST['user_middle'] );              //save bottom         update_usermeta( $user_id, 'user_bottom', $_POST['user_middle'] );     }      All of the code seems to work and when I click "Update Profile" it works (I think), but the dropdowns display the first item, instead of the selected item by the user. So if a user selected "Yoga Top" and clicked on "Save", "I Got Guns" is displayed instead of "Yoga Top", which the user selected. Is there anyway I can fix this? I would really appreciate any help as we are under the gun in terms of time. Thanks! -Keenan


title: Unable to paginate a custom page query

text:
I have this code on a page called **Categories**.               <?php     /*     Template Name: Categories     */          get_header(); ?>

                         Categories
                               <?php                     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                  $args = array(                 'post_type' => 'post',                 'posts_per_page' => '4',                 'paged' => get_query_var('paged')             );             $the_query = new WP_Query( $args ); ?>                  <?php if ( $the_query->have_posts() ) : ?>                      <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>                          <?php                         get_template_part( 'content', 'categories' );                     ?>                      <?php endwhile; ?>                      <?php wp_pagenavi( array( 'query' => $the_query ) ); ?>                 <?php wp_reset_query(); ?>                  <?php endif; ?>
          <?php get_sidebar(); ?>     <?php get_footer(); ?>      I have set the template in admin to **page-categories** The pagination shows up with the correct number of pages to browse, however, when I click on the next page (the link is something like `example.com/categories/page/2/` ) I get 404 page. Why is that? how to fix it?


title: How to query for a week using key => value WP_Query argument notation?

text: I would like to be able to query for a specific year and week using WP_Query argument notation. I am using this notation as I would like the page to paginate. What's the correct "year" and "week" key value notation for performing the query in this manner? I know I could do something like this, but I would like the page to paginate. Here's the bit of code I'm using for the key-value wp_query notation:               <?php      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $args = array('category_name' => 'whats-happening', 'year' => 2012, 'week' => 46 ,'paged' => $paged);     $temp = $wp_query;     $wp_query = null;     $wp_query = new WP_Query($args);     if (function_exists('wp_pagenavi')) { wp_pagenavi(); }     if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post();     ?>          HTML post structure to loop through....          <?php if ($wp_query->max_num_pages > 1) : ?>         <?php next_posts_link( __('← Older') ); ?>         <?php previous_posts_link( __('Newer →') ); ?>     <?php endif; ?>          <?php         if (function_exists('wp_pagenavi')){ wp_pagenavi(); }         $wp_query = null;         $wp_query = $temp;         wp_reset_query();     ?>


title: Displaying several specific pages using WP_Query()

text: I want to display the pages 'famous' and 'mschief'. Using this code, WP_query() doesn't return any result:               $args = array(     'post_type' => 'page',     'pagename' => 'famous,mschief',     'posts_per_page' => 3     );      This code returns one of the 2 pages:               $args = array(     'post_type' => 'page',     'pagename=famous,mschief',     );      And this code returns the 2 pages correctly:               $args = array(     'post_type' => 'page',     'pagename=famous,mschief',     'posts_per_page' => 3     );      Why does the first piece of code (the only correct one to me) doesn't work? And why the two others produce these results?


title: Taxonomy page shows category in title

text: I have a custom taxonomy called 'Genres' within that I have various taxonomies: 'Paintings' 'Drawings' etc. I use the code below to create my page titles. When viewing the taxonomy page for 'Paintings' I get a page title 'Paintings | Genres | BlogName' whereas I wanted to display only: 'Paintings | BlogName', how can I do that?               <title><?php         /* Print the <title> tag based on what is being viewed */         global $page, $paged;              wp_title( '|', true, 'right' );              // Add the blog name.         bloginfo( 'name' );              // Add the blog description for the home/front page.         $site_description = get_bloginfo( 'description', 'display' );              if ( $site_description && ( is_home() || is_front_page() ) )             echo " | $site_description";             ?></title>


title: wp-parallax-content-slider plugin placing in one page only

text: I am new to wordpress, I have installed the parallax content slider in my demo site. Now the site consists for 5 static pages and I want the slider to appear only on the first page. If I add the function in the header.php its shown in all the pages. if ( function_exists( 'get_wp_parallax_content_slider' ) ) { get_wp_parallax_content_slider(); } If I add the short code [parallaxcontentslider] above the page it doesn't look good as the format of my home page is 1. header with navigation 2. the slider. 3. accordian. 4. testimonials. 5. the static page.


title: How to get movies by date

text:
Ola, i am building a complex cinema site, and i want to get movies by date Ex: The movies are aded trought post type, I have a custom field name date. How can i retrive the Movie that shoud play today in cinema ( date in custom field : 08.09.2012...) Ex: How can i retrive the movie by date Site: http://cinema.trancelevel.com/cinema/in-curand/ Movies that apear today...in righit Like This? `               <?php     $args = array(         'posts_per_page' => '-1',         'post_type' => 'post',         'meta_key' => 'premiera_cinema',         'meta_value' => date('Y-m-d'),         'meta_compare' => '='     );     $todays_movies = new WP_Query( $args );     ?>          <?php while ($todays_movies->have_posts()) : $todays_movies->the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?>

     <img src="/scripts/timthumb.php?src=<?php the_field('img'); ?>&h=60&w=90&zc=1" alt="" title="<?php the_title(); ?>" />     <?php $excerpt = get_the_excerpt();echo string_limit_words($excerpt,30);?><a class="detalii" href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'kubrick'), the_title_attribute('echo=0')); ?>">...detalii

     <?php endwhile; ?>


title: Manual excerpts for pages not working on Search

text:
# Image says it all... Page Edit: ![enter image description here](http://i.stack.imgur.com/DoCRr.gif) ## Search Results: ![enter image description here](http://i.stack.imgur.com/mJjGQ.gif) ## functions.php to enable page excerpts               add_post_type_support( 'page', 'excerpt' );      ## search.php code for displaying excerpt               <?php the_excerpt(); ?>           ## Full search.php code               <?php     /**      * The template for displaying Search Results pages.      *      * @package Shape      * @since Shape 1.0      */          get_header();      get_template_part('inc/header-image');?>

<?php printf( __( 'Resultados da Busca' ), '' . get_search_query() . '' ); ?>
                         <input type="search" value="<?php printf( __( '%s' ), '' . get_search_query() . '' ); ?>"></input>

                     <?php while (have_posts()) : the_post(); ?>

<a class="search-item-title" href="<?php the_permalink(' ') ?>" title="<?php the_title(); ?>"><?php the_title(); ?>
                                             <?php the_excerpt(); ?>                                             <a href="<?php the_permalink(' ') ?>" class="post-entry-read-more" title="<?php the_title(); ?>"><?php the_permalink(' ') ?>

                         <?php endwhile; ?>

     <?php get_sidebar(); ?>     <?php get_footer(); ?>


title: Use Filename for Alt and Title Tags

text: I currently name all of my image files like this:               Earth the Blue Planet.jpg      Which when uploaded gets changed to this:               Earth-the-Blue-Planet.jpg      I was wondering if it is possible to have the image's alt and title tags render like this using the filename when adding them to posts:               alt="Earth the Blue Planet" title="Earth the Blue Planet"      I know the title tag shouldn't be used like that, but I'll just be using the filename as a base to add in the information I want. This would just make it easier. Thank you so much! I love this place for all my Wordpress questions!


title: Add column(s) to post edit page

text: In the dashboard area you have the option of 1-4 columns. However when you are adding or editing a new post/page you only have the option of 1-2 columns. I would like to have be able to choose 1-3 or even 1-4 columns. I have lots of custom taxonomy that I would like to arrange more aptly by using more than 2 columns. There is a solution. It works on a Wordpress 3.2 installation I have but not on the current 3.4. It probably only needs a minor tweak but, I can't seem to figure it out. This is the solution from the link above...               add_action( 'submitpost_box', 'third_column_edit_form' );     add_action( 'submitpage_box', 'third_column_edit_form' );     function third_column_edit_form() {     global $post_type, $post;     //if( 'your-type' != $post_type )     //return;     $side_meta_boxes2 = do_meta_boxes( $post_type, 'column3', $post );     }          add_action( 'admin_print_styles-post.php',     'third_column_css');     add_action( 'admin_print_styles-post-new.php', 'third_column_css');     function third_column_css () {     global $post_type;         //if( 'your-type' != $post_type )          //     return;     ?>     <style type="text/css">     #side-info-column {       width: 580px;     }          #post-body {       margin-right: -620px !important;     }          #post-body-content {       margin-right: 600px !important;     }          #column3-sortables {       width: 280px;       float: right;       display: block;       min-height: 200px;     }          #side-sortables {       float: left;       display: block;       min-height: 200px;     }          /* Style copied from #side-sortables */          #column3-sortables .category-tabs, #column3-sortables .category-tabs {       margin-bottom: 3px;     }          #column3-sortables .category-tabs li, #column3-sortables .add-menu-item-tabs li {       display: inline;     }          #column3-sortables .category-tabs a, #column3-sortables .add-menu-item-tabs a {       text-decoration: none;     }          #column3-sortables .category-tabs .tabs a, #column3-sortables .add-menu-item-tabs .tabs a {       color: #333;     }     </style>     <?php     }'


title: Custom posts and custom taxonomies for many products and categories?

text: I'm a little confused about custom posts and custom taxonomies... I've read it everywhere but I didn't understand very well.. I would build a wordpress site, with many products, categories, feature and options... They will just order the products, without paying, so I don't need an e-commerce plugin.. Now the really question is: how can I organize the products in categories? I have to customize wordpress posts, to assign various feature and options, like the article code, or the color? I have to use custom taxonomies? (I have a vague idea of what it is...) Thanks in advance for who will help me.. I'm a little confused about this type of wordpress customization...


title: lock meta box position on post edit screen for contributors

text: Our website has an open system for contributors (WP User Role) to add news and calendar content to the site. I'd like to set and lock the position of the content and meta boxes on the post edit screen. Is there a filter or function to set the order of the boxes before I disable the option of changing the sort order? For Example, I'd like my post edit screen to appear in one column - Title > Taxonomy > Body > Meta Box > Meta Box > Publish.


title: fall back for main menu?

text:
I am new to WordPress, and am still trying to learn the in's and out's in much respect to this well known CMS. I am wanting to know, if I should or must have a Fallback for main menu? This is what I am working with:               // This theme uses wp_nav_menu() in one location.     register_nav_menus( array(         'primary' => __( 'Primary Navigation', 'xxxxxx' ),     ) );      And here is the callback within my header.php file:                                    <?php wp_nav_menu(          array(             'theme_location' => 'Primary',              'menu' =>  'Primary',             'container' => '',              'items_wrap' => '
%3$s
'           ));      ?>           Like I said, I am new. So please, any help will be much welcome. And if you could, please respond with an example.


title: How to pass custom options from widget form to widget update callback?

text:
I've added a few checkbox options to the default widget form. But I'm stuck on how to access these option states and pass them along during the widget save event (`widget_update_callback`) so that they can be saved by WP to the DB. How do I pass my custom form values to WP to save as widget options for each widget? In the first function, I'm Appending my checkbox options to all widgets control panels...               add_filter('in_widget_form', 'wse_widget_context_form');          function wse_widget_context_form(){          $checked = ' checked="checked"';     ?>

Don't show this widget on:

<input value="on" type="checkbox" name="noHome" id="noHome"<?php if(isset($instance['noHome'])) echo $checked ?> />Home Page

<input value="on" type="checkbox" name="noPosts" id="noPosts"<?php if(isset($instance['noPosts'])) echo $checked ?> /> Posts

<input value="on" type="checkbox" name="noPages" id="noPages"<?php if(isset($instance['noPages'])) echo $checked ?> /> Pages

<input value="on" type="checkbox" name="noCats" id="noCats"<?php if(isset($instance['noCats'])) echo $checked ?> /> Categories

      Callback function is below. `$instance` doesn't contain the custom form values, only the default widget values (text and content). How do I append my custom options to `$instance`?               <?php     add_filter('widget_update_callback', 'wse_widget_context_callback');          function wse_widget_context_callback($instance){         echo 'instance: '.$instance.'
'; // returns array but no custom form values          }


title: What type to upload image within theme options?

text: I want to get option to change logo within my option theme. I use this code:                   array("name" => "Upload Logo",         "desc" => "Choose an image",         "id" => $shortname."_logo_img",         "type" => "upload",         "std" => "",     ),      when I execute on my theme option page, nothing appear. I change that type to "file" and "image", that's same as before, nothing appear. I don't want to take URL, like when I set the type as "text".


title: Update page | Post shortcut

text: Is there a keyboard shortcut for updating a page or post? It is such a PIMA to scroll up and update manually.


title: Preserve custom URL parameter after saving post

text: I'm testing different layouts for my admin pages, and the easiest way I found to determine which layout to load is with URL parameters. One of those parameters is "fullscreen=1" which hides the admin menu, for instance. The problem is, whenever I save a post / custom post type by submitting a form, WordPress will redirect me without preserving my parameter, thus breaking my layout by adding back the admin menu... Is there an easy way to achieve this?


title: Display more than 10 posts on author.php file

text: it seems that there are only 10 posts being displayed on author.php file. The theme I'm using have just this in author.php file:-               <?php while ( have_posts() ) : the_post(); ?>          <?php endwhile; ?>     <?php wt_pagination(); ?>      The loop is getting only first 10 posts (of the author). How can I change it to first 30 posts. Without writing a secondary (custom) loop.


title: Taxonomy Category category.php not working

text: I have created custom post type, taxonomy and categorys. When viewing the category it seems to be using index.php and ignoring the WordPress template hierarchy. Any ideas why category.php, category-{id}.php etc aren't working for the custom post type categorys but working fine for regular posts? thanks               add_action('init', 'collegestampede_register');          function collegestampede_register() {              $labels = array(             'name' => 'College Stampede', 'post type general name',             'singular_name' => 'Member', 'post type singular name',             'add_new' => 'Add New', 'stampede item',             'add_new_item' => 'Add New Member',             'edit_item' => 'Edit Member',             'new_item' => 'New Member',             'view_item' => 'View Member',             'search_items' => 'Search Member',             'not_found' => 'Nothing found',             'not_found_in_trash' => 'Nothing found in Trash',             'parent_item_colon' => ''         );              $args = array(             'labels' => $labels,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,             'query_var' => true,             'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',             'rewrite' => true,             'capability_type' => 'post',             'hierarchical' => false,             'has_archive' => true,             'menu_position' => null,             'supports' => array('title','editor','thumbnail','excerpt',)                );               register_post_type( 'stampedemember' , $args );          register_taxonomy("Location", array("stampedemember"), array("hierarchical" => true, "label" => "Location", "singular_label" => "Location", "rewrite" => true));


title: Javascript stopped working

text: For some reason, the scripts that I have set up on my wordpress install stopped working yesterday afternoon. I had been editing things, but I'm not sure what I could have done that caused it to stop. Is there any way that I can error check why it's not working, or any common reasons why it might not be? The site is up at http://www.delsilencio.net/staging/wordpress/


title: What if I have a large file on the server that I want the wp library to have?

text: I have one server that has wordpress in the root directory. However before I installed wordpress, I also have (root)/videos. I'm sure I can move this folder anywhere, however I want to move it to a place so wordpress can add it to its media library. This way, I can easily select it. I don't want (and I can't) re-upload these large video files through the wordpress upload. Thank you


title: How can I search for a worpress user by display name or a part of it?

text: I need to create a search page that will display anything related to the supplied search. i.e. `comments` containing it, `events`, `posts`, `CPT`s and `users` with that name. > How can I search for users in the site who's first or last name contains the > search phrase ?


title: How to obtain the link/URL to the feed of a custom taxonomy?

text: What I need to accomplish is to provide a feed link for every item in a custom taxonomy. The function `get_category_feed_link` only works for categories, and I don't see that tags support this either. How to obtain the feed for a custom taxonomy item? Does exists something like `get_taxonomy_feed_link(<your_custom_taxonomy_name>, <your_custom_taxonomy_item_id>)`. Thanks!


title: Saving zero in meta box

text: So I have created a meta box for a review rating. Sometimes the value of the rating (out of 5) is zero. When you enter a 0 into the input and save the data, it doesn't process because of the fact 0 also means false in the statement:               if ($meta_value) ...      I was wondering if anyone knew a way to save the zero value? The only answer I have found is to enter 0x0 and then convert it (as per: http://wordpress.stackexchange.com/a/96536/17411), but for users it seems like a confusing task to explain, and then for them to remember.. * * * This is my save_meta:               function save_custom_meta($post_id) {         global $meta_review_fields_1;          // Verify nonce     if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__)))            return $post_id;            // Check autosave     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)         return $post_id;          // Check permissions     if ('page' == $_POST['post_type']) {         if (!current_user_can('edit_page', $post_id))             return $post_id;         } elseif (!current_user_can('edit_post', $post_id)) {             return $post_id;     }               // Loop and save: Review     foreach ($meta_review_fields_1 as $field_1) {         $old_1 = get_post_meta($post_id, $field_1['id'], true);         $new_1 = $_POST[$field_1['id']];         if ($new_1 && $new_1 != $old_1) {             update_post_meta($post_id, $field_1['id'], $new_1);         } elseif ('' == $new_1 && $old_1) {             delete_post_meta($post_id, $field_1['id'], $old_1);         }     }      Mind you, I need it to delete the content of other fields if empty, just the rating input that should allow the value of 0.


title: How to get attachment id of background image?

text: I'm looking for a way to get the ID of the background_image when I am using custom headers? I tired using `url_to_postid` like this:               $url = get_header_image()     $postid = url_to_postid( $url );      and $url = get_theme_mod('header-image') $postid = url_to_postid( $url ); I got a null value for both, which I realized is because both `get_header_image()` and `get_theme_mod('header-image')` return the url in the form of example.com/wp-content/uploads... but what `url_to_postid` needs is example.com/?attachment_id=#. I also thought about `get_theme_mods();` but it only returns the long url for background image. Not the shorter url or the ID. It does give the id for the header image though, grrr. What am I missing here? For the record I'm doing this so I can get the background image with `wp_get_attachment_image_src()` in a dynamic stylesheet and use the $size arg, with some custom sizes to return a different size depending on the screen size. That way I can do full screen backgrounds without having to load and scale down some massive image for a phone's screen. Alternative solutions to my actual problem are more than welcome.


I have a transient set for a custom query. It expires in 30 days. But I also need it to expire once a new post/page is published. So that the new published post/page is available in that custom query. How to delete a transient on post/page publish? How I set the transient:               // Get any existing copy of our transient data        if ( false === ( $query = get_transient('d_results') ) ) {         // It wasn't there, so regenerate the data and save the transient         $randargs = array("post_type"=>"", "orderby"=>"", "order"=>"", "posts_per_page"=>-1);         $query = new WP_Query($randargs);         set_transient( 'd_results', $query, DAY_IN_SECONDS * 30);        }