title: pre_get_posts works in post type archive but not in single post

text:
I have a custom post type "Scholars" that has an archive. I want to sort by a custom meta field called "year", I'm doing this with `pre_get_posts`:               add_action('pre_get_posts', 'my_queries');     function my_queries($query)     {       if (!$query->is_main_query()) return;            if ($query->query['post_type'] == 'scholars') {         $query->set('posts_per_page', -1);         $query->set('meta_key', 'year');         $query->set('orderby', 'meta_value');       }     }      This works fine in the archive page (the main listing), but the `next_post_link` and `previous_post_link` are not in sync in the single post. They are still sorted by date and not by custom "year". I have a custom query on the single page using `WP_Query` to show related posts, but I tried removing it and still does not work. This is the archive page:
       <?php         if (have_posts()) {           while (have_posts()) {             the_post();             // this just loads an
             get_template_part('content', 'scholars');           }         } else {           echo '
Nothing found.
';         }       ?>
      And this is the single page:               <?php the_post() ?>
                <?php previous_post_link() ?>
<?php the_title() ?>
         <?php next_post_link() ?>

       <img src="<?php the_field('photo') ?>" alt="" />
<?php the_field('year') ?> Scholar

      Any ideas why it won't work? **Edit:** After looking at other related answers seems like this is not possible with the built-in function out of the box, found this plugin but I'm open to any solution. **Edit:** Pfff, it doesn't even work with that plugin, don't know what the issue is:               next_post_link_plus('meta_key=year&order_by=numeric')


title: Is it possible to have screenshots in any other section rather than the screenshots section?

text: At WordPress.org plugin, is it possible to have screenshots in any other section rather than the screenshots section? For example. Can I create a section called "Manual" and then have some screenshots there?


title: Create Landing Page With Login or Subscribe Form

text: I am trying to create a landing page with a subscribe or register/login form that does the following:   * Redirects new users to a different page after registering (or subscribing),   * Redirects returning users to page after login (or after re-entering their email address),   * Automatically subscribes users to my mailchimp rss list. I am using the plugin MailChimp for WP right now and it redirects new subscribers to a new page but not returning ones. Is there a way I can do this with this plugin? If not, what plugin(s) can I use to make all of these things happen? I need to have this landing page finished by Saturday 8/10/13.


title: how can I change the background color of all posts on my server?

text: The default for the theme I'm using is to have a white background for any post (the part with the text, not the background that forms the border around it) on my wordpress installation. Is there a way I can set the the background for all pages in one shot. I've tried adding the following css:               p     {         background: #91C3C1;     }      but it only changes the background color for the paragraphs. What element should I be changing? (in this case I'm using the "Responsive" theme from CyberChimps)


title: If more than 1 image show post link?

text:
I have an image gallery of sorts its displayed on the page using the following template code...                <?php             $featured = get_post_meta($post->ID,'_thumbnail_id',true);             $attachments = get_children( 'post_type=attachment&orderby=menu_order&exclude='.$featured.'&post_mime_type=image&post_parent='.$post->ID ); ?>
            <?php foreach ($attachments as $attachment) {                  $img = wp_get_attachment_image_src($attachment->ID);         $img_large = wp_get_attachment_image_src($attachment->ID, 'full'); ?>
<a rel="example" href="<?php the_permalink() ?>"><img class="fac-img" src="<?php echo $img[0] ?>" width="<?php echo $img[1] ?>" height="<?php echo $img[2] ?>" />
            <?php } ?>
      The image linking to the main single page of the post. Now is there any way that one there is only 1 image attached it doesn't show the link? So you attach one image to the post it shows it on its own. If however, you upload more than one image it adds the link around that image a long with link text 'click to view more images' or whatever. Clicking that takes you to a new single.php page where all the images are there running a gallery js script which is already done. Possible or not? Thank you for any help.


title: How to remove header image in Twenty Eleven theme?

text: Please give me details on how to remove the custom header image in the Twenty Eleven theme.


title: Why is my working Custom Taxonomy not in get_taxonomies array?

text: I've created a custom taxonomy. It's working just as expected, aside from it is not showing in the `get_taxonomies` array. `get_terms` function returns an `invalid taxonomy` error. I want to use `get_terms` to loop through the Double India Pale Ales and print each name for a select box. Here is the code used to register it.               add_action( 'init', 'double_ipa_init' );          function double_ipa_init()  {         register_taxonomy(             'double-ipa',             array (                 0 => 'post',                 1 => 'page',             ),             array(                 'hierarchical' => true,                 'label' => 'Double IPAs',                 'show_ui' => true,                 'query_var' => true,                 'rewrite' => array(                     'slug' => 'double-ipa'                 ),             'singular_label' => 'Double IPA'             )         );     }      This code is in a plugin, and is on Multisite. Thanks in advance for your help.


title: 404 on pagination but with a strange twist (error 404 only when there is single post on the second page)

text:
I have a weird problem I'm having hard time understanding. Pagination gives me error 404 when I click page #3 when there is only 1 post on that page. If I add 1 more so that on page #3 there are minimum 2 posts error goes away! Any way to diagnose this issue? My code is this:                               //default values                     if ( !isset ($_POST['lolpp']) ) { $listing_order_logic_perpage = 'date'; }                     if ( !isset ($_POST['lopp']) ) { $listing_order_perpage = 'DESC'; }                     if ( !isset ($_POST['lpp']) ) { $listing_per_page = 6; }                 ?>

                          <?php                             //calculating offset depending on number of featured listing, lets create variable first                             $count_featured_offset = 0;                                   //featured listing loop                         query_posts( 'order=DESC&orderby=date&posts_per_page=2&post_type=post&cat='.$current_category_id.'&meta_key=featured&meta_value=yes' );                         if ( have_posts() ) : while ( have_posts() ) : the_post();                         //lets save ID of listing which is featured to later exclude it from normal loop                         $do_not_duplicate[] = $post->ID;                     ?>

                                                        <a href="<?php the_permalink(); ?>">                                                 <?php                                                      if ( has_post_thumbnail() ) {                                                         echo get_the_post_thumbnail($post->ID, 'thumbnail', array('alt' => the_title('','',false), 'title' => get_the_excerpt(), 'class' => 'primarythumb' ));                                                     } else {                                                         echo '';                                                 } ?>
<a class="title" href="<?php the_permalink(); ?>"><?php the_title(); ?>
                                              <?php                                           echo "
".__(get_post_meta($post->ID, 'Address', true))."
";                                           echo ''.get_post_meta($post->ID, 'Phone', true).'';                                                  $link = get_post_meta($post->ID, 'url', true);                                                  if ( $link ) {                                               echo ''.__('Official Website','holidayge').'';                                             } else {                                               echo ''.__('Official Website','holidayge').'';                                             }                                         ?>
<?php echo trim(strip_tags($post->post_excerpt)); ?>

                                                                 <?php echo ( wp_gdsr_rating_article()->votes ); ?> <?php _e('users rated','holidayge'); ?>
<?php if(function_exists('wp_gdsr_render_article')){ wp_gdsr_render_article();}?>

                                                                 <?php _e('Number of reviews','holidayge'); ?>                                                                 <a href="<?php echo get_permalink();?>#comments"><?php comments_number( '0', '1', '%' ); ?>

                          <?php                             //increment featured count offset variable                             $count_featured_offset++;                              endwhile;                          endif;                     ?>                          <?php wp_reset_query(); ?>                                         <?php                         //here we calculate correct offset depending on number of featured listings 2 1 0                         $listing_per_page = $listing_per_page - $count_featured_offset;                              //count to insert ads after nth post, 5th place in this example                         $adspostnum = 1;                         $adsshowpos = 1;                              //normal listing loop                         $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                         query_posts( array( 'order' => $listing_order_perpage, 'orderby' => $listing_order_logic_perpage, 'posts_per_page' => $listing_per_page, 'post_type' => 'post', 'cat' => $current_category_id, 'post__not_in' => $do_not_duplicate, 'paged' => $paged ) );                         if ( have_posts() ) : while ( have_posts() ) : the_post();                     ?>
                                                  <a href="<?php the_permalink(); ?>">                                                     <?php                                                          if ( has_post_thumbnail() ) {                                                             echo get_the_post_thumbnail($post->ID, 'thumbnail', array('alt' => the_title('','',false), 'title' => get_the_excerpt(), 'class' => 'primarythumb' ));                                                         } else {                                                             echo '';                                                     } ?>
<a class="title" href="<?php the_permalink(); ?>"><?php the_title(); ?>
                                                  <?php                                               echo "
".__(get_post_meta($post->ID, 'Address', true))."
";                                               echo ''.get_post_meta($post->ID, 'Phone', true).'';                                                      $link = get_post_meta($post->ID, 'url', true);                                                      if ( $link ) {                                                   echo ''.__('Official Website','holidayge').'';                                                 } else {                                                   echo ''.__('Official Website','holidayge').'';                                                 }                                             ?>
<?php echo trim(strip_tags($post->post_excerpt)); ?>

                                                                     <?php echo ( wp_gdsr_rating_article()->votes ); ?> <?php _e('users rated','holidayge'); ?>
<?php if(function_exists('wp_gdsr_render_article')){ wp_gdsr_render_article();}?>

                                                                     <?php _e('Number of reviews','holidayge'); ?>                                                                     <a href="<?php echo get_permalink();?>#comments"><?php comments_number( '0', '1', '%' ); ?>

                          <?php                         //in betweeen listing advertising goes here                         if ( $adspostnum == $adsshowpos ) {                         ?>

              <?php //echo adrotate_block(2); ?>              <a href="<?php echo get_permalink( 11 ); ?>"><?php echo get_the_title( 11 ); ?>

                         <?php } $adspostnum++;                                        endwhile;                          endif;                     ?>

                <?php wp_pagenavi(); ?>


title: Pass get_option value to an array

text: I want to pass get_option value to an array value. This the value that I want to pass to the array.               <?php echo stripslashes(get_option('a')); ?>      and this is what I am trying to do.               <?php $var = array( 'foo' =>'echo stripslashes(get_option('a'));');      Please let me know how can I achieve this.


title: Sort X categories by last update and show image

text: I want to display X categories, and sort them by last update. I also want to grab the image of the latest post with the category.               <img src="<?php echo get_image('article_image',1,1,0,NULL,$res75); ?>" />      So, the category list will be displayed by images, with the corresponding category-name underneath. Sorted by last update. How would I go about doing that?


title: Getting URL of archive (category) page

text: I'm trying to retrieve the current URL of the page, which works everywhere except for archive pages, for example, a category page. On a category page, it shows as the most recent post in that category.               $this_id = $wp_the_query->get_queried_object_id();     $this_url = get_permalink($this_id);     echo $this_url; // Should show like: http://domain.com/blog/category      How do I retrieve the actual archive page URL?


title: Getting the ID of any image for use in functions.php

text:
I've added two custom fields to attachments on my site, so the user can add a special image credit. I'm trying to write a function that looks to see if either of the custom fields are populated, and if so echoes the contents. The part I'm struggling with is getting the ID of the image into the function - it's simple enough for featured images using `get_post_thumbnail_id()` \- is there a similar way to get the ID for _any_ attached image? Here's what I have so far:                   function mat_image_credit() {              //this is the bit I'm struggling with:         $mat_image_id = wp_get_attachment_image( $attachment->ID );               //this is collecting the contents of the custom field and works fine         $mat_flickr_credit = slt_cf_field_value('flickr_credit', 'attachment', $mat_image_id);               $mat_custom_credit = slt_cf_field_value('custom_credit', 'attachment', $mat_image_id);              //and then this echoes out the contents depending on what we find...         if (!empty ( $mat_flickr_credit ) ) {              echo '
Image by ' . $mat_flickr_credit . '
';          } elseif ( !empty ( $mat_custom_credit ) ) {              echo '
Image by ' . $mat_custom_credit . '
';          };          }      Thanks!


title: Add a #hash to the links in my custom menu

text: I have created a static frontpage where I load in the content of all my pages. Now I have a normal custom menu, but the links refer to the pages, for example: http://mysite.com/about Now the I want to have the link directed to the page itself with http://mysite.com/#about. Now I have a custom walker that I use, and I have tried the following code:               $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( get_bloginfo('url').'#'.$item->title ) .'"' : '';      Now this works ok, except for the home link itself. The home links to http://mysite.com/#home, but that one just needs to link to http://mysite.com/# Is there something different I could use then `$item->title` to append. \-- If you want to know the method that I use to create the single page:   Creating the modern 'single page' html5 css3 layout in wordpress > =============== **_Update_** =================== Just wanted to tell you guys what i did, maybe it helps someone. Pages are structured like this:               Home      (public)  -> cutom menu item -> [link:#][label:home]     portfolio (private) -> cutom menu item -> [link:#portfolio][label:portfolio]     contact   (private) -> cutom menu item -> [link:#contact][label:contact]     blog      (public)  -> page menu item  -> [link:blog][label:blog]      Home and blog will be indexed and visible. portfolio and contact are loaded in home which is a front_page.php. Note that I use _relative links_ , and not absolute, html output will be href="#contact". Now having it like this will conflict on the blog page, the links will become http://mysite.com/blog/#contact. We don't want that, we want just http://mysite.com/#contact In my default walker I am going to edit edit in the absolute path. I do it here just to make the template a little more dynamic.               if($item->object == 'custom'){         $attributes .= ! empty( $item->url ) ? ' href="' .         esc_attr(get_bloginfo('url').'/'.$item->url ) .'"' : '';     }else{         $attributes .= ! empty( $item->url ) ? ' href="' .          esc_attr( $item->url ) .'"' : '';     }      Source to the complete walker can be found here: Menu items description? Now the next thing is 1) to have a nice scroll effect (jquery scrollto) when the links are clicked on the frontpage 2) be redirected to the blog when the blog link is clicked 3) be redirected back to the right section when a hashlink is clicked on the blogpage. Script for jQuery               $(document).ready(function() {       $('.menu-item-object-custom a').bind('click', function(e) {         e.preventDefault();         var parts = ($(this).attr("href")).split("#");         var target = '#' + parts[1];              if($('body.home').length){           var moveto = $(target).length ? $(target).offset().top : 0;           $('html, body').stop().animate({ scrollTop: moveto }, 1500, function() {             location.hash = target;           });           return false;         }else{             window.location = $(this).attr("href");         }       });     });      Note that the url in the browser is also changed, so the back button works also, and there is easy bookmarking. Thanks for all the suggestions and inspiration bellow!! And I hope someone can use this.


title: trying to list users & display first - last name

text:
For some reason this is not working for me :(               $get_members = array(         'blog_id' => $GLOBALS['blog_id'],         'role' => 'sm_flagar',     );          $blogusers = get_users($get_members);         foreach ($blogusers as $user) {             echo "
user_url."\">". $user->first_name ." ". $user->last_name ."
";         }


title: Wrap Featured Image in a Link

text: I want to wrap a link around a featured image (only if the custom meta box has been filled in), the link will come from a custom meta box. Here's my image code: `the_post_thumbnail('screenshot');` Here's my code for displaying the link using text:               <?php //Only if $urllink is filled in, display this link. ?>       <?php $urlbox = get_url_desc_box();         if ( !empty( $urlbox[0] ) ) {           echo sprintf( 'Visit Website »', $urlbox[0] );     } ?>      I've tried a few ways to get this to work but can't figure it out. Any help would be greatly appreciated.


title: WP MS: How to query over the network

text: I have a WP 3.8.1 Multisite installation with 3 blogs, they're all in one db, prefixed `wp_`, `wp_2_` and `wp_3_`. In a template in `wp_` I try to to display all posts from `wp_`, `wp_2_` and `wp_3_` which have a category _xxx_ attached. I want to display the posts chronologically. I tried this query:               SELECT *      FROM $wpdb->posts         INNER JOIN $wpdb->term_relationships ON $wpdb->posts.ID= $wpdb->term_relationships.object_id         INNER JOIN $wpdb->term_taxonomy ON $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id         INNER JOIN $wpdb->terms ON $wpdb->term_taxonomy.term_id=$wpdb->terms.term_id WHERE $wpdb->terms.name = 'xxx'     ORDER BY $wpdb->posts.post_date DESC      This works only for the current blog, ie it doesn't include `wp_2_` and `wp_3_`. How do I retrieve all posts with category _xxx_ from `wp_`, `wp_2_`, `wp_3_` (instead of only `wp_`)?


title: How to display a feature only if custom field value is set?

text: What i'm trying to do here is to modify the existing wp-postratings plugin. The function to display the ratings is:               <?php if(function_exists('the_ratings')) { the_ratings(); } ?>      However, the above code displays the ratings on every post. What would be the conditional statement to add such that if a post has a custom field with name/value as ratings/yes This way, based on the conditional statement, the ratings would be displayed only on posts where the custom field has the ratings/yes added.


title: Getting index.php instead single.php for displaying posts

text:
I'm (locally) building a custom theme. So far I have:   * index.php   * single.php   * page.php   * custom page template called about-page.php   * two different headers: one for default use and one for the single.php NO functions.php; NO custom taxonomy; Permalink settings > Common settings : default My index.php has a list of posts (all of those belonging to a specified category), when I click on one of those posts I end to the index.php BUT with the right custom header (header I created for the posts, it's called header- single.php). **So, I'm getting the index.php istead of the single.php** I read around other people had the same problem with the word "year" or some other Reserved Terms. I don't think it's my case. In my home page I have:               <?php     /**      * Template Name: Front Page Template      */     get_header(); ?>
                 <?php                     $lastposts = get_posts('numberposts=20&orderby=date&cat=9');                     foreach($lastposts as $post) :                     setup_postdata($post);                     ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a
                     <?php endforeach; ?>
          <?php get_footer(); ?>      EDIT Here's the structure of my single.php               <?php     /*      Template Name: Single project       */     get_header(); ?>
        //something

         READ

             CLOSE

             <?php the_content(); ?>

     <?php get_footer(); ?>      Looking forward for some clues!   Thank you very much!   Best,   L


title: Gettind 404 not found wen click the view button for a given category custom post type portfolio

text: I have created a custom post type portfolio and custom categories. Everything is working fine as expected however when I click into the custom post types categories and click the view button for a given category the page that comes up isn't listing the results eror 404. For example, if the post type is "portfolio" and the category is "web-design" When I click the view button for this category I would suspect to see a page with all the web-design post... Not sure what I am doing wrong here. Code generate with http://generatewp.com/                // Register Custom Post Type      function portfolio_post_type() {               $labels = array(         'name'                => _x( 'Portfolios', 'Post Type General Name', 'owd' ),         'singular_name'       => _x( 'Portfolio', 'Post Type Singular Name', 'owd' ),         'menu_name'           => __( 'Portfolio', 'owd' ),         'parent_item_colon'   => __( 'Parent Portfolio:', 'owd' ),         'all_items'           => __( 'All Portfolios', 'owd' ),         'view_item'           => __( 'View Portfolio', 'owd' ),         'add_new_item'        => __( 'Add New Portfolio', 'owd' ),         'add_new'             => __( 'New Portfolio', 'owd' ),         'edit_item'           => __( 'Edit Portfolio', 'owd' ),         'update_item'         => __( 'Update Portfolio', 'owd' ),         'search_items'        => __( 'Search portfolios', 'owd' ),         'not_found'           => __( 'No portfolios found', 'owd' ),         'not_found_in_trash'  => __( 'No portfolios found in Trash', 'owd' ),     );     $args = array(         'label'               => __( 'portfolio', 'owd' ),         'description'         => __( 'Portfolio information pages', 'owd' ),         'labels'              => $labels,         'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'custom-fields', ),         'hierarchical'        => true,         'public'              => true,         'show_ui'             => true,         'show_in_menu'        => true,         'show_in_nav_menus'   => true,         'show_in_admin_bar'   => true,         'menu_position'       => 5,         'menu_icon'           => get_stylesheet_directory_uri() . '/images/portfolio.png',         'can_export'          => true,         'has_archive'         => true,         'exclude_from_search' => false,         'publicly_queryable'  => true,         'capability_type'     => 'page',     );     register_post_type( 'portfolio', $args );     flush_rewrite_rules();     // http://dreamdare.org/tips-tricks/how-to-fix-wordpress-custom-post-type-permalink-404-error/      } add_action( 'init', 'portfolio_post_type', 0 ); // Register Custom Taxonomy function custom_taxonomy_portfolio() {               $labels = array(         'name'                       => _x( 'Portfolio Categories', 'Taxonomy General Name', 'owd' ),         'singular_name'              => _x( 'Portfolio Category', 'Taxonomy Singular Name', 'owd' ),         'menu_name'                  => __( 'Portfolio Category', 'owd' ),         'all_items'                  => __( 'All Portfolio Category', 'owd' ),         'parent_item'                => __( 'Portfolio Category', 'owd' ),         'parent_item_colon'          => __( 'Parent Portfolio Category:', 'owd' ),         'new_item_name'              => __( 'New Portfolio Category', 'owd' ),         'add_new_item'               => __( 'Add Portfolio Category', 'owd' ),         'edit_item'                  => __( 'Edit Portfolio Category', 'owd' ),         'update_item'                => __( 'Update Portfolio Category', 'owd' ),         'separate_items_with_commas' => __( 'Separate portfolio categories with commas', 'owd' ),         'search_items'               => __( 'Search Portfolio Category', 'owd' ),         'add_or_remove_items'        => __( 'Add or remove Portfolio Category', 'owd' ),         'choose_from_most_used'      => __( 'Choose from the most used portfolio category', 'owd' ),         'not_found'                  => __( 'Not Found Portfolio Category', 'owd' ),     );     $rewrite = array(         'slug'                       => 'portfolio',         'with_front'                 => false,         'hierarchical'               => true,     );     $capabilities = array(         'manage_terms'               => 'manage_categories',         'edit_terms'                 => 'manage_categories',         'delete_terms'               => 'manage_categories',         'assign_terms'               => 'edit_posts',     );     $args = array(         'labels'                     => $labels,         'hierarchical'               => true,         'public'                     => true,         'show_ui'                    => true,         'show_admin_column'          => true,         'show_in_nav_menus'          => true,         'show_tagcloud'              => true,         'rewrite'                    => $rewrite,         'capabilities'               => $capabilities,     );     register_taxonomy( 'portfolio_category', array( 'portfolio' ), $args );      } // Hook into the 'init' action add_action( 'init', 'custom_taxonomy_portfolio', 0 ); I have archive-portfolio.php and taxonomy-portfolio_category.php


title: Show Twitter followers count snippets don't work

text: No matter what I try I can't seem to get the code snippets to work that will display the number of followers of Twitter. I tried various ones as the Plugin I'm using is not showing the Twitter number at all, so I need to look for alternatives. When I tried this snippet, for example, I got the following error message: http://pastebin.com/iif9g35a Anybody any idea what's going wrong here? I think it's strange that the "Suscribers to text" plugin doesn't display the number of followres to begin with - otherwise I wouldn't have to look for alternatives.


title: Redirect current user to their most recent custom post

text: Is there a way that, if a user tries to access a particular page, they are redirected to their most recent post (In a custom post type)? Or, if the user has no posts, redirect them to the homepage?


title: register_post_type not working in wordpress 3.6

text: I am using WP3.6 and am having trouble adding a new post type. I have put echo statements in the code and know that a) the function calling register_post_type gets called b) the post type name i am using does not exist c) register_post_type returns an object with all the values I specified But at the end of it all, nothing happens. No UI is added. Nothing seems to gets registered. Below is my entire code:               function responsive_custom_init_as() {       $labels = array(         'name' => 'Products',         'singular_name' => 'Product',         'add_new' => 'Add New',         'add_new_item' => 'Add New Product',         'edit_item' => 'Edit Product',         'new_item' => 'New Product',         'all_items' => 'All Products',         'view_item' => 'View Product',         'search_items' => 'Search Products',         'not_found' =>  'No products found',         'not_found_in_trash' => 'No products found in Trash',          'parent_item_colon' => '',         'menu_name' => 'Products'       );            $args = array(         'label' => 'Products',         'labels' => $labels,         'description' => 'Products imported from 1shoppingcart.com',         'public' => true,         'publicly_queryable' => true,         'show_ui' => true,          'show_in_menu' => true,          'query_var' => 'product',         'rewrite' => array( 'slug' => 'products', 'with_front' => false ),         'capability_type' => array('onesc_product', 'onesc_products'),         'capabilities' => array('edit_onesc_products' => false, 'publish_onesc_products' => true, 'read_private_onesc_products' => true),         'has_archive' => false,          'hierarchical' => false,         'menu_position' => 5,         'supports' => array('title', 'editor', 'thumbnail', 'excerpt'),         'map_meta_cap' => true,         'register_meta_box_cb' => 'add_onesc_meta_boxes_as'       );             register_post_type('onesc_product', $args);     }          function add_onesc_meta_boxes_as() {       add_meta_box('1sc_product_details', 'Product Details', 'responsive_add_field_as', 'onesc_product', 'normal', 'default', array('1sc_id', 'Id'));       add_meta_box('1sc_product_details', 'Product Details', 'responsive_add_field_as', 'onesc_product', 'normal', 'default', array('1sc_visibleid','Visible Id'));       add_meta_box('1sc_product_details', 'Product Details', 'responsive_add_field_as', 'onesc_product', 'normal', 'default', array('1sc_sku', 'SKU'));       add_meta_box('1sc_product_details', 'Product Details', 'responsive_add_field_as', 'onesc_product', 'normal', 'default', array('1sc_price', 'Price'));       add_meta_box('1sc_product_details', 'Product Details', 'responsive_add_field_as', 'onesc_product', 'normal', 'default', array('1sc_isfeatured', 'Is Featured', 'checkbox'));       add_meta_box('1sc_product_details', 'Product Details', 'responsive_add_field_as', 'onesc_product', 'normal', 'default', array('1sc_usesaleprice', 'Use Sale Price', 'checkbox'));       add_meta_box('1sc_product_details', 'Product Details', 'responsive_add_field_as', 'onesc_product', 'normal', 'default', array('1sc_saleprice', 'Sale Price'));       add_meta_box('1sc_product_details', 'Product Details', 'responsive_add_field_as', 'onesc_product', 'normal', 'default', array('1sc_isactive', 'Is Active', 'checkbox'));       add_meta_box('1sc_product_details', 'Product Details', 'responsive_add_field_as', 'onesc_product', 'normal', 'default', array('1sc_hairtype', 'Hair Type'));       add_meta_box('1sc_product_details', 'Product Details', 'responsive_add_field_as', 'onesc_product', 'normal', 'default', array('1sc_length', 'Length'));       add_meta_box('1sc_product_details', 'Product Details', 'responsive_add_field_as', 'onesc_product', 'normal', 'default', array('1sc_style', 'Style'));       add_meta_box('1sc_product_details', 'Product Details', 'responsive_add_field_as', 'onesc_product', 'normal', 'default', array('1sc_color', 'Color'));     }          function responsive_add_field_as($post, $customid, $customlbl, $type='text'){       $value = get_post_meta($post->ID, $customid, true);       echo '<label for="'.$customid.'">'.$customlbl.'</label> ';       echo '<input type="'.$type.'" id="'.$customid.'" name="'.$customid.'" value="'.esc_attr($value).'" size="25" />';     }          add_action( 'init', 'responsive_custom_init_as' );      Any ideas?


title: Custom field drop down to set the term of the post when published

text: In my functions.php i'm trying to check if the user has selected a value in a custom field drop down and then set that value as the term of the post when it's published. I'm using the following function but it doesn't seem to work. Although if i select a term from the custom taxonomy check list and publish the post the term doesn't get saved. So i guess i'm close? No?               function artist_term_save( $post_ID ){              // Bail if we're doing an auto save         if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;              //check if they selected your state term         $artist = isset($_POST['magicfields[shop_artist][1][1]']) ? $_POST['magicfields[shop_artist][1][1]'] : ''; //make sure of what the input name is here...              //insert post meta         wp_set_object_terms($post_ID, $artist, 'byartist');     }      Note: magicfields[shop_artist][1][1] is the name of the select drop down in the HTML.


title: Changing the wp-config.php broke the site

text: I added the lines `define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/blog/wp-content' );` and `define( 'WP_CONTENT_URL', 'example/blog/wp- content';);` in my wp-config.php and then my site broke. Even some of the widgets on the backend do not appear anymore. I immediately removed the above lines from the `wp-config.php` however that did not change anything. PLEASE HELP


title: Create dropdown list post

text: I want to create a drop down list that will list all the posts in the category. I want the drop down list to appear on every post. So for example if I view a post that belongs to category Apples it should list all posts in category Apples


title: What's the proper WordPress URL for the template of my custom taxonomy?

text: I have a CPT called "books", a custom taxonomy called "book" for this CPT, and a "taxonomy-books.php" template in which I display my "books" terms using get_terms(). I don't understand (yes, I googled the problem) how to visit the page attached to this template. For one, "www.my_site.com/books/" doesn't work (page not found). Here's how I defined my custon taxonomy:               $labels = array(         'name'                          => 'Books',         'singular_name'                 => 'Book',         'search_items'                  => 'Search Books',         'popular_items'                 => 'Popular Books',         'all_items'                     => 'All Books',         'parent_item'                   => 'Parent Book',         'edit_item'                     => 'Edit Book',         'update_item'                   => 'Update Book',         'add_new_item'                  => 'Add New Book',         'new_item_name'                 => 'New Book',         'separate_items_with_commas'    => 'Separate Books with commas',         'add_or_remove_items'           => 'Add or remove Books',         'choose_from_most_used'         => 'Choose from most used Books'         );          $args = array(         'label'                         => 'Books',         'labels'                        => $labels,         'public'                        => true,         'hierarchical'                  => true,         'show_ui'                       => true,         'show_in_nav_menus'             => true,         'args'                          => array( 'orderby' => 'term_order' ),         'rewrite'                       => array( 'slug' => 'books', 'with_front' => false ),         'query_var'                     => true     );          register_taxonomy( 'books', 'book', $args );      So articles online made me think that the "rewrite" line was in cause, I removed it and it's the same.


title: Cannot display default template after switching to custom

text: I'm having a strange issue with a page. The site has a Default Template (page.php) and several custom templates. A page was created using a custom template (page-services.php), but then later switched to use the Default Template (all via Admin Page Attributes). However, the page's front end continues to pull the custom template instead of the selected Defaul Template. The back end is correct (there are different custom fields depending on the template). The edit page view shows the correct custom fields for the template selected. I can't think of any other details that might be relevant.


title: RSS Subscriber count

text: I'm looking to retrieve an RSS Subscription count. How do I return the number of subscribers without use of Feedburner or use of a plugin?


title: save_post + insert_post = infinite loop

text: I'm trying to automatically create a new post when a post containing a certain custom field is saved - hooking an insert_post function into save_post. This generates an infinite loop. I found some answers to this problem, suggesting I should check the post type before inserting. However, the following code still gives an infinite loop, any ideas?               add_action('save_post', 'createGallery');          function createGallery () {         global $post;         if ( $post->post_type == 'activity' ) {             $gallerypost = array(                 'post_content' => 'the text of the post',                 'post_status' => 'publish',                  'post_title' => 'Photo album',                  'post_type' => 'post',                  'post_author' => 1);               wp_insert_post( $gallerypost );         }     }


title: Storing Dropbox Authentication?

text: I am trying to create a Wordpress plugin that exports each blog post to my dropbox folder. The code is below but I have a problem. If I run this code outside Wordpress, it works perfectly. The table is created and my token is stored. If I use a different browser it works perfectly...no authentication because it reads from the DB. My problem is that when I put this into my plugin, the table is not created at all. So if I go to a different browser, I have to re-authenticate. Help please. Code:               /*      * Copyright 2012 Erin Dalzell.      *      */          require_once('Dropbox/API.php');     require_once('Dropbox/Exception.php');     require_once('Dropbox/OAuth/Consumer/ConsumerAbstract.php');     require_once('Dropbox/OAuth/Consumer/Curl.php');     require_once('Dropbox/OAuth/Storage/Encrypter.php');     require_once('Dropbox/OAuth/Storage/StorageInterface.php');     require_once('Dropbox/OAuth/Storage/Session.php');     require_once('Dropbox/OAuth/Storage/Filesystem.php');     require_once('Dropbox/OAuth/Storage/PDO.php');          include ABSPATH . '/wp-config.php';          function etd_initialize() {          global $current_user;              // Set your consumer key, secret and callback URL         // should be in the settings         $key      = 'xxxxx';         $secret   = 'yyyyy';         $current_user = wp_get_current_user();              // Check whether to use HTTPS and set the callback URL         $protocol = (!empty($_SERVER['HTTPS'])) ? 'https' : 'http';         $callback = $protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];                   // Instantiate the Encrypter and storage objects         $encrypter = new \Dropbox\OAuth\Storage\Encrypter('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');              // Instantiate the database data store and connect         $storage = new \Dropbox\OAuth\Storage\PDO($encrypter, 1);         $storage->connect(DB_HOST, DB_NAME, DB_USER, DB_PASSWORD);              $storage = new \Dropbox\OAuth\Storage\Session($encrypter);              $OAuth = new \Dropbox\OAuth\Consumer\Curl($key, $secret, $storage, $callback);              $dropbox = new \Dropbox\API($OAuth);              return $dropbox;          }          function export_to_dropbox($id) {         $dropbox = etd_initialize();              $post = get_post($id);                   // Create a temporary file and write some data to it         $tmp = tempnam('/tmp','dropbox');         file_put_contents($tmp, $post->post_content);              // Upload the file with an alternative filename         $put = $dropbox->putFile($tmp, $post->post_title . '.md');              // Unlink the temporary file         unlink($tmp);     }          register_activation_hook( __FILE__, 'etd_initialize' );     add_action('publish_post', 'export_to_dropbox');     ?>


title: I keep getting 404 Error when I attempt to view blog in single view

text: I'm a newbie to Stack Exchange. Hoping to get some answers now and again and maybe help out as well. My question is, I have (2) blog posts, and for some reason the latest one gives me a 404 Error message when I try to view it. See for your self : http://dstac.headbentdesign.com/in-the-news/ I contacted the theme developer and all he did was select the "default" setting for the permalinks. I don't want the post ID, I want the /%postname%/ I hear it could be an .htacces issue, so I contacted my host, but they basically said it wasn't their problem. Good ol' Bluehost. Any ideas guys? Thank you


title: Post form as custom post

text: I'm new to WordPress and need to create a website including a special form, with which I can upload photos, set my position on an OpenStreetMap and choose from several dropdown menus. Here you can find an example of how it should look like: ![enter image description here](http://i.stack.imgur.com/IABAz.png) I already did this:   1. Created a page template with the form `<form id="new_post" name="new_post" method="post" action="" enctype="multipart/form-data">`   2. Made the form submitable for users who are logged in (is this a secure solution?)                  <?php if ( 0 == $current_user->ID ) {                          wp_loginout();                           echo " to submit a post";                     } else {                       echo '<fieldset class="submit">                                 <input type="submit" value="Los" tabindex="40" id="submit" name="submit" />                             </fieldset>                             <input type="hidden" name="action" value="new_post" />';                             wp_nonce_field( "new-post" ); } ?>        3. When the form is submitted this php code is executed:              if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&  $_POST['action'] == "new_post") {             $new_post = array(                 'post_title'    =>  "roadkill entry",                 'post_content'  =>  "testcontent",                 'post_category' =>  array(0),                 'post_status'   =>  'publish',                 'post_type' =>  'roadkills' // this is my custom post   );              $pid = wp_insert_post($new_post);              $link = get_permalink( $pid );         wp_redirect( $link );     }      But I will end in an page not found. http://www.citizen- science.at/wordpress/roadkill/eintrag-hinzufugen/ When I create an entry via the admin GUI I am able to view the single post, but not the archive http://www.citizen-science.at/wordpress/roadkills/dafdf/ Oh yeah, here is how I am registering my post type:               <?php      add_action( 'init', 'create_post_type' );     function create_post_type() {         register_post_type( 'roadkills',             array(                 'labels' => array(                     'name' => __( 'Roadkills' ),                     'singular_name' => __( 'Roadkill' )                 ),             'public' => true,             'has_archive' => true,             )         );     }      What did I miss here? (I already got it working yesterday, but somehow it broke)


title: Echo a div to header.php from functions.php

text:
Within the section of header.php I have a div structure

      ... I want to add a div within "branding" - I can do this easily be editing header.php directly. I also think that I can use functions.php to:               add_action('wp_head', 'add_div' );      ... and then echo in the code. Is there any way at all I can define where the code should be echoed though (i.e. tell the add_div function where it should add the code)?


title: Wordpress within specific sub-directories, implicitly not root

text: I have an existing application running at my website root now. Using .htaccess, would it be possible for a single Wordpress installation to manage sub-directories? For example, /press/, /careers/, /blog/ would be served by Wordpress. The problem is I don't want Wordpress to get served on the root. I suspect something tricky with permalinks and .htaccess. Option 2 for us here is building a CRUD into our app, but we really wanted to use Wordpress (for certain pages).


title: Can't seem to get an else statement correct?

text:
I'm learning my ways in PHP lately and play allot with WP and PHP. I've created a some PHP that fetches some posts with the same 1th tag. This with some help with a tutorial here and there. The thing the tutorial is missing is a message when there is no tag attached to the post. Here is the code:               <?php $tags = wp_get_post_tags($post->ID); if ($tags) { ?>
Related
         <?php $first_tag = $tags[0]->term_id; $args=array(             'tag__in' => array($first_tag),             'post__not_in' => array($post->ID),             'posts_per_page'=>10,             'caller_get_posts'=>1         );?>
             <?php $my_query = new WP_Query($args); if($my_query->have_posts() ) {                 while ($my_query->have_posts()) : $my_query->the_post(); ?>

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

             <?php endwhile; } wp_reset_query();         } ?>
      I thought this would be a solution:               <?php endwhile; else: echo('no tags'); } wp_reset_query(); } ?>      But it's not working, but to be honest... it doesn't seem right at all. I know it's pretty basic, but the if else ifelse while foreach.... sometimes I can't see the wood for the trees. Also I think the:
      is placed wrong. Thanks, /Paul


title: Publish and save specific postmeta to a filtered post_type

text: I have multiple plugins with different post_type(s). When I save or publish, all of the `custom_post_meta` that belong to one specific `post_type` are also saving. I'd like to filter by `post_type` so that the `custom_post_meta` will only save in a specific `post_type`. So my question is, if you have multiple plugins: **How do you save a specific postmeta** to a specific `post_type`? Would you just say:               if (post_type=="my_post_type") {       add_action('save_post','save_my_meta_box_to_postmeta');       add_action('publish_post','save_my_meta_box_to_postmeta');     }      And how do you **get** the `post_type` value?


title: Site does not display translations

text: I installed clean wordpress multisite. Bought a theme, installed woocommerce. Activated stuff, translated some and voila - everything is working. Translations and all. i then uplodaded all the same stuff to my isp. Did all the same things i did at my own computer - but translations are not displayed there. So i started googling things and Some of the posts mentioned that perhaps gettext is not working in the server. So i asked my isp and they said that they can confirm that php gettext is installed and working properly. So how can i test this though? What could be other problems that translations are not working? Alan


title: Wordpress class, using add_action to call member function does not work

text: I'm learning to create a WP plugin as a class. However, it seems the add_action doesn't work when calling my function; it works when using $this->init(). Example:                   class test     {              public $age = NULL;              public function __construct()         {             //register an activation hook             register_activation_hook( __FILE__, array( &$this, 'installplugin' ) );                  add_action('init', array( &$this, 'init' ) ); //this doesn't work             //$this->init(); //This WORKS!              }              function installplugin()         {                  add_option( 'age', 45 );             $this->init();                }              function init()         {                  $age = get_option( 'age' );             $this->age = $age;                        }              function printAge(  )         {             echo "The age is " . $this->age . "<br />";         }          }      So, after running:               $learnObj =  new learnable_test();          $learnObj->printAge();      It only prints: "The age is " But if I were t comment out the add_action('init',...) and use the $this->init(), that seems to work, printing "The age is 45" What am I missing?


title: Tinymce broken after update

text: I've found other posts related to this, but none had a answer to my issue. After updating to WP 3.4 my visual editor is broken. Firebug reports this error               Failed to load: http://xxxxxx.com/wp-includes/js/tinymce/langs/pt.js      wp-tin...9-20805 (linha 1) I've tried setting the theme to a default theme and it WORKS. So, is there any way I can determine what's causing this in order to fix it?


title: Edit the excerpt before it is shown

text: I'm looking for a way the edit the excerpt before it get's show on the page. The issue is this: We import data (jobs) for a third party provider and the content is divided in sections with each a header (e.g. the first one is "Introduction"). The issue now is that in the overview with the post, each excerpt looks like "Introduction. Lorem Ipsum". So I want to manipulate the data to remove "Introduction." Are there any hooks in WordPress that I can utilize to either edit the data before shown, or is there a function that I can overwrite that display's `the_excerpt()`? I'm using a child theme of a theme we bought and would prefer to not mess with the core files.


title: Wordpress search same results no matter what i type

text:
I have strange problem with wordpress. No matter what i type in search box result's are always the same. Last published posts. Tried to disable all plugins, no effect. Here's my searchform.php               <form method="get" id="searchform" action="<?php  echo home_url(); ?>/">
         <input type="text" value="<?php the_search_query(); ?>" name="s" id="s" autocomplete="off" />
     <input type="submit" id="searchsubmit" value="" />
      And my search.php               <?php get_header(); ?>     <?php         $sidebar = get_option(THEME_SHORT_NAME.'_search_archive_sidebar','no-sidebar');         $sidebar_class = '';         if( $sidebar == "left-sidebar" || $sidebar == "right-sidebar"){             $sidebar_class = "sidebar-included " . $sidebar;         }else if( $sidebar == "both-sidebar" ){             $sidebar_class = "both-sidebar-included";         }     ?>     <div class="content-wrapper <?php echo $sidebar_class; ?>">

             <?php                 $left_sidebar = "Search/Archive Left Sidebar";                 $right_sidebar = "Search/Archive Right Sidebar";                              $item_type = get_option(THEME_SHORT_NAME.'_search_archive_item_size', '1/1 Full Thumbnail');                 $num_excerpt = get_option(THEME_SHORT_NAME.'_search_archive_num_excerpt', 200);                 $full_content = get_option(THEME_SHORT_NAME.'_search_archive_full_blog_content', 'No');                      global $blog_div_size_num_class;                 $item_class = $blog_div_size_num_class[$item_type]['class'];                 $item_index = $blog_div_size_num_class[$item_type]['index'];                 if( $sidebar == "no-sidebar" ){                     $item_size = $blog_div_size_num_class[$item_type]['size'];                 }else if ( $sidebar == "left-sidebar" || $sidebar == "right-sidebar" ){                     $item_size = $blog_div_size_num_class[$item_type]['size2'];                 }else{                     $item_size = $blog_div_size_num_class[$item_type]['size3'];                 }                         echo "
";                 echo "
";                      if( have_posts() ){                          echo '
';                          if( $item_type == '1/1 Full Thumbnail' ){                            print_blog_full($item_class, $item_size, $item_index, $num_excerpt, $full_content);                     }else if( $item_type == '1/1 Medium Thumbnail' ){                         print_blog_medium($item_class, $item_size, $item_index, $num_excerpt);                     }else{                         print_blog_grid($item_class, $item_size, $item_index, $num_excerpt);                     }                          echo '
'; // blog-item-holder                          echo '

';                          pagination();                      }else{                          global $gdl_admin_translator;                     if( $gdl_admin_translator == 'enable' ){                         $translator_not_found = get_option(THEME_SHORT_NAME.'_search_not_found',                              'Sorry, but nothing matched your search criteria. Please try again with some different keywords.');                     }else{                         $translator_not_found = __('Sorry, but nothing matched your search criteria.' .                              ' Please try again with some different keywords.','gdl_front_end');                          }                                 echo '
';                     echo '
' . __('Search','gdl_front_end') . '
';                     echo '
';                     echo $translator_not_found;                     echo '
';                                       echo '
';                      }                      echo "
"; // gdl-page-item                      get_sidebar('left');                              echo "
"; // gdl-page-float-left                      get_sidebar('right');                ?>

       Please help. I'm trying to fix that all day without result's. Regards.


title: How to use Shortcode Plugin with AJAX loading?

text: I'm using Wordpress 3.9.1 and a Theme that utilizes AJAX loading. (the site is here: http://phoenixwave.com/test/ ) I've installed a plugin to add more shortcode abilities. Problem is, once a page loads via the AJAX loading - it doesn't seem to load the shortcodes (especially anything that is animated) unless you do a hard refresh on the page. If you go to: http://phoenixwave.com/test/portfolio and choose the only option on that page you'll see what is happening ... or not happening in this case. I have the ability to add custom Javascript and CSS within the theme that I'm using and wondered if there would be a way to fix this problem. I've noticed other similar problems posted to Stack but they are SO code heavy that I was unsure what to learn from.


title: Equivalent of admin.php for public pages

text: I am pretty new to the Wordpress API and can't seem to find what I need. I have been searching for a way to create public pages (accessible to users without admin permission), similar to the method used when creating pages on admin.php. Basically, I have my application for creating surveys in the dashboard, but now I want to display the actual thing to users. I was planning on displaying a custom link using a `shortcode`, which would in-turn open a window containing the requested survey using javascript's `window.open()`. However, I can no longer connect to the database if I call to an empty page in the plugin directory. In admin.php I could also `$.post` to `ajaxurl`, but that is only accessible in the admin headers. What method can I use to display a public page but still have most of the features of admin.php?


title: get post id in while loops outputting page id

text:
it's been a while since I used wordpress and I am trying to us e advanced custom fields, I am trying to output the post ID inside a loop on a page, so i can use get_field to output the post contents. Ths $post->ID gives me the page id not the post id so thr wrong number is being outputted, how do I get the post ID?               <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>                              <?php $current_id = $post->ID ?>             <?php echo $current_id ?>
<?php the_field('titleFart', $current_id); ?>
                  <?php endwhile; // end of the loop. ?>          <?php endif; ?>


title: Create a network of blogs with WordPress 3

text: I want to create a network of sites on the WordPress platform. Apartment Therapy is a prime example of how I would like to implement the network. They are using unique domains, not subdomains or directories. Click Technology in the top nav for Unplggd, click Children for Ohdeedoh, etc. Can you give me your opinion of how to best do this with WordPress 3.0.x multisite? I've read some posts about WordPress multisite that give me a hint but I want to build the architecture right the first time. Thanks for your input.


title: Manipulating a query

text: I'm trying to use my own search form rather than default single-field form. So I made my fields and set the values to the query by using `pre_get_posts` hook. All things are well. Because of searching through multiple `custom fields` I'm using `meta_query` with `relation => 'OR'` as well as using multiple key/value arrays inside it. But there is a problem I've and going to explain. This is the query that will run when submit button is clicked:               SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)     INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id)     INNER JOIN wp_postmeta AS mt2 ON (wp_posts.ID = mt2.post_id)     INNER JOIN wp_postmeta AS mt3 ON (wp_posts.ID = mt3.post_id)     INNER JOIN wp_postmeta AS mt4 ON (wp_posts.ID = mt4.post_id)     INNER JOIN wp_postmeta AS mt5 ON (wp_posts.ID = mt5.post_id)     INNER JOIN wp_postmeta AS mt6 ON (wp_posts.ID = mt6.post_id) WHERE 1=1  AND (((wp_posts.post_title LIKE '%test%') OR (wp_posts.post_content LIKE '%test%')))  AND wp_posts.post_type IN ('post', 'page', 'attachment') AND (wp_posts.post_status = 'publish' OR wp_posts.post_author = 1 AND wp_posts.post_status = 'private') AND ( (wp_postmeta.meta_key = 'jz_ftype' AND CAST(wp_postmeta.meta_value AS CHAR) = 'pamphlet')     OR  (mt1.meta_key = 'jz_year' AND CAST(mt1.meta_value AS CHAR) = '')     OR  (mt2.meta_key = 'jz_has-answer' AND CAST(mt2.meta_value AS CHAR) = 'yes')     OR  (mt3.meta_key = 'jz_atc-author' AND CAST(mt3.meta_value AS CHAR) LIKE '%%')     OR  (mt4.meta_key = 'jz_ebook-author' AND CAST(mt4.meta_value AS CHAR) LIKE '%%')     OR  (mt5.meta_key = 'jz_pro-author' AND CAST(mt5.meta_value AS CHAR) LIKE '%%')     OR  (mt6.meta_key = 'jz_level' AND CAST(mt6.meta_value AS CHAR) = 'basic') ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10      As you can see (at the end of 7th line) the additional query I set to main query by using `$query->set()` method is being `AND`:               AND ( (wp_postmeta.meta_key = 'jz_ftype' AND CAST(wp_postmeta.meta_value AS CHAR) = 'pamphlet')      But I need to make it `OR`:               OR ( (wp_postmeta.meta_key = 'jz_ftype' AND CAST(wp_postmeta.meta_value AS CHAR) = 'pamphlet')      So how can I achieve that?


title: How to add a custom button to the tinyMCE toolbar?

text: I want to add a custom button to the tinyMCE toolbar in the 'Add New Post' screen which when clicked, will insert text into the new post. I have tried using this code (from http://tinymce.moxiecode.com/tryit/custom_toolbar_button.php):               wp_admin_css('thickbox');     wp_print_scripts('jquery-ui-core');     wp_print_scripts('jquery-ui-tabs');     wp_print_scripts('post');     wp_print_scripts('editor');     add_thickbox();     wp_print_scripts('media-upload');     setup : function(ed)     {         // Add a custom button         ed.addButton('mybutton',          {             title : 'My button',             image : 'img/example.gif',             onclick : function()              {             // Add you own code to execute something on click             ed.focus();             ed.selection.setContent('Hello world!');             }         });     }      but it fails to compile. It error's at the line with ' **setup : function(ed)** ' Is it failing because I need to reference tinyMCE.js? I couldn't find that file under my WordPress installation on the server. is there a better way of creating the button?


title: Order posts by average

text: I am using advance custom fields and i have used the custom fields to create an average score. Now i want to order the posts by the average score I have tried to do it but it doesnt seem to work here is my code               <?php     $args = array(         'post_type' => 'review',         'meta_key' => $scoreavg,         'orderby' => 'meta_value_num',         'order' => 'DESC'     );     $query = new WP_Query($args);     ?>          <?php if ($query->have_posts()) : ?>              <?php while ($query->have_posts()) : $query->the_post(); ?>             <?php             $totalscore = get_field('features_score') + get_field('price_score') + get_field('service_score') + get_field('matching_score');             $scoreavg = $totalscore / 4;


title: Admin panel: Javascript not loading properly. Cannot edit pages/posts

text: I am using the latest Wordpress.org install. None of my back-end javascript is working, none of my navigation drop downs, admin panel areas are not loading as well. **I have not edited any core files.** I have tried to disable all my plugins, even moved them from the plugin directory to see if there is a conflict. No luck. I have tried to use different themes. No Luck. The only way that I can edit posts/pages is if I highlight the text that's in the post (see screenshot). I've added a few jquery scripts to my themes header.php file, tried to take those out as well, didn't work. Tried switching themes, didn't work. The only theme file that I've touched otherwise was functions.php. I'm working on a local machine using WAMP. Any help would be appreciated, THANK YOU! SCREENSHOTS: ![alt text](http://i.stack.imgur.com/30ebS.png) ![alt text](http://i.stack.imgur.com/t6Qvs.png)


title: Wordpress Permalink

text: I need to make my wordpress permalink like the following Permalink For Category:                www.mydomain.com/category/%category%      Permalink For Posts:                www.mydomain.com/category/%category%/article/%postname%      Is there any specific code i can use with .htaccess or any plugin that might help


title: Overwrite CSS of Instaemail plugin popup

text: I am using instaemail plugin on my wordpress for sending a post by email and I am trying to customize popup window, but seems that I can not overwrite Id or I don't know how to do it. Same popup you can find on link above if you click on email (try it) I had success with changing wraper color and classes by putting in style.css               div#pf-email-wrapper {         background-color: rgba(09, 85, 3, 0.50);     }      but how to change (overwrite URL)               .email-sprite{       background: url('/images/email/email-app-sprite.png') no-repeat;     }      or change color of               .pf-email label {       color:#356da9; }      So the CSS in style.css would overwrite default CSS of Instamail script It is not problem in priority It is in calling the class in style.css probably > P.S. Is there any plugin which for "send to friend" button and to > customization of popup and customization of email template


title: Automatically add author's name to post_tag

text: I need to add the author of a post's name to the post's tags whenever the post is published. So for example John Smith wrote a post, the tag 'John Smith' would be added to that post's tags. I've tried a couple of different ways, but I think I'm closest with this:                In functions.php:           add_action( 'save_post', 'add_authors_name');      function add_authors_name( $post_id ) {      $post_author = get_the_author($post_id);      wp_set_post_terms( $post_id, "$post_author", 'post_tag', true );      }      This doesn't work, but I think I'm getting there. Just not sure what I'm missing... Could anyone shed some light on this?


title: How do I move menu to the bottom in Custom Community theme?

text: I am new to Wordpress and created the following website: www.sugarhausbyamy.com I would like to move my menu to the bottom of the screen. Is there an easy way to do this? I would also like to change the font in the menu. Thanks!


title: Can't past image from clipboard into new post

text: Depending on the computer used, I'm able or not to paste copied images into a new WP post. I've looked at everything and I can't find the culprit. I've tried different browsers, and nothing seems to be working. Any ideas?


title: How we show pages in dropdown

text: I show the all `menu` which i have on the top in `dropdown` style when site is open in mobiles. I successfully display them in dropdown style but the problem is that how can i indend my subpages. or make parent pages bolg is any way to do that, my code is               <nav id="nav-mobile" role="navigation">                     <select id="mob_menu" name="page-dropdown">                       <option value="">                     <?php echo esc_attr( __( 'Select page' ) ); ?></option>                       <?php                        $pages = get_pages();                        foreach ( $pages as $page ) {                         $option = '<option value="' . get_page_link( $page->ID ) . '">';                         $option .= $page->post_title;                         $option .= '</option>';                         echo $option;                       }                      ?>                     </select>                          </nav>


title: How to scale up post thumbnails/featured image?

text:
Is there a way to scale up post thumbnails on Wordpress? On a featured div I want a post thumbnail/featured image with **584×348 px**. When I upload a smaller image as a featured image on a post, it won’t scale up to this size. **If the image is 250×250, it will appear 250×250.** But if I use a larger image as featured image on the post, it will resize normally. The thumbnail in **functions.php** is set this way:               // This theme uses post thumbnails     add_theme_support( 'post-thumbnails' );     set_post_thumbnail_size(150, 150); //size of thumbs     add_image_size( 'post-thumb', 600, 380, true );       The div:
<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'post-thumb' ); } ?>
      And the class:               .featured_thumb {background:#0C6; width:584px; height:350px; overflow:hidden;}      Can someone help me to figure out how to do it please? I thought of using timthumb but I’ve seen lots of complains about security. Not quite sure about it… Anyway, hoping someone could help me.


title: error inserting value

text: Im kinda having some problem in my `query` and looks alright in my side and tested it in a localhost too. `$query = "INSERT INTO`$db_name`(`fname`,`pass`) VALUES('".$_REQUEST['fname']."', '".$_REQUEST['pass']."')";` that query is giving me an error it says in the error that `mysql_query() expects parameter 1 to be string` and im using the plugin `Allow PHP in post and pages`.               [PHP]     if(isset($_REQUEST['fname'])){     require_once('wp-config.php');     $con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);     $db_name = "add_name";     mysql_select_db($db_name);     $query = "INSERT INTO `$db_name`(`fname`, `pass`) VALUES('".$_REQUEST['fname']."', '".$_REQUEST['pass']."')";     $add = mysql_query($con, $query);     if($add){       echo "Added succesfull";     }else{       echo "problem connection!";     }     }     [/PHP]


title: Get only parent terms from wp_get_post_terms

text: I've got a custom post type that has hierarchical taxonomies set up. For an example, my post type of "project" has categories of                A        A.1      B      C      I'm trying to get the taxonomies displayed as classes on `<li>` items for each post, but I just want the top level parents shown. For the post I'm looking at, it is categorized as A.1 and C, but I'd like to return A and C. I'm using `'parent' => 0` in the args, however its giving me A.1 and C. I have also tried using `'hide_empty' => 0` but that doesn't seem to help. Here's my code:                function project_get_item_classes($post_id = null) {          if ($post_id === null)              return;          $_terms = wp_get_post_terms($post_id, 'construction_type', array( 'parent' => 0, 'hide_empty' => 0 ));          foreach ($_terms as $_term) {              echo " " . $_term->slug;          }      }


title: Is there a way to export Advanced Custom Fields data?

text: I've entered data into ACF using the ACF Options plugin. Is there a way to export all that data I entered? When I use ACF's built in exporter, it only exports the structure. Maybe I'm missing something obvious.


title: edit posts through front-end

text: It's possible to insert posts by users through the front-end by using plugins such as gravity forms or by using wp_insert_post. However, how would one handle the editing of those posts? This has to be in a safe/foolproof/secure way for users.


title: wordpress sanitize array?

text: I have a custom post form that sends data to a page which uses wp_insert_post to create a post. I can easily sanitize most data, but I have some troubles with my tags, I retrieve in an array:               $tags =  $_POST['tags'];      Before using these tags as tags_input, how can I successfully sanitize all names? Thanks!


title: Retrieving a JSON feed of my posts and displaying thumbnails

text: I want to show a feed of my latest posts though json. I seem to be able to do it - up to a point. I am retrieving my feed like so:               var json = <?php echo json_encode($query->get_posts()); ?>;      Problem is, I can't retrieve the post thumbnails, I can just retreive the post title and a bunch of other information, but can't seem to get what I'm looking for. Any idea how I can do that? Thanks a lot!


title: All of my custom posttypes are 404'ing

text: All of the posts made within custom posttypes have suddenly become uneditable, and will 404 when you try to view them.![Screenshot](http://i.stack.imgur.com/OpENn.png) The posts in the admin panel are greyed out (posts in the standard post/pages etc are fine). * * * **Things I have Tried**   * I have tried using `GIT BISECT` but problem persists beyong where I know it to be working.   * Tried downgrading wordpress   * Checked various database elements such as post status and post author.   * Tried setting and resetting permalinks.   * Deactivated All plugins * * * New posts seem to be fine, and work normally. But my metaboxes have also vanished!! Again, `GIT` suggests this problem going back beyond where I know them to be working. It seems, as `GIT` is incapable of finding the solution, that it must either be related to the database or the wordpress core itself (as my GIT repo only tracks the theme) Wordpress is up to date. * * * **Edit** This is the function that creates the post types:               register_post_type($object_name,             array(                 'labels' => mf_create_labels($object_name),                 'public' => true,                 'supports' => array('title','editor','thumbnail','page-attributes')                      )         );      using this to create labels:               function mf_create_labels($label){         return array(             'name' => __($label),             'singular_name' => __($label),             'add_new' => _x('Add New', $label),             'add_new_item' => __('Add New '.$label),             'edit_item' => __('Edit '.$label),             'new_item' => __('New '.$label),             'view_item' => __('View '.$label),             'search_items' => __('Search '.$label),             'not_found' =>  __('No ' . $label . ' found'),             'not_found_in_trash' => __('No ' . $label . '  found in Trash'),              'parent_item_colon' => ''         );     }      * * * **Update** I have got the meta boxes back, it seems Wordpress now insists on having the posttype declared in all lower case, despite be declaring the post types with capital letters * * * **Please, if you have any idea where to look for the issue, comment. No suggestion too small at this stage**


title: Settings to get the most out of W3 Total Cache

text: I'm running a dedicated server which hosts one website - our WordPress install. Currently we're getting around 400,000 pageviews per month and that will likely rise quickly over the coming month - and hopefully exponentially from there onward ;) I want to install the W3 Total Cache plugin but after reading a few reviews/support forum posts, I'm concerned that I'll potentially slow the website down rather than speeding it up. I've installed it, had a quick play, then uninstalled it due to a few minify problems (see #2). My question, as such, is twofold.   1. Knowing that my server is a good spec, good network and hosts only this website, are there any options I should consider enabling (or disabling) to get the fastest site-usage possible?   2. How can I stop the plugin from caching my forums? Simple Press is located at `/forums/` and the JS minify breaks a number of features of the forum (TinyMCE editor, profile amendments, etc). I tried adding `*forum*\.php` to the `never cache` option, but it killed my site (500 error; had to remove the W3 Cache lines from `.htaccess`). Thanks in advance,


title: Wp plugin modification

text: i find a wp plugin what replace the external links, the problem is only check on post content, but not on fields in postmeta, this is the code what checks on post content:               //returns content of post with links replace for Wordpress Bar     //considerable thanks to Randy @onederlnd.com/     function replace_links($content) {             preg_match_all("/<a\s*[^>]*>(.*)<\/a>/siU", $content, $matches);             //preg_match_all("/<a\s[^>]*>(.*?)(</a>)/siU", $content, $matches);                 $foundLinks = $matches[0];             $wpbar_options = get_option("wpbar_options");                  foreach ($foundLinks as $theLink) {                     $uri = getAttribute('href',$theLink);                     if($wpbar_options["validateURL"]) {                             if(!isWhiteListed(get_domain($uri)) && !isSociable($theLink) && isValidURL($uri) && !isExcludedExtension($uri)) {                                     $uid = isInDB($uri);                                     $nofollow = is_nofollow($uid) ? "rel='nofollow'" : "";                                     $content=str_replace("href=\"".$uri."\"","title='Original Link: ".$uri."' ".$nofollow." href=\"".get_option('home')."/?".$uid."\"",$content);                             }                     } else {                             if(!isWhiteListed(get_domain($uri)) && !isSociable($theLink)) {                                     $uid = isInDB($uri);                                     $nofollow = is_nofollow($uid) ? "rel='nofollow'" : "";                                     $content=str_replace("href=\"".$uri."\"","title='Original Link: ".$uri."' ".$nofollow." href=\"".get_option('home')."/?".$uid."\"",$content);                             }                     }             }                   return $content;     }      I dont know how make search on postmeta


title: Sociable buttons displaying seemingly at random

text: I'm using the Sociable plugin for WordPress. In the admin settings, the Live Preview of Sociable works exactly how I'd like it to: ![Sociable Live Preview](http://i.stack.imgur.com/WxVGN.png) * * * However, on the front-end, I'm getting varying different results. Last night, my user (`dunc`)'s view was that of the Live Preview. At the same time however, my colleague had this view: ![Sociable - Matt view](http://i.stack.imgur.com/XTw5L.png) * * * Now, this morning, my view is this: ![Sociable - dunc new view](http://i.stack.imgur.com/S2AFU.png) * * * I installed the W3 Total Cache plugin last night (well before my view changed, I hasten to add) and I'm wondering if that could be having such an effect on the plugin? * * * **EDIT** I've now completely removed the W3 Total Cache plugin - and I'm having the same problem. A live link can be found here: http://www.seriouslyfish.com/welcome-to-our- new-website/ * * * Thanks in advance,


title: Ajax function not returning any results

text:
Im trying to create an ajax call when I click a link, the link is the post thumbnail, and the result should show the post content. When I use admin-ajax.php it works fine, but the problem then is that the URL doesnt become accessable. This is my ajaxcall                   $.ajax({             //url: admin_url +  '/wp-admin/admin-ajax.php',             url: href + '?action=ajax',             dataType: 'json',             data: {                 //action: 'ajax',                 post_id: post_id             },                  success: function(data) {                 console.log("Succes");                 row.before('

');                 $("#case").slideUp(1);                 $("#case").html(data).slideDown(speed);                      $("#header, #featured, .row").animate({'opacity': halfOpacity}, speed);                 return false;             },             error: function() {                 console.log("Error");                 window.location = href;             }         });      And this is the php in the functions.php                 function ajax() {              global $wpdb;         global $post;         $id = $_GET['post_id'];              $querystr = "             SELECT $wpdb->posts.*             FROM $wpdb->posts             WHERE $wpdb->posts.ID = $id         ";              $post = $wpdb->get_results($querystr);              $response = $post[0]->post_content;         $response = json_encode($response);              header( "Content-Type: application/json" );         echo $response;         exit;     }


title: How to parse meta value from user specific post to google charts?

text:
I'm currently working on a project where i need to visualize the progress of users (fitness). For that i have created a custom post type with custom fields. I want to parse the meta values associated with the custom fields to a google chart. Example: Progress in weightloss (weight + date). The users will create a post every once in a while container weight and date info. So i need to get meta values from all posts from a specific user (e.g. logged in) and then parse them to google chart. I have managed to retrieve the meta values from all post for a specific user. Code:                                                   <?php                function get_meta_values( $key, $type = 'workout', $status = 'publish' ) {     global $wpdb;     $user_ID = get_current_user_id();     if ( empty( $key ) )         return;          $r = $wpdb->get_results(         $wpdb->prepare( "             SELECT pm.meta_value, p.post_date FROM {$wpdb->postmeta} pm             LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id             WHERE pm.meta_key = '%s'              AND p.post_status = '%s'              AND p.post_type = '%s'             AND p.post_author = $user_ID             ORDER BY pm.meta_value ASC             ",             $key,             $status,             $type         )     );          if ( $r ) {         $user_ids = wp_list_pluck( $r, 'post_date' );         cache_users( $user_ids );     }          return $r;            }       ?>                            <?php     $workout_history = get_meta_values( 'repetitioner', 'workout' );      if (empty($workout_history)) {        echo '
Du har ikke indtastet data for denne øvelse.
';      }      else{       foreach ( $workout_history as $data ) {            echo '
'.$data->meta_value.' - ';       echo $data->post_date; // User ID       echo get_the_author_meta( 'display_name', $data->post_date ).'
';            }} ?>      If i try to use `json_encode` the result will look like this: `[{"meta_value":"11111","post_date":"2014-04-15 12:55:20"}]` I'm having a hard time figuring out how to parse the json fil to a google chart. I know that theres is a specific json structure in the google charts api. So any suggestions on how I should move forward? Or is there a more simple way of doing this?


title: Does wpdb add considerable overhead on queries with large result sets?

text: I am working on backup-related plugin and from some research of existing plugins - they seem to favor using PHP's `mysql_*` functions, rather than `$wpdb`. Is `$wpdb` overhead considerable enough that it is unsuitable for such task as querying whole database tables?


title: Browse Happy in 3.2

text: The Browse Happy interruption would only appear to logged-in admin users, correct? It won't show up on my public facing site? I can't really fire up IE6 very easily to find out.


title: Search taxonomies while creating a post inside metabox

text: I have a question how to add a "search" buttom to your metabox with taxonomies. Currently I have got around 200 taxonomies and it is really a pain to check the taxonomies. Is there a way so user can search through them? For example, same thing that works while editing menu for pages. Thanks! :)


title: Is it possible to query specific Wordpress Attachment files (.ppt & .pdf) and output them in a list?

text: The files are `.ppt` and `.pdf` files (not images). Will it be possible to query these types of attachments and output it in a unordered list?


title: My wordpress blog RSS isn't showing

text:
I'm trying to have a little section on my wordpress home page that has a RSS feed of my blogs activity. Here is my code for getting and displaying the RSS               <?php // Get RSS Feed(s)          include_once( ABSPATH . WPINC . '/feed.php' );          // Get a SimplePie feed object from the specified feed source.     $rss = fetch_feed( 'http://www.wpbeginner.com/feed/' );          if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly          // Figure out how many total items there are, but limit it to 5.      $maxitems = $rss->get_item_quantity( 5 );           // Build an array of all the items, starting with element 0 (first element).     $rss_items = $rss->get_items( 0, $maxitems );          endif;     ?>
     <?php if ( $maxitems == 0 ) : ?>
<?php _e( 'No items', 'my-text-domain' ); ?>
         <?php else : ?>         <?php // Loop through each feed item and display each item as a hyperlink. ?>         <?php foreach ( $rss_items as $item ) : ?>
                  <a href="<?php echo esc_url( $item->get_permalink() ); ?>"                                     title="<?php printf( __( 'Posted %s', 'my-text-domain' ), $item->get_date('j F Y | g:i a') ); ?>">                           <?php echo esc_html( $item->get_title() ); ?>
              <?php printf( __( 'Posted %s', 'my-text-domain' ), $item->get_date('j F Y | g:i a') ); ?>

         <?php endforeach; ?>     <?php endif; ?>
      Now this feed works. The thing is that the blogurl isn't my blog. Now if I try and switch the url over to my feed, any variation of the url doesn't work. It shows up No Items. Some of the URLs I tried: obrienservice.com/feed obrienservice.com/feed/rss obrienservice.com/?feed=rss2 If you check the above URLs, you'll see the RSS feed IS being generated. I just don't know why it won't go through my script.


title: How to take options from form fields and turn them in to links?

text: I have a form in WordPress with options when clicked they retrieve a filtered posts. I want to take the options from the form and place it like normal links. Can this be done? Thank You all in advance :)               <form action="" method="get" id="filter">     <select id="sort_by" name="sort_by" onchange="this.form.submit()">     <option value="most_recent"<?php if( !$_GET['sort_by'] || $_GET['sort_by'] == 'most_recent' ) echo " selected"; ?>><?php print            __('Most Recent', 'bo'); ?></option>     <option value="most_favorites"<?php if( $_GET['sort_by'] == 'most_favorites' ) echo " selected"; ?>><?php print __('Most Favorites', 'bo'); ?></option>     <option value="most_viewed"<?php if( $_GET['sort_by'] == 'most_viewed' ) echo " selected"; ?>><?php print __('Most Viewed', 'bo'); ?></option>     <option value="most_commented"<?php if( $_GET['sort_by'] == 'most_commented' ) echo " selected"; ?>><?php print __('Most Commented', 'bo'); ?></option>     </select>     </form>


title: Add a css class to a taxonomy permalink

text: I need to add a css class to every `<a>` element retrieved by `the_terms()` (or similar function) in order to open the taxonomy permalink in a fancybox modal window. I've been searching this whole afternoon for a Filter that could handle it, with no success. Anyway, I got into this (poor) solution below:               $cities = get_the_terms($post->ID, 'cities');                             foreach ($cities as $city) {                 echo 'slug, 'cities' ).'">'.$city->name. '' ;             }      But it's too 'ugly' to put in a template file. Is there any wordpress filter that deals with this question of permalink html generation? Thanks a lot!


title: How to use several wp_ajax_ functions for different queries?

text: I am working on getting multiple functions to work with `wp_ajax_` and the first two functions fire just fine. However I have the need for a completely new query that will take advantage of AJAX also.   * Should I beef up my first function with conditionals? Or    * Can I `init` more than one wp_ajax_ function like my code below?  My code so far:               add_action( 'init', 'my_ajax_init' );     function my_ajax_init() {        add_action('wp_ajax_nopriv_wpa56343_search', 'my_ajax_search');// works        add_action('wp_ajax_wpa56343_search', 'my_ajax_search'); // works             add_action('wp_ajax_nopriv_nogeo_results', 'nogeo_search'); // does not        add_action('wp_ajax_nogeo_results', 'nogeo_search'); // does not     }      my_ajax_search is functioning fine with my JS AJAX calls. nogeo_search is not. My question is - **is what I am doing to declare my ajax functions correct?** If it is not correct please explain how to use wp_ajax_ with multiple callback functions.


title: Problem with empty class attributes when running a filter on nav_menu_css_class

text:
I'm using the code below in order to remove all classes but the current-menu- item and current-menu-parent classes from the custom menus. It works very well, however, there's one nagging issue I'm trying to overcome. Some menu items end up with empty class attributes:

Home

About Us

Contact Us

      Its probably not that big a deal, but I'd rather not show a class attribute at all. Can this be done with minor revisions to the code below?               add_filter('nav_menu_css_class', 'clean_menu_classes', 10, 2);          function clean_menu_classes($classes, $item) {         $classes = array_filter(              $classes,              create_function( '$class',                       'return in_array( $class,                            array( "current-menu-item", "current-menu-parent" ) );' )             );         return array_merge(             $classes,             (array)get_post_meta( $item->ID, '_menu_item_classes', true )             );         }


title: Show just one level of child pages, wp_list_pages woe

text: I'm working on a site that has a fairly large page structure a few levels deep - in some sections there are a lot of pages. The basic setup is something like this...               Parent     Parent     Parent     -Child     -Child     --Grandchild     --Grandchild     --Grandchild     ---GreatGrandchild     -Child     -Child     --Grandchild     --Grandchild     --Grandchild     ---GreatGrandchild     -Child     Parent     -Child     Parent     Parent     -Child     -Child     --Grandchild     ---GreatGrandchild     --Grandchild      You get the picture - just imagine a lot more pages! My normal solution of submenus works fine normally (taken straight from the Codex), because I'm working on much smaller sites. This site results in a massively long menu that is far to big to be useful. What I would like to do is just to show the level _directly_ below the page that is currently being viewed. Basically an 'In this section...' menu. No matter what combination of wp_list_pages snippet I've found I've only been able to get all or nothing. Also because there are some sections that don't have children it needs to just show the top level links when no children are present. Hopefully that makes sense - I've been tearing my hair out all day over this! Any help greatly appreciated! EDIT Right, I'll ad it here. Sorry for being a noob! So huge thanks to @chip-bennet for getting me this far! I now have this code that does nearly everything I need it to.                    $output = wp_list_pages('echo=0&depth=1&title_li=Sections' );                  if (is_page( )) {                    $page = $post->ID;                    if ($post->post_parent) {                 $page = $post->post_parent;               }                    $children=wp_list_pages( 'echo=0&child_of=' . $page . '&title_li=' );                         if ($children) {                 $output = wp_list_pages( array(                     // Only pages that are children of the current page                     'child_of' => $post->ID,                     // Only show one level of hierarchy                     'depth' => 1,                     'title_li' => 'In this Section'                 ) );               }                       }                   echo $output;      This works exactly as I want until I hit the bottom of the tree, when it outputs nothing. Chip has given me the code again to show the peers of the page rather than looking for more children - however my lack of proper PHP skills is meaning I'm having trouble adding it to this code.


title: Post from one loop in different containers?

text:
Is there a way to output posts from a single loop in multiple containers? Ideally I'd like to have the posts title/meta/content etc alternate between first-container and second-container, but I can't figure out a way to do it without multiple loops.                <?php             $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;             query_posts('posts_per_page=3&paged=' . $paged);              ?>                       <?php if (have_posts()) : while ( have_posts()) : the_post(); ?>              <div <?php post_class('clearfix') ?> id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>"><?php the_title(); ?>

                          <?php global $more; $more = 0; ?>                          <?php the_post_thumbnail(); ?>                          <?php the_content('Read on...'); ?>

       FULL               <?php         $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         query_posts('posts_per_page=3&paged=' . $paged);          ?>              <?php $class = '';          <?php if (have_posts()) : while ( have_posts()) : the_post(); ?>     <?php $class = ('first-container' == $class) ? 'second-container' : 'first-container'; // alternate classes ?>     <div <?php post_class('clearfix') ?> id="post-<?php the_ID(); ?>">

         <?php the_time('M jS, Y') ?>

                  <?php echo 'Written by
'; the_author_posts_link(); ?>                         <?php the_tags('Tags: ', ', ', '
'); ?>

          Comments          <?php comments_popup_link('No Comments', '1 Comment', '% Comments', 'comments-link', ''); ?>

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

                                      <?php global $more; $more = 0; ?>                                                    <?php the_post_thumbnail(); ?>

                           <?php the_content('Read on...'); ?>

           <div class="<?php echo $class ?>">

                          <?php endwhile; endif; ?>


title: How do I use the WP image functions in a page template?

text: Wordpress has tons of mature code for image editing on the admin side, but I would like to provide a form inside of a custom page template for my visitors to drag and drop, crop and save a thumbnail image as part of a new draft post. I can do the page template, form, and draft post part, but am getting pretty frustrated trying to integrate the plupload, jcrop and gd library parts. I can do bits and pieces using each of those libraries but can't get them to play nice and it's getting way too complicated for me. Then it hit me: WordPress can do all that magic stuff on the admin side already (having "bundled" those common libraries), so if I can leverage those wp core functions from the front-end, I will be done. Can anyone give me an example or two on how to use those wp core media functions from inside a user- facing page template? Please see my similar post on wp.org


title: Sidebar loop - Thematic Framework

text:
I'm trying to add a sidebar loop to list 3 news post. I'm using thematic framework and since I don't find any hook to use I first write this function in functions.php                   function sideloop(){          global $post;         echo '

';             // The News Query             $args = array(                             'numberposts'     => 3,                             'post_type'       => 'post',                             'category'        => '123',                             'orderby'         => 'date',                             'order'           => 'DESC',                             'post_status'     => 'publish' );                  $news = get_posts( $args );                  // The Loop             foreach ($news as $post) : setup_postdata($post);                 echo '
';                     the_title();                 echo '
';             endforeach;                  // Reset Post Data                 wp_reset_postdata();              echo '

';                         }      Than I load a plugin to write php code in the widget and i write inside a widget in the primary aside widget area:               <?php     if (function_exists('sideloop')) {         sideloop();     } ?>      I expect to get this result

...

1st Post

2nd Post

3rd Post

...

      Unfortunately it seems not working right and I get this html output

        1. First of all the function doesn't get me 3 post but a lot more.   2. The posts of the sidebar-loop are empty.    3. The loop is outside the I wanted to be in.   4. The "sidebar-loop" pull the "secondary" div outside the main wrapper of the framework. Anyone can help? Thank you guys. Bye Carletto PS: I've already tried using WP_query instead of get_posts but I get the same results. Please help! * * * EDIT Wondering how I can retrieve an error message (like "Sorry, no news") when my query is empty... trying some if thing but I'm not good enough ;) Code corrected with Chip's tips and working! Thanks Bye


title: How can I list only Subcategories in Woocommerce

text:
So I have been able to list all the categories in woocommerce, but I am having trouble trying to list the subcategories of the category 'bathrooms'. Does anyone have any idea how I can achieve this? here is the code I am currently using...               <?php $tax_terms = get_terms('product_cat', 'hide_empty=0' ); ?>
               <?php foreach ($tax_terms as $tax_term) {                 echo '
' . 'name ) . '" ' . '>' . $tax_term->name.'
';         } ?>


title: Wordpress duplicate content with wp_link_pages

text: Currently I am using wp_link_pages in my single.php post template using               <!--nextpage-->      to split a post into multiple pages, but i have a **serious problem** with google webmaster and **duplicate content** , for example:               http://italianstreaming.info/arrow-serie-tv-streaming/2/     http://italianstreaming.info/arrow-serie-tv-streaming/3/      in this way i get **penalized by google** a lot, what should I do to fix it? I modified the **htaccess** file in this way               User-agent: *     Disallow: /wp-admin/     Disallow: /wp-includes/     Disallow: /1/     Disallow: /2/     Disallow: /3/     Disallow: /4/     Disallow: /5/     Disallow: /6/     Disallow: /7/     Disallow: /8/      but it does not work, help me please!