Is it true $wpdb->get_results is faster than WP_Query in most cases?

On my homepage, I have a section where I have to display the last five featured posts, where a featured post is simply a post with a custom field is_featured set to 1. I achieved what I want with two different type of codes:      **Using wpdb**               <?php             $featuredPosts = $wpdb->get_results("             SELECT ID, post_title FROM $wpdb->posts             LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id)             WHERE $wpdb->postmeta.meta_key = 'is_featured'             ORDER BY ID DESC LIMIT 5         ");              if ($featuredPosts)         {             $htmlOutput = '';                                     foreach ($featuredPosts as $featPost)                 $htmlOutput .= '
ID).'">'.$featPost->post_title.'';         }              echo $htmlOutput;     ?>         According to the "Query Monitor" plugin, this query takes 0.1s and generates this SQL:               SELECT ID, post_title     FROM wp_posts LEFT JOIN wp_postmeta ON(wp_posts.ID = wp_postmeta.post_id)     WHERE wp_postmeta.meta_key = 'is_featured'     ORDER BY ID DESC     LIMIT 5         **Using Wordpress' native calls**               <?php                                                                                $featuredPostsRevised = new WP_Query         (             array             (                 'meta_query' => array                 (                     array                     (                         'key' => 'is_featured'                     )                 )              )          );                while($featuredPostsRevised->have_posts()) : $featuredPostsRevised->the_post();     ?>
             <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?>     <?php         endwhile;     ?>         According to the "Query Monitor" plugin, this query takes 0.2s and generates a somehow longer SQL:               SELECT SQL_CALC_FOUND_ROWS wp_posts.ID     FROM wp_posts     INNER JOIN wp_postmeta     ON (wp_posts.ID = wp_postmeta.post_id)     WHERE 1=1     AND wp_posts.post_type = 'post'     AND (wp_posts.post_status = 'publish'     OR wp_posts.post_status = 'private')     AND (wp_postmeta.meta_key = 'is_featured' )     GROUP BY wp_posts.ID     ORDER BY wp_posts.post_date DESC     LIMIT 0, 10      My questions are:   1. How can I `prepare()` my `wpdb` query? I tried but couldn't manage because of the second parameter.   2. After using prepare, am I right in assuming that in terms of security and performance, `wpdb` is indeed a better solution?


Can't grab author info outside of the loop

I have an author box outside of the loop that is supposed to grab the name of the author, but the correct author isn't being displayed most likely because these tags only work inside the loop. What can I change in this code to make it work outside of the loop?

About <?php echo get_the_author(); ?>
                 <?php echo get_avatar( get_the_author_meta( 'user_email' ), 70 ); ?>

<?php the_author_meta( 'description' ); ?>

<a class="author-link" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">View all posts by <?php echo get_the_author(); ?> →

      Full code for single.php below:               <?php get_header(); ?>
                  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                               <div <?php post_class(); ?> id="post-<?php the_ID(); ?>">

                              <?php the_category(', '); ?>
                                  <?php the_title(); ?>                                  <?php $format = get_post_format(); ?>                             <?php if ($format == "image" || $format == "gallery" || $format == "video") : ?>                             <img src="<?php echo get_template_directory_uri(); ?>/images/icon-<?php echo $format; ?>.png" alt="<?php echo $format; ?>" />                             <?php endif; ?>
                              <?php _e('Posted', 'engine') ?> <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' '.  __('ago', 'engine'); ?>                         <?php _e('by', 'engine') ?> <?php the_author_posts_link(); ?> <a class="post-twitter" href="http://twitter.com/<?php the_author_meta('twitter') ?>" target="_blank"><img src="<?php echo get_stylesheet_directory_uri(); ?>/images/twitter-icon.png" />

                                       <div class="featured-image <?php echo get_post_format(); ?>">                          <?php if (get_post_format() == 'video' && get_post_meta(get_the_ID(), 'dt_video', true) != '') : ?>                              <?php                         global $wp_embed;                         $video_url = get_post_meta(get_the_ID(), 'dt_video', true);                         $video_embed = $wp_embed->run_shortcode('[embed width="700"]'.$video_url.'[/embed]');                         ?>                         <div id="video-<?php the_ID(); ?>"><?php echo $video_embed; ?>
                          <?php elseif (get_post_format() == 'gallery') : ?>
                                  <?php                                  $args = array(                                 'orderby'        => 'menu_order',                                 'order'          => 'ASC',                                 'post_type'      => 'attachment',                                 'post_parent'    => get_the_ID(),                                 'post_mime_type' => 'image',                                 'post_status'    => null,                                 'numberposts'    => -1,                             );                                  $attachments = get_posts($args);                                  ?>                                  <?php if ($attachments) : ?>
                                  <?php foreach ($attachments as $attachment) : ?>                                      <?php                                     $format = get_post_format();                                     $src = wp_get_attachment_image_src( $attachment->ID, array( '9999','9999' ), false, '' );                                     $src = $src[0];                                     $image = dt_resize($attachment->ID, $src, 700, '', true);                                     $caption = $attachment->post_excerpt;                                 ?>
                                          <span class="overlay-icon overlay-<?php echo $format; ?>"><a rel="group-<?php the_ID(); ?>" title="<?php echo $attachment->post_title; ?>" class="colorbox-<?php echo $format; ?>" href="<?php echo $src; ?>">                                          <img                                     height="<?php echo $image['height']; ?>"                                     width="<?php echo $image['width']; ?>"                                     alt="<?php echo apply_filters('the_title', $attachment->post_title); ?>"                                     src="<?php echo $image['url']; ?>"                                     />                                          <?php if($caption != '') : ?>                                     <?php echo $caption; ?>                                     <?php endif; ?>
                                  <?php endforeach; ?>

                                      Next                                 Prev
                                  <?php endif; ?>
                          <?php elseif (has_post_thumbnail() && get_option('dt_blog_image') != 'false') : ?>                              <?php                          $thumb = get_post_thumbnail_id(get_the_ID());                         $image = dt_resize( $thumb, '', 700, '', true );                         echo '';                         ?>                          <?php endif; ?>

                     <?php the_content(); ?>

                          <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' '.  __('ago', 'engine'); ?>                          <?php comments_number(__('No Comments', 'engine'), __('1 Comment', 'engine'), __('% Comments', 'engine')); ?>

                 <?php                     $prevPost = get_previous_post();                      if(isset($prevPost->ID))                     $prevthumbnail = get_the_post_thumbnail($prevPost->ID, array(100,100) );                     $nextPost = get_next_post();                      if(isset($nextPost->ID))                     $nextthumbnail = get_the_post_thumbnail($nextPost->ID, array(100,100) );                      $default = '';                 ?>

                         <?php                             if ($nextPost && '' != get_the_post_thumbnail($nextPost->ID, array(100,100))) {                                  next_post_link('%link', $nextthumbnail, false);                                  next_post_link('%link', '« %title', false);                              } elseif ($nextPost) {                                 next_post_link('%link', $default, false);                                  next_post_link('%link', '« %title', false);                             } else {                                 print '
' . __( 'You are at the beginning!' ) . '
';                             }                            ?>

                         <?php                             if ($prevPost && '' != get_the_post_thumbnail($prevPost->ID, array(100,100))) {                                  previous_post_link('%link', '%title » ', false);                         previous_post_link('%link', $prevthumbnail, false);                              } elseif ($prevPost) {                         previous_post_link('%link', '%title » ', false);                                 previous_post_link('%link', $default, false);                                   } else {                                 print '
' . __( 'You are at the end!' ) . '
';                             }                            ?>

                   <?php $related = get_option('dt_related');                  if($related == 'true') : ?>

Recommended
                          <?php                          $related = dt_get_posts_related_by_taxonomy(get_the_ID(), 'category', get_the_ID());                          ?>
                              <?php  if($related->have_posts()) : while ($related->have_posts()) : $related->the_post(); ?>                                                       <li id="featured-post-<?php the_ID(); ?>">

                                                                              <?php the_title(); ?>                                         <?php dt_overlay_icon(); ?>
                                 <a href="<?php the_permalink(); ?>"><?php dt_image(200, ''); ?>
                              <?php endwhile;  else: ?>
<?php _e('There are no related posts.', 'engine'); ?>
                         <?php endif; ?>

                  <?php endif; ?>

About <?php echo get_the_author(); ?>
                     <?php echo get_avatar( get_the_author_meta( 'user_email' ), 70 ); ?>

<?php the_author_meta( 'description' ); ?>

<a class="author-link" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">View all posts by <?php echo get_the_author(); ?> →

                                                  Please enable JavaScript to view the comments powered by Disqus.

                  <?php endwhile; else : ?>
<?php _e('No posts found', 'engine'); ?>
                  <?php endif; ?>
          <?php get_sidebar(); ?>          <?php get_footer(); ?>


Description is not seen of my title in search engine?

I'm using Wordpress SEO plugin and I can also see my site in google search But in general settings of Wordpress I gave title as `Gamers | Play game online` and description and also provided some description `Say something about website` But it shows me only `Gamers` as title and description is not seen what I gave in meta tag instead it shows all link name of the menus of the website. Can any one guess what might be the problem?


When developing entire sites for clients, is it viable to version control the entire site?

How do you then manage the database? An alternative, of course, is to just keep the themes in version control, and then upload them manually to the site when deploying. edit: Close this, it's duplicate. I couldn't "flag" it.


query with custom field

I figured out with my jquery slider. Need to help (: my query is:               <?php $the_query = new WP_Query('showposts=10&orderby=post_date&order=desc'); while ($the_query->have_posts()) : $the_query->the_post(); ?>     <?php $imaj = get_post_meta($post->ID, 'manset', true); ?>          <?php the_permalink()?>     <img src="<?php echo $imaj; ?>" alt="" />          <?php endwhile;?>     <?php wp_reset_query(); ?>      with this query, **the query** print all posts. But i would like to display just if the post has "manset" custom field in it. how can i do that ( sorry about my bad english )


Code to check amount of blog posts and add css

Is there any sort of jquery I can use to check if there is only one blog post on the page, then to add custom CSS? And if there is more than one, add different CSS?
       <?php if ( have_posts() ) : ?>         <?php while ( have_posts() ) : the_post( '' ); ?>

               <time datetime="<?php the_time( 'Y-m-d' ); ?>" pubdate><?php the_time( 'F j, Y' ); ?></time>
                 <p href="<?php the_permalink(); ?>"><?php the_title(); ?>

                 <?php the_content(); ?>

               <?php               echo(types_render_field( "blog-image", array("output" => "html") ));               ?>

               <?php endwhile; ?>       <?php endif; ?>


How to add thumbnails to posts?

I am using the latest version of WordPress with the Twenty Ten theme. How can I add thumbnails to each of my posts? A step-by-step guide would be helpful in this regard.


Link to full size image or attachment page in photo theme

My site is using WooThemes Statua theme. I'm trying to get my resized slider images to link to their respective full size images (or attachment pages). I asked a similar question on the WooThemes support forums (members login required) and the code they provided links the images to the resized 960px Large image size instead of the Full size images. Here's an example page on my site, using the single.php template, and its code. How can I get the slider images to link to the full size originals or attachment pages?


template_include filter does not render the custom template

I created a plugin that will render a shortcode that is entered to a page. This Shortcode shall override the theme's page template and use the one that I included on the plugin Here's my code: api.php                  class Api{              public static $logger = null;              function Api() {             add_shortcode('my_shortcode', array(&$this, 'my_shortcode_function'));         }              function my_shortcode_function($atts,$content = null)            {             add_filter( 'template_include', 'custom_view');                  }              function custom_view()         {             $template = plugin_dir_path( __FILE__ ) . 'custom-page.php';                  return $template;              }     }              add_action('init', 'apiInit', 10);         function apiInit() {              global $api;             if (class_exists('Api')){         $api = new Api();       }         }      and here's my custom-page.php (which I am 100% sure that is in the correct path / directory that I am pointing in the code)                  <?php        /**         * Response View Template         * File: custom-page.php         *         */        echo 'I am here!';       <?      Tried to debug each function it goes through my_shortcode_function() but does not go through custom view function. Cheers!


Insert PHP into wordpress page

I want to use the following code in my wordpress page. How can I do that?               <?php     $theme_name = get_template();     $directory = "wp-content/themes/" . $theme_name . "/pdf/ECE340/";     $pdfs= glob($directory . "*.pdf");     foreach($pdfs as $pdf)     {     $link= substr($pdf,48,90);     ?>     <a href="<?php echo $pdf;?> "><?php echo $link;?>     <?php     echo "\n\n";     }     ?>


add_action does not work when instance multiple tab-containers via template-file

I wrote my first class in functions.php which I want to use to create multiple tabs with a simple call all over my template files. When I create a new instance directly in functions.php everything is fine for that instance. But when I call my class via a helper function outside my functions.php, all action hooks do not take effect. Are there any suggestions how to get this done? Regards               class EasyTabs {          private static $instance;          public static function get_instance() {              if ( !self::$instance instanceof self )             self::$instance = new self;         return self::$instance;          }          public function container_id() {         $id = rand(1000,9999);         return $id;     }          public function get_the_tabs() {         ...     }          public function tabs_js() {         ...     }          public function tabs_styles_and_scripts() {         // style         wp_register_style('jquery-easytabs-style', get_stylesheet_directory_uri() . '/inc/easytabs/style.css', array(), '', 'all');         wp_enqueue_style('jquery-easytabs-style');              //script         wp_register_script('jquery-easytabs-min', get_stylesheet_directory_uri() . '/inc/easytabs/jquery.easytabs.min.js', array('jquery'), '', false);         wp_enqueue_script('jquery-easytabs-min');         wp_register_script('jquery-hashchange-min', get_stylesheet_directory_uri() . '/inc/easytabs/jquery.hashchange.min.js', array('jquery'), '', false);         wp_enqueue_script('jquery-hashchange-min');     }          public function __construct() {         //actions         add_action('wp_enqueue_scripts', array ( $this, 'tabs_styles_and_scripts' ));         add_action('wp_head', array($this, 'tabs_js'));     }          }          if ( !function_exists( 'the_tabs' ) ) {         function the_tabs() {             echo EasyTabs::get_instance()->get_the_tabs();         }     }      **Edit:** Thanks for the hint, looking for a hook which fires later did the trick: http://shibashake.com/wordpress-theme/wp_enqueue_script-after-wp_head               class RFRQ_Tabs {              public $containerID;         public $posttype;              public function __construct( $posttype ) {             // set vars             $this->set_container_ID();             $this->set_posttype($posttype);             //add scripts and styles             add_action('wp_footer', array($this, 'scripts'));             add_action('wp_print_footer_scripts', array($this, 'ex_scripts'), 1);         }              ...              public function scripts() {             echo "<script type='text/javascript'>";                 echo "jQuery(document).ready( function() {";                     echo "jQuery('#tab-container-" . $this->get_container_ID() . "').easytabs();";                 echo "});";             echo "</script>";         }                   public function ex_scripts() {                     if (is_admin())                 return;             wp_enqueue_script('jquery-easytabs-min', get_stylesheet_directory_uri() . '/inc/easytabs/jquery.easytabs.min.js', array('jquery'), '', true);             wp_enqueue_style('jquery-easytabs-style', get_stylesheet_directory_uri() . '/inc/easytabs/style.css', array(), '', 'all');             }       }     /**      * RFRQ      * helper function to instance an tab-object      */     if (!function_exists('the_tabs')) {         function the_tabs( $posttype ) {             $easytabs = new RFRQ_Tabs( $posttype );             echo $easytabs->get_the_tabs();         }     }


Change template on the fly based on post parent selection

I want to change my page template automatically when someone selects a specific post parent. I have the code to update the template but couldn't find anything for detection of post parent attribute changes. Can you help?


Disable plugin function

I want to hide most of the backend links added by TinyMCE Templates plugin. I have problem with 'Copy to a new template' link inside Publish box. Plugin code:               add_action('post_submitbox_start', array(&$this, 'post_submitbox_start'));      I try (and it doesn't work):               function remove_post_submitbox_link(){         global $tinymceTemplates;         remove_action('post_submitbox_start', array( $tinymceTemplates, 'post_submitbox_start' ) );     }     add_action('plugins_loaded', 'remove_post_submitbox_link', 11);      Why that doesn't work?


save_post custom post type ? $_POST not working?

i have this code.               <?php     add_action('add_meta_boxes', 'ct_meta_add');     add_action('save_post','ct_meta_save');     add_action('save_post','ct_parent');     // add meta functions     function ct_meta_add() {         add_meta_box(             'ct_chap', //id             'Thông tin chương', //title             'ct_meta_show', //callback function             'chap', //post type                  'normal' //priority         );     }     function get_blogspot_url($string) {         preg_match_all('/<a href="(.*?)"/', $string, $matches);         $string = '';         foreach($matches[1] as $val) {             $string .= $val."\n";         }         $string = str_replace('s1600', 's0', $string);         return $string;     }     // save meta functions     function ct_meta_save() {         global $post;            /* Save meta */         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;         if ( !wp_verify_nonce( $_POST['ct_nonce'], plugin_basename( __FILE__ ) ) ) return;         if( !current_user_can( 'edit_post' ) ) return;           $meta = array('ct_download_link', 'ct_list_url', 'ct_list_url2');         foreach($meta as $dt) {                  if($dt == 'ct_list_url2') {                          $_POST[$dt] = get_blogspot_url($_POST[$dt]);             }             if(isset($_POST[$dt]) && $_POST[$dt] !== '') {                 update_post_meta($post->ID, $dt, $_POST[$dt]);             } else {                 delete_post_meta($post->ID, $dt);                }                }        }     ?>     <?php     function ct_parent() {          global $post;         if($_POST['ct_truyen'] && $_POST['ct_truyen'] != "") {             //lưu hoặc thay đổi truyện của chap             $ct_post = array();             $ct_post['ID'] = $post->ID;             $ct_post['post_parent'] = $_POST['ct_truyen'];               //thay đổi thời gian cập nhật truyện             $tr_post = array();             $tr_post['ID'] = $_POST['ct_truyen'];                $tr_post['post_modified_gmt'] = current_time('mysql');             $tr_post['post_modified'] = current_time('mysql',7);                     remove_action('save_post','ct_parent');                  remove_action('save_post','tr_parent');              wp_update_post($ct_post);                wp_update_post($tr_post);                add_action('save_post','ct_parent');         }     }        ?>     <?php //save_meta function     function ct_meta_show() { ?>         <?php             global $post;             $ct_download_link = get_post_meta($post->ID, 'ct_download_link', true) ? get_post_meta($post->ID, 'ct_download_link', true) : '';             $ct_list_url = get_post_meta($post->ID, 'ct_list_url', true) ? get_post_meta($post->ID, 'ct_list_url', true) : '';             $ct_list_url2 = get_post_meta($post->ID, 'ct_list_url2', true) ? get_post_meta($post->ID, 'ct_list_url2', true) : '';         ?>         <?php wp_nonce_field(plugin_basename(__FILE__), 'ct_nonce');  ?>

                 Truyện<a class="add-chap-truyen" href="<?php echo admin_url('post-new.php?post_type=truyen'); ?>">thêm truyện	                                      <?php                     global $post;                     global $wpdb;                     $query = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'truyen' AND post_status = 'publish' ORDER BY post_title";                     $results = $wpdb->get_results($query, OBJECT);                     echo '<select name="ct_truyen" id="ct_truyen">';                     if(!$_GET['truyen_id'] || !get_the_title($_GET['truyen_id'])) {                         echo '<option value = "">None</option>';                         foreach ($results as $r) {                             echo '<option value="', $r->ID, '"', $r->ID == $post->post_parent ? ' selected="selected"' : '', '>', $r->post_title, '</option>';                         }                     } else {                         foreach ($results as $r) {                             echo '<option value="', $r->ID, '"', $r->ID == $_GET['truyen_id'] ? ' selected="selected"' : '', '>', $r->post_title, '</option>';                         }                     }                     echo '</select>';                     ?>

                 Địa chỉ tải chương	                 <input type="text" name="ct_download_link" class="regular-text" value="<?php echo $ct_download_link; ?>"/>

                 Địa chỉ ảnh đọc online	                                      Địa chỉ ảnh 1
<textarea name="ct_list_url" rows="20" class="large-text code"><?php echo $ct_list_url; ?></textarea>
                     Địa chỉ ảnh 2
<textarea name="ct_list_url2" rows="20" class="large-text code"><?php echo $ct_list_url2; ?></textarea>

         <?php } ?>     <?php     //auto chap title     add_filter( 'default_title', 'ct_auto_title');     function ct_auto_title($title) {         if($_GET['truyen_id'] && get_the_title($_GET['truyen_id'])) {             $chap_number = get_number_chap($_GET['truyen_id']);             $title = get_the_title($_GET['truyen_id']) . ' chương ' . ($chap_number+1);             return $title;         } else {             return $title;         }     }     function ct_remove_excess_columns( $columns ) {              unset($columns['author']);         unset($columns['comments']);         unset($columns['wpseo-score']);         unset($columns['wpseo-title']);         unset($columns['wpseo-focuskw']);         unset($columns['wpseo-metadesc']);           return $columns;         }     add_filter( 'manage_edit-chap_columns' , 'ct_remove_excess_columns' );     ?>      everything is OK, but when i was saving, the function `get_blogspot_url($_POST[$dt])` didn't work because $_POST[$dt]. When i replace `get_blogspot_url($_POST[$dt])` with,               get_blogspot_url('

')      it works, so i think $_POST[$dt] have problem, can you help me? You can download php file: https://dl.dropbox.com/u/52812919/chap-meta.rar :( Sorry about my bad english


Allow HTML in excerpt

Here is my excerpt code.               // Generate custom excerpt length     function wpbx_excerpt_length($length) {         return 300;     }     add_filter('excerpt_length', 'wpbx_excerpt_length');      How do I allow html like `<a> <b> <i> <br>`


Craft theme content links are stripped

I'm working with Craft theme and I have a link on in my post. The Link works fine in the post but not on the home page where it is showcased. I was thinking I put it in the post incorrectly at first. However it looks like the theme is stripping out the link for some reason. I am trying to figure out where I can correct this. Is there some pre processing going on somewhere in the themes code that does this and where is the best place to prevent it from happening ? you can see the behavior on this site


Views count with time limit per IP

I've been looking for function about post views count. I found this simple functions using update and get post meta.               function setPostViews($postID) {         $count_key = 'views';         $count = get_post_meta($postID, $count_key, true);         if($count==''){             $count = 0;             delete_post_meta($postID, $count_key);             add_post_meta($postID, $count_key, '0');         }else{             $count++;             update_post_meta($postID, $count_key, $count);         }     }      What I want is, to add functions to limit the count added per IP by given time - a day for example. So when the IP visiting on the same day, it would not counted, just once. Any idea? Thanks.


How to set up conditionals in page templates?

I have created custom template page like this with a custom query on page showing only details fetch from my custom table not any post.               /*          Template Name:product          */     <?php get_header(); ?>     <?php              $data = $wpdb->get_results("myquery Here");         foreach($data as $row)         {             product Name:  $row->p_name;             prod price: $row->p_price;     ?>         VIEW PRODUCT          <?php         }     ?>     <?php get_footer();?>      I need help about when we click on "VIEW PRODUCT" then how can I redirect to next view_detail page? For that can I create another *view_detail.php* page? What should I write on `href=""` with passing `product_id`, which I get on view_detail.php.


Get page slug and assign a variable within functions.php

I have created a lazy loading script using AJAX and JSON for my blog. It works perfectly. However I have 4 different blogs on the same site. These are created using custom post types. I need to get the AJAX to do lazy loading for all of these blogs. I can get it to work for each one by manually changing the name from post to boutiques for example. So I created a variable called $postname and want to assign this a different value depending on the slug of the page you are on when you click load more posts. How can i check what page slug is and then assign my variable a name. Here is my code but I need to know how to call the slug of the page im on and assign that to $slug.               if ( $slug == 'boutiques'  ) {              $postname = 'boutiques';          } elseif ( $slug == 'tourist' ) {              $postname = 'tourist';     }     else {         $postname = 'post';     }


how to fetch the meta field keys/meta boxes from a post type?

I need to find all the meta keys or meta boxes preferably from just a post type ...couldn't find any wordpress function to do this. Any custom queries?


Register/Get sidebar?

I can't quite seem to figure out how it works. By default i have a sidebar in sidebar.php that i load using `get_sidebar();`. That works great (no need to register it), but i have a custom page template for another page where i want to load another sidebar. I know i can use include('filename') to load it but i assume there is some sort of wordpress way to do it as well. I know i have to register the new sidebar in the functions.php file, but where do i actually reference the sidebar file? From the doc:               name - Sidebar name (default is localized 'Sidebar' and numeric ID).     id - Sidebar id - Must be all in lowercase, with no spaces (default is a numeric auto-incremented ID).     description - Text description of what/where the sidebar is. Shown on widget management screen. (Since 2.9) (default: empty)     class - CSS class name to assign to the widget HTML (default: empty).     before_widget - HTML to place before every widget(default: '
') Note: uses sprintf for variable substitution     after_widget - HTML to place after every widget (default: "
\n").     before_title - HTML to place before every title (default:
).     after_title - HTML to place after every title (default: "
\n").      In neither of those preferences do you specify the filename of the sidebar, so how do i do it? After i have registered it successfully, i assume i can load it using `get_sidebar(ID);`, will that work? Any help is very appreciated!


Check if a post is in any child category of a parent category

In a site I'm developing, I have the following category structure:               * movies (parent)         * thriller (child)         * comedy (child)         * drama (child)      The current post is in the **comedy** category. The **has_term** function with the following parameters returns true:               has_term( 'comedy', 'category' )      But, the same function with the following parameters returns false:               has_term( 'movies', 'category' )      My question is, is there a core function to check if the current post is in any child category of a specific parent category? If not, how can I check this? Thanks in advance


Multiple category lists on one page

Is it possible to use `wp_list_categories( $args )` several times on a page to list different groups of terms from a taxonomy? The following code displays on term#58 together with a child that says "No Categories". None of the child terms appear on the page. However, if I remove the first use of the tag `wp_list_categories( $args )` then the second group appears on the page and lists the children. I'd appreciate any suggestions on how to overcome this and get both groups to display. Note that the reason I'm approaching the dispay in this manner is that I want to put the terms into a jquery accordion and so I need to separate out the parent term from the children.               <?php     //set up the header title for the first group     $taxonomy     = 'glossary';     $include      = 58;     $title        = '';               $argstitle1 = array(         'taxonomy'     => $taxonomy,         'title_li'     => $title,         'include'   =>$include     );          wp_list_categories( $argstitle1 );          // list terms in a given taxonomy using wp_list_categories.     // Specifies the list to view by using the "child-of" arguments.          $taxonomy     = 'glossary';     $orderby      = 'name';      $show_count   = 0;      // 1 for yes, 0 for no     $pad_counts   = 0;      // 1 for yes, 0 for no     $hierarchical = 1;      // 1 for yes, 0 for no     $title        = '';     $Child_of     = 58;               $args = array(         'taxonomy'     => $taxonomy,         'orderby'      => $orderby,         'show_count'   => $show_count,         'pad_counts'   => $pad_counts,         'include'        => $include,         'title_li'     => $title,         'child_of'   => $Child_of     );     ?>          <ul>         <?php wp_list_categories( $args ); ?>     </ul>


Wrapping code in an if block

Breadcrumb trail shows on all pages, except I need to remove it from the homepage. Here's my code so fare.               <?php if( !is_front_page ):?>       <div class="breadcrumbs" style="position:absolute; bottom:0;">         <?php if(function_exists('bcn_display'))           {             bcn_display();           }?>       </div>     <?php endif;?>      at this point the code is not working, even on the homepage. how should i have the if statement written so that the breadcrumb trails show up on all other pages except the homepage.


Black and White Thumbnail in WordPress Gallery

I want to have black and white thumbnail on page, and i want to show image in colour when mouse is on and when big image is shown (in lightbox) I have this ->               add_action('after_setup_theme','bw_images_size');     function bw_images_size() {         $crop = get_option('thumbnail_crop')==1 ? true : false;         add_image_size('thumbnail-bw', get_option('thumbnail_size_w'), get_option('thumbnail_size_h'), $crop);     }          add_filter('wp_generate_attachment_metadata','bw_images_filter');     function bw_images_filter($meta) {         $file = wp_upload_dir();         $file = trailingslashit($file['path']).$meta['sizes']['thumbnail-bw']['file'];         list($orig_w, $orig_h, $orig_type) = @getimagesize($file);         $image = wp_load_image($file);         imagefilter($image, IMG_FILTER_GRAYSCALE);         //imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR);         switch ($orig_type) {             case IMAGETYPE_GIF:                 $file = str_replace(".gif", "-bw.gif", $file);                 imagegif( $image, $file );                 break;             case IMAGETYPE_PNG:                 $file = str_replace(".png", "-bw.png", $file);                 imagepng( $image, $file );                 break;             case IMAGETYPE_JPEG:                 $file = str_replace(".jpg", "-bw.jpg", $file);                 imagejpeg( $image, $file );                 break;         }         return $meta;     }      And i have 4 image in 3 size (1024x628, 150x100, 300x200) and 1 "name-150x100-bw.jpg". But i don't know how to use this bw.jpg. Above code is from http://bavotasan.com/2011/create-black-white-thumbnail-wordpress but code to get in loop worked only for featured image in post. Thank you.


NextGen Gallery template cache

I've implemented a custom Isotope template for the NextGen Gallery plugin, and I've made changes and bug fixes to the template, but when I refresh the page the template changes have not taken effect. I tested the cache of my browser by making changes to other theme template files, such as _header.php_ , etc. The browser recognizes these changes immediately, but the NextGen Gallery template is still on an old version. Any idea of how to flush this cache and reload this template file with each new change?


Custom URL for all posts in Wordpress

I have a wordpress site with static page as the front page. I want to have `/blog` to display the recent posts. How can I do that? thanks.


Search Everything & WP 3.7 update issues

I have been personally maintaining the Search Everything plugin for WordPress since the authors stopped. I upgraded one of my sites to wp 3.7 today but i get this error when i search: > **WordPress database error:** [You have an error in your SQL syntax; check > the manual that corresponds to your MySQL server version for the right > syntax to use near `'))) AND ncca_wp_posts.post_type IN ('post', 'page', > 'attachment', 'archive', 'r'` at line 1]               SELECT DISTINCT SQL_CALC_FOUND_ROWS          ncca_wp_posts.*      FROM ncca_wp_posts      LEFT JOIN ncca_wp_term_relationships AS trel          ON ( ncca_wp_posts.ID = trel.object_id )      LEFT JOIN ncca_wp_term_taxonomy AS ttax          ON (              ( ttax.taxonomy = 'category'                  OR ttax.taxonomy = 'post_tag'                  OR ttax.taxonomy = 'years'                  OR ttax.taxonomy = 'archive-tags'                  OR ttax.taxonomy = 'course'             )              AND trel.term_taxonomy_id = ttax.term_taxonomy_id         )      LEFT JOIN ncca_wp_terms AS tter          ON (ttax.term_id = tter.term_id)      LEFT JOIN ncca_wp_postmeta AS m          ON (ncca_wp_posts.ID = m.post_id)      WHERE 1=1          AND (              (                  ((()))                  AND ncca_wp_posts.post_type IN ('post', 'page', 'attachment', 'archive', 'research-project')                  AND (                     ncca_wp_posts.post_status = 'publish'                      OR ncca_wp_posts.post_status = 'private'                 )             )              AND post_type != 'revision'         )         AND post_status != 'future'          ORDER BY ncca_wp_posts.post_title LIKE '% %' DESC, ncca_wp_posts.post_date DESC LIMIT 0, 24      Edit: Thank you kaiser. Taken on board for next time. I can see the error is being caused by an SQL syntax error, as stated above, but I cannot figure out how to fix it. Can anybody suggest how to alter this line of code to make it work correctly?


How to move style from template file to <head> section?

Imagine the following situation:               //header.php contains:     logo and navigation          //my-template.php contains:     <?php get_header(); ?>

     <?php get_footer(); ?>      This will disable `<header>` for my-template.php in the most modern browsers (except IE9) but it's not valid solution. Is there a way to use something like `wp_enqueue_style();` directly in my-template.php to make it load that style in `<head>` in header.php? Just to make it valid. I want to keep this modular, so I don't want to put if statement like this in header.php (it will not be stand-alone modular page template anymore):               <?php if(is_page_template( 'my-template.php' )){ ?>          <?php } ?>


some posts have comments closed and some open why?

Some posts in my wordpress isntallation display comments closed, while some are open. Did this happen because while writing those posts comments was closed and now as it is open value in db remained unchanged? If so is there a massive way to fix this?


is there any wp plugin that could detect wp site visitor(using mobile browser) Geo location?

i found one plugin http://wordpress.org/extend/plugins/ochre-w3c-geolocation- services, close to my demand but it seems still need revise some code on the activated theme. so i am wondering, if any easy to use plugin with such feature: for example, provide a widget or shortcode with a button, whenever visitors come from a mobile browser and press that button, he will get his accurate location and content info related to that location, which is predefined and inputed by site admin. if there is no such plugin yet...i think it's a good blank. anyone build it will get lots of wp users i believe,that is a basic and common demand in turning wordpress into mobile era. btw...i am not a programmer.


query_vars in plugin not working?

I have a problem writing a plugin for wordpress. First, I register a new `query_var` and add a new rewrite rule:               function nng_users_query_vars( $vars ) {         array_push( $vars, 'nng_users' );         return $vars;     }     add_filter('query_vars', 'nng_users_query_vars');          function nng_users_rewrite_rules( $rules ) {     $newrules = array(                             'benutzer/([^/]+)/?$' => 'index.php?pagename=nng_users&nng_users=$matches[1]'                           );     $finalrules = $newrules + $rules;         return $finalrules;     }     add_filter('rewrite_rules_array','nng_users_rewrite_rules');      This works perfectly, but I cannot grab any `query_var` from the plugin. Typing:               print_r( $wp_query->query_var );      or               echo $wp_query->query_var['some_var'];      does not show anything. But why? If I put the exact same thing into the function of my theme, it works. If I put it into a function and call this function in my theme, it works... Background is the following: I want to create a custom user system and therefore I need to check my custom query var to e.g. logout or header-redirect. Thanks in advance


Enqueue jQuery in WordPress

Building my first theme from scratch in Wordpress 3.4.1, I know Wordpress already has the latest version of the JQuery via Google. I have read about issue's if the script is not called properly, so want to try and keep everything as close to the recommended coding as possibly. I want to make sure the script is loaded which I believe is carried out by the below PHP script in the functions.php file (taken from the Wordpress Codex).               <?php     function my_scripts_method() {     wp_enqueue_script( 'jquery' );     }      I want to basically have a custom menu using JQuery, so is it just a case of placing the script I want to activate in the header or PHP section? Also if I wanted to enqueue another script that is not included in the Wordpress already, do I simply add the below PHP to the above code in the functions.php file?               wp_register_script( 'jqueryexample', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jqueryexample.min.js');      I am ok with HTML and CSS but PHP and JAVA is relatively new to me, any help is greatly appreciated. Thanks, Ant


Custom User Field in Dashboard Widget

I checked justin tadlocks custom profile field tutorial and wanted to add the field in the custom dashboard widget but it seems it's not working. I want to show all the user information in this widget. All that I want to do is add the custom information from the profile field to this dashboard widget and it seems to be not working. My aim here to to get all author information and show it on this dashboard. Any ideas how to achieve this task?               function example_dashboard_widget_function() {     // Display whatever it is you want to show     the_author_meta();      }           // Create the function use in the action hook     function example_add_dashboard_widgets() {     wp_add_dashboard_widget('example_dashboard_widget', 'User Profile',    'example_dashboard_widget_function');     }     // Hoook into the 'wp_dashboard_setup' action to register our otherfunctions     add_action('wp_dashboard_setup', 'example_add_dashboard_widgets' );


Want to be able to sign up subscribers as authors

I want to be able to select a subscriber an author of a post in the admin so it displays their name as having written the post, but I do not want to give them any additional privileges (if they login the only thing they can access is their profile). I saw a solution up here, but when I used that hack, it left other users off of the author drop-down (e.g., contributor, etc.). In addition, I'm going to end up having 100s of contributors I want to include as subscribers/authors, but I imagine that would destroy the dropdown or make it very difficult. Any suggestions would be so welcome and thank you very much! :)


How to delete orphan userdata from array in wp-options

I have an option that subscribes members to forum email notifications. The list of emails is in an array as an option value. All is working fine and all subscribing and unsubscribing is done using `update_option();` My problem is that were a user to be deleted it would be difficult to unsubscribe him without going into the database. So I thought this function would do it but I must be missing something :               add_action( 'delete_user', 'forum_remove_deleted_user' );          function forum_remove_deleted_user($user_id)     {            $user_obj = get_userdata($user_id);               $subscbr_email = $user_obj->user_email;              if(!empty($subscbr_email)) {                                 $list = (array)get_option('mf_forum_subscribers_1');                  if(!empty($list) &&  is_subscribed($subscbr_email)) {                 $key = array_search($subscbr_email, $list);                 unset($list[$key]);             }                        }            }          function is_subscribed($subscbr_email)     {         if($subscbr_email )           {             $list = (array)get_option('mf_forum_subscribers_1');             if(in_array($subscbr_email , $list)) {               return true;             }             return false;           }          }      I'd love to know what I'm doing wrong. Otherwise I suppose I could use `$wpdb` or perhaps I should?


Perform a function to create/delete custom post only if certain user meta checkbox is set to true

I have a website where I would like all subscribers to be able to create or remove a post that says they are accepting new patients (they are doctors) by checking or unchecking a custom checkbox that I have added to their profile page. I am using using this post as a template to create my function. I can get a custom post (type = 'accepting') created no problem (if I remove the if/else statement surrounding that function). My problem lies in when I try to put the conditional statement around creating the post to only create it if the user has selected the checkbox and delete it if they unselect the checkbox in their user profile. Here is the code I used to create my checkbox in the user's profile:               add_action( 'show_user_profile', 'my_show_extra_profile_fields' );     add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );          function my_show_extra_profile_fields( $user ) { ?>

Accepting Patients Status

         Currently Accepting New Patients?	                      <input type="checkbox" name="accepting-patients" id="accepting-patients" value="true" <?php if (esc_attr( get_the_author_meta( "accepting-patients", $user->ID )) == "true") echo "checked"; ?> />             Yes

     <?php }          add_action( 'personal_options_update', 'my_save_extra_profile_fields' );     add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );          function my_save_extra_profile_fields( $user_id ) {     if ( !current_user_can( 'edit_user', $user_id ) )         return false;          if (!isset($_POST['accepting-patients'])) $_POST['accepting-patients'] = "false";           update_user_meta( $user_id, 'accepting-patients', $_POST['accepting-patients'] );     }      Here is the code for my function (that isn't working currently):               // checking to see if accepting box is checked     if ( $user = get_user_meta($user_id, 'accepting-patients', true) ) {          function create_accepting_post( $user_id = '' ) {     $user = new WP_User($user_id);     if ( ! $user->ID ) return '';          // check if the user whose profile is updating has already a post     global $wpdb;     $accepting_post_exists = $wpdb->get_var( $wpdb->prepare(      "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type = 'accepting' and post_status = 'publish'", $user->user_nicename     ) );          // you have a custom role for members?     // you should, because if not all user will have a page, also admin, subscribers...     // if ( ! in_array('accepting', $user->roles) ) return '';          $user_info = array_map( function( $a ){ return $a[0]; }, get_user_meta( $user->ID ) );     $title = $user_info['first_name'] . ' ' . $user_info['last_name'];     // of course create the content as you want     $content = 'This is the page for: ';     $content .= $user_info['first_name'] . ' ' .$user_info['last_name'];     $post = array(       'post_title' => $title,       'post_name' => $user->user_nicename,       'post_content' => $content,       'post_status' => 'publish',       'post_type' => 'accepting'     );     if ( $accepting_post_exists ) {       $post['ID'] = $accepting_post_exists;       wp_update_post( $post );     } else {       wp_insert_post( $post );     }          }          add_action( 'personal_options_update', 'create_accepting_post' );     add_action( 'edit_user_profile_update', 'create_accepting_post' );          }          else {     function remove_accepting_post() {          // check if the user already has a post     global $wpdb;     $accepting_post_exists = $wpdb->get_var( $wpdb->prepare(      "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type = 'accepting' and    post_status = 'publish'", $user->user_nicename     ) );          }     add_action( 'publish_to_trash', 'remove_accepting_post' );     }      Any help you can provide would be greatly appreciated!!


Most visited posts

I need a plugin which shows the most visited posts. I ve looked all plugins, they are working fine but the results can manipulate with refreshing. Is there any plugin that shows unique weekly visitors. Thanks in advance.


How to change picture size

How can I resize a picture I've already posted? I can click and drag the corner of the picture and it resizes the picture, but only horizontally, so the picture looks really squashed. I can also go into the advanced settings and manually change the height and width in pixels but the same still happens. What am I doing wrong?


Embedding screencast.com Videos in WordPress Multisite

I've got a multisite installation of WP 3.5.1 running, and I'd like to for users to be able to embed screencast.com videos into posts, preferably with a shortcode like you do with YouTube or Vimeo. I can do this using the full embed code from the screencast.com sharing menu, but I can only do this as a super admin. All other users have and tags stripped out of their posts. I can get around this by installing the Unfiltered MU plugin, but that's not ideal, since it allows users to put all sorts of untrusted code/tags in their posts. I've searched pretty extensively for some sort of simple plugin, and have come across this Screencast.com Video Embedder that seems idea, but it hasn't been updated in 2 years. So I'm wondering if there are any other solutions that might work for this.


Problem after updating WordPress to 3.6.1 and WooCommerce to 2.0.14

I have updated my WordPress and WooCommerce website and I am getting the following error > public_html/wp-content/plugins/woocommerce/classes/class-wc-payment- > gateways.php on line 45 Does anybody have the same problem? How do I fix this?


Custom Image Size in Insert Media

I have some custom image sizes set in my functions and it works just as one would expect, but I am would like this custom image size to be present when a user adds images to a post. You know when you add an image to a post, in the bottom area it gives you the option to choose from predefined sizes; basically I would like to add my own size to this area...is that possible?


2 WordPress install with same database

I am tring to make 2 sites (1 domain and 1 subdomain) in WordPress. Subdomain should have different logo,menu,ads..etc but both of them,same database with same article.I know it is risky for Google, but I have other plans with this. I upload wp to principal domain and subdomain. In wp-config I put same database, but the links displayed on subdomain are exactly like the ones from principal. Here is a domain example: http://wow7.ro and a subdomain one: http://lol.wow7.ro . I try to duplicate wp prefix _options table in phpmyadmin to have different siteurl, but I can not find the php file in wp structure where is the code which selects this from duplicate table.


Category page showing posts from all categories

I am trying to set up a category archive (editing category.php) that displays a list of posts from one single category. If I left the twentyten default code               (get_template_part( 'loop', 'category' );)      and i go to www.mysite.com/categoryname it correctly filters the posts only for the categoryname. If I try to use my custom query code, going to www.mysite.com/categoryname every post is displayed, despite of category. This is the loop code:                   <?php if (have_posts()) : ?>         <?php                    $args = array(                        'post_type' => 'post',                        'posts_per_page' => 5,                        'orderby' => comment_count,                        );             query_posts($args);             while (have_posts()) : the_post();?>                        MY CUSTOM CONTENT             <?php endwhile; ?>                  <?php else : ?>      <?php endif; ?>      thanks


How to delete user meta by key

I'm a beginner with WordPress plugin api, php and ajax. I'm coding a training plugin for myself to save posts article to read them later, like favourites on web browser, with folders. I use oop to do so. I assumed to create a new user meta called 'favoris', wich is an array with the users created folders. I got something like that for getting favs, creating folders and deleting'em.               /**      * Get favorites      */     public function fp_ajax_getFav(){         $current_user = wp_get_current_user();         $userid = $current_user->ID;         $folder = get_user_meta($userid, 'favoris');         $content =  '';         $content .= 'Favoris';         $content .= '';         $content .= '';         $content .= '';         $content .= '';              if (!empty($folder)) {             $content .= 'Tout supprimer';             $content .= ' _Aucun favoris._ ';         }         else{             $content .= 'Tout supprimer';             $content .= ' _Aucun favoris._ ';         }              $content .= '';              if (!empty($folder)) {             $msg = '';             foreach ($folder as $key) {                 foreach ($key as $k => $value) {                     $content .= ' ' . ucwords($value['titre']) . '     ';                 }             }         }         else{         }         $content .= '';         $content .= '';         return $content;     }          /**      * Add folder      */     public function fp_ajax_addFolder(){         $current_user = wp_get_current_user();         $userid = $current_user->ID;         $meta = get_user_meta($userid, 'favoris');         if (empty($meta)) {             if ($_REQUEST['foldername'] !== '') {                 $folder[0]['titre'] = $_REQUEST['foldername'];                 add_user_meta($userid, 'favoris', $folder);                 var_dump($folder);                 echo ucwords($_REQUEST['foldername']);                 die();             }         }         if (!empty($meta)) {             $folder = $meta[0];             if ($_REQUEST['foldername'] != '') {                 foreach ($folder as $key => $value) {                     $i = count($folder);                     if ($value['titre'] != $_REQUEST['foldername']) {                         $folder[$i]['titre'] = $_REQUEST['foldername'];                         update_user_meta($userid, 'favoris', $folder);                         var_dump($folder);                         echo ucwords($_REQUEST['foldername']);                         die();                     }                 }             }         }     }          /**      * Remove folder      */     public function fp_ajax_removeFolder(){         if ( ( !isset($_POST['folderId']) || empty($_POST['folderId']) ) && ( !isset($_POST['folderName']) || empty($_POST['folderName']) ) ) {             echo 'Pas de dossier spécifié';             die();         }         else{             $id = $_POST['folderId'];             $name = $_POST['folderName'];             $current_user = wp_get_current_user();             $userid = $current_user->ID;             $folder = get_user_meta($userid, 'favoris');             $folderToErase = $folder[0][$id];             try {                 delete_user_meta($userid, 'favoris', $folder[0][$id]);                 echo $folderToErase['titre'];                 //print_r($folder[0][$id]['titre']);             }              catch (Exception $e) {                 echo 'not ok';                 var_dump($folder);                 return $e->getMessage();             }             die();         }     }                As far as I get or create, everything goes fine. But when I want to remove a folder by key ($id), it doesn't. But when I echo the $folderToErase, the id's right. Maybe some help ?


Best way to detect if you are in a SINGLE POST page

So this may seem like a pretty menial thing, but follow me here. I'm trying to add some logic through the `pre_get_posts` action. This is the entire WP_Query object given to me. (see the end) Things I have considered using:   * `is_single()` \- too broad.   * `is_singular()` \- too early to use this, as `get_queried_object()` is not yet set.   * `$query->single` property - again too broad.   * `$query->get('post_type')` \- not set, as it's using the `name` property. is `name` really the only indicator here?               WP_Query Object     (         [query] => Array             (                 [page] =>                  [name] => abcs-of-mental-health             )              [query_vars] => Array             (                 [page] =>                  [name] => abcs-of-mental-health                 [error] =>                  [m] => 0                 [p] => 0                 [post_parent] =>                  [subpost] =>                  [subpost_id] =>                  [attachment] =>                  [attachment_id] => 0                 [static] =>                  [pagename] =>                  [page_id] => 0                 [second] =>                  [minute] =>                  [hour] =>                  [day] => 0                 [monthnum] => 0                 [year] => 0                 [w] => 0                 [category_name] =>                  [tag] =>                  [cat] =>                  [tag_id] =>                  [author_name] =>                  [feed] =>                  [tb] =>                  [paged] => 0                 [comments_popup] =>                  [meta_key] =>                  [meta_value] =>                  [preview] =>                  [s] =>                  [sentence] =>                  [fields] =>                  [menu_order] =>                  [category__in] => Array                     (                     )                      [category__not_in] => Array                     (                     )                      [category__and] => Array                     (                     )                      [post__in] => Array                     (                     )                      [post__not_in] => Array                     (                     )                      [tag__in] => Array                     (                     )                      [tag__not_in] => Array                     (                     )                      [tag__and] => Array                     (                     )                      [tag_slug__in] => Array                     (                     )                      [tag_slug__and] => Array                     (                     )                      [post_parent__in] => Array                     (                     )                      [post_parent__not_in] => Array                     (                     )                  )              [tax_query] =>          [meta_query] =>          [queried_object] =>          [queried_object_id] => 0         [post_count] => 0         [current_post] => -1         [in_the_loop] =>          [comment_count] => 0         [current_comment] => -1         [found_posts] => 0         [max_num_pages] => 0         [max_num_comment_pages] => 0         [is_single] => 1         [is_preview] =>          [is_page] =>          [is_archive] =>          [is_date] =>          [is_year] =>          [is_month] =>          [is_day] =>          [is_time] =>          [is_author] =>          [is_category] =>          [is_tag] =>          [is_tax] =>          [is_search] =>          [is_feed] =>          [is_comment_feed] =>          [is_trackback] =>          [is_home] =>          [is_404] =>          [is_comments_popup] =>          [is_paged] =>          [is_admin] =>          [is_attachment] =>          [is_singular] => 1         [is_robots] =>          [is_posts_page] =>          [is_post_type_archive] =>          [query_vars_hash] => f473ebf7f725c2627dc5fd9a1429f626         [query_vars_changed] =>          [thumbnails_cached] =>      )


Check if post/page has gallery?

I'd like to run some code only if a gallery (inserted with the `[gallery]` shortcode) has been inserted into a post/page. I did the following:               gallery_shortcode($post->ID) ?     $gallery = 1 : $gallery = 0;      However, this always sets `$gallery = 0` whether there's a gallery or not. Am I using this incorrectly?


Display Posts from Custom Post Type with Category Filters

Thanks in advance for any assistance. I have a simple 4 page portfolio site I'm trying to build for myself. The pages consist of: Home Page, Print Design, Digital, and Identity. I have created a custom post type called "portfolio" with categories: "Print Design", "Digital", and "Identity". When first visiting the site a user will see a grid of ALL posts from the custom post type (5 columns, 4 rows). I am using the following code to pull the custom post type:               <?php      $items = new WP_Query(array(     'post_type' => 'portfolio',      'posts_per_page' => 1000     ));      while ( $items->have_posts() ) :      $items->the_post();     ?>      Each post pulls the featured image into the grid with the following code:               <?php     $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' );     ?>      So far, all is well. I have a grid layout of 20 items all displaying nicely. Here is my issue and what I am trying to accomplish: The home page will always display all 20 posts just as they do now. I want the 'Print Design' page to display all 20 posts as-well BUT I want all posts outside of the "Print Design" category to be 50% opaque and not-clickable. For example: A user clicks on "Print Design" and is taken to a new page. This page displays 20 posts of which only 3 stand out and are clickable. The other 17 are grey and can't be clicked. This same idea would be setup for each additional page listed above. My thoughts are that I should be able to setup a condition that says something like: "HEY! There are 20 posts on this page! Find all the posts that aren't in category "Print Design" and use this CSS "property"!" Thanks again! This stuff is fun but also difficult... and also frustrating when I've come so far but can't complete the idea I have.


How to display admin bar when using wp_use_themes = false?

So I'm using Wordpress in a 'themeless' manner, i.e. not using a "blog" template. My site files are in the root directory (not in the theme folder), and Wordpress is installed in its own `/wordpress/` directory. The only thing my theme exists for is customization of the back-end, including re-branding and custom post types. (I'm basically avoiding plug-ins and widgets and doing a bespoke implementation of Wordpress) With this set-up, is there a way I can get the admin bar to display when my clients view the front-end pages like it normally does? NOTE: I've tried adding `wp_head()` and `wp_footer()` to no avail. I think this might have something to do with my custom file structure.


How Can i print the wp_editor field content?

Normal editor content we can call as the_content(); here, i have 3 more wp_editor fields, how can i print the code in my page?.                    <?php wp_editor( $holds, 'holds', $settings = array('textarea_rows'=>20) ); ?>


custom post template file not shown, instead all the time 404.php

i'm completely confused, want to use my own template file for a custom post type and of course i read all about this here or in the Codex (http://codex.wordpress.org/Post_Types#Custom_Post_Type_Templates ) Also i found users with the same problem ( http://stackoverflow.com/questions/14461285/what-would-make-a-custom-post- type-template-not-show-up ), and of course i already have updated the permalink page (change the setting > save > change setting to original back > save !). Nothing has worked out so far :( . What did i done ? First i register my custom post type as usual with that code:               register_post_type( 'series', array(           'supports'                => array('title', 'editor'),           'menu_position'           => 20,           'show_ui'                 => true,           'show_in_nav_menus'       => false,           'show_in_menu'            => true,           'public'                  => true,           'register_meta_box_cb'    => array($this, 'addMetaBoxes'),           'public_queryable'        => true,           'has_archive'             => true         )     );      After the registration i expected to have access to my custom template file, if i create the **single-series.php** template file inside my theme root directory. But ... boohhh. All the time my **404.php** is called instead of my desired custom template file... what (the hell) goes wrong ??? Do i forget something important ? ...argghh ! Please help. Thanks in advance!


Editing <?php the_content('Read more...'); ?>

Is there possible to automatically add for example image before first h2 in the_content ? Thank you


How to Handle CSS Organization

I notice not many people have downloaded the plugin Combine CSS. Without it, I don't know of a better way to automatically combine CSS files. I was wondering, are 99% of the developers using WordPress just working in a single stylesheet? Is there some other way to combine CSS without the Combine CSS plugin?


Plugin to install a plugin

I'm wondering if there is a way for a plugin to install other plugins directly. That means, I provide an interface for the user to click multiple plugins and download and install them directly to wp-content/plugins. Basically imagine a marketplace plugin within wordpress where users can purchase plugins FROM a plugin and install directly into their site. I would like to find out the API or any ideas on how to achieve the installation/upgrade.


I can't view or add comments

Hey, there. I just got this site up and going. http://www.paledogstudios.com It works fine except for the fact I can't seem to see past comments (this blog was imported from blogger) or add comments. I know it's the code not the settings since someone else told me but he didn't help me further. He said it was probably on the index.php Help?


e-commerce, customizing checkout process based on product

After lots of research, I'm considering using Wordpress and either the WP e-commerce plugin or the Shopp plugin. We'll also integrate with PayPal to do the actual credit card transaction. The products that we will be selling will be a combination of regular products and "odd" products that have crazy dimensions and weights. Whenever one of these "odd" products are part of the shopping cart, we want the transaction to be passed on to a sales associate. The sales associate will look at the order and provide estimated shipping information (they need to figure out how to group and package odd products with regular products, if possible). Will the two plugins that I mentioned allow you to intercept the checkout process to do this? Is this something that ecommerce plugins/engines allow you to do? I'm thinking of just tagging these "odd" products and then I would hopefully be able to "hook" into the process somewhere. (Note: I also posted this on StackOverflow but thought that this is also relevant here.)


Add widgets to available widgets section without changing the theme?

I have a client that wants to use a particular theme without modification, but will likely want to have more widgets than are available with a given theme. Is there a way to add widgets to the list of those available without modifying the theme? Thanks.


Screen options on a different computer

Is it possible to keep dashboard screen options (for instance, not showing custom fields) across computers?


Limit popular posts by days

I am using this get_posts array to retrieve top 15 popular posts by comments. The problem is that it shows those all those highly commented posts from the day posts were added into blog. So, the list sometimes changes but most of the time remains same. How can I limit/show posts of the last 7 days? This would show most commented posts of the last week. Thanks Here is my code:               global $post;          $args = array(     'orderby' => 'comment_count',     'order' => 'DESC' ,     'numberposts' => 15);          $popular_posts = get_posts( $args );          foreach( $popular_posts as $post ) :          if (has_post_thumbnail()) { ?>

     <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('widgetimg-thumb'); ?>

     <?php } endforeach; ?>


php.ini -Theme-specific settings

I'm testing a theme on a group of people. Its a microstock image selling theme. Very unique, so far, works great on most hosts. **However many people complain that that the image-processing script crashes with larger images.** It uses wideimage - http://wideimage.sourceforge.net/. This is mostly on shared hosting. Most people have dealt with it **by changing php.ini settings** and increasing memory - but this goes against the theme being a simple install-and-use situation. **I heard that it might be possible to place a php.ini file in the theme's folder** , and it would apply to all other folders. Or even in the script's folder itself. Logically I had simply upped the memory use in the script itself, but that does not appear to do much. `ini_set( "memory_limit", "1024M" )`. <\- maybe thats just freekishly too high? :D _I simply need a good fast solution to dealing with large images among varying hosts._


Create advanced portal website with sections - taxonomy usage?

I would need your help. Please let me explain my needs. I need to create a portal-based website, and I have some doubts about the right way. The homepage will contain a few "sections". Each section is dedicated to different sort of users. The users will register to this website and when registering, they have to choose in which section/sections they will register and then they can add posts appearing in these concrete sections. Each section has more subsections. Let me show you an example - imagine that you are an artist and want to write articles on my website. You are interested in painting and in sculptures. So you register and during the registration you need to apply to these two sections. Then when you are writing an article, you will choose in which section it will appear. My very raw idea - I have custom post type, which is let's say "article". But it is not important. I will register custom taxonomies, and I think I need one taxonomy for each section. So for painting I can have portrait, pop art, animals.. I don't know. Then when writing this article, I will check the taxonomy I need. Problem is - when I applied to the painting section and sculptures, I must not see the rest of the sections.. So no photography let's say.. So in general - am I able to prepare some WP-based structure for these section, to have custom taxonomy for each section and to filter the displayed taxonomies when creating the "article" depending on the sections the user is registered to? I hope it is clear for you, I am not good at explanations..... Thanks to everyone for each idea that could show me the way, I don't want complete solutions, just pointing the directions. Thanks!


Query Page Content From Theme Options?

I'm trying to create a slider where you choose what pages are shown in the slider, using a theme options panel based on the https://github.com/vauvarin/options-framework-theme That lists the pages in the options like so..               <?php     $options[] = array( "name" => "Slider One Page",                                             "desc" => "Choose page for first slide.",                                             "id" => "slide_page1",                                             "type" => "select",                                             "options" => $options_pages);     ?>      To display that page id in the theme page i use..               <?php echo of_get_option('slide_page1'); ?>      So how do in corporate that page id into a query to display the pages content? Is it possible? Thanks for any help.


Adding taxonomy terms based on custom field

I have a custom post type that I am setting up so that different sets of custom fields are displayed based on the type of post it is. Its one of three (collection, product, or variant). I have everything set up in that regard, but I am thinking that when designing my templates to display different data depending on the input type, it may be easier to do it if I had the input type defined as a taxonomy. So I would like to update my post with the corresponding taxonomy that relates to the input type. I came up with this, but it is not doing the trick. To clarify, my taxonomy:               function set_tax_terms() {         global $wpdb;         $post_id = $wpdb->get_results ('SELECT ID FROM wp_hyhg_posts WHERE post_type = uc-collections' , object);              foreach ($post_id as $id) {             //get the input_type meta              $term= get_post_meta( $id, 'input_type', true );             //get the term id that matches the input type             $term_id = term_exists( $term, 'input' );             //set the post term based on above results             wp_set_post_terms( $id, $term_id, 'input', true );          }     }          set_tax_terms();      Any ideas? Based on another post, I also tried this method with no success. (I am putting this code in a snippet plugin btw, so I can easily activate it and deactivate.)               function set_tax_terms() {                       $args = array('post_type' =>'uc-collections');                         $post_id=get_post( $args );              if($post_id) {             foreach ($post_id as $id) {                 //get the input_type meta                  $term= get_post_meta( $id->ID, 'input_type', true );                 //get the term id that matches the input type                 if(!empty($term)) {                     $term_id = term_exists( $term, 'input' );                     //set the post term based on above results                     wp_set_post_terms( $id->ID, $term_id, 'input', true );                  }             }         }     }          set_tax_terms();      EDIT: For some reason I am not getting the code set up below to work. So I'm trying to figure out how things are related in the database. In the term table: my term_id/ slug relationship for the items in question are : 57/ collection, 58/product, 59/ variant. This is what I would assume would be in the term_relationships table, but that doesnt seem to be the case. I see object_id and term_taxonomy_id, one example being 3838 / 67 which corresponds to a post That I defined a term for, and the term_taxonomy table. I am seeing that there is a term_taxonomy_id, and then term_id as 67 / 59 which would be my variant selection. I guess i'm not sure why there are two different numbers in this case. I dont know why this doesnt want to work. Guess im going do it manually.


Load script only in the admin page

I used the Custom Category Post Order plugin in my Wordpress site. But this plugin load 4 times jquery ui code in. This jQuery ui code generate errors in my own javascript code. Is it posible to load only the jquery ui script in the admin page in wordpress. Of is that not possible.?


Wordpress Loop Prob

![This is my code snapshot](http://i.stack.imgur.com/Uq5pT.jpg) im using this code to get the posts of the categories but the problem is this code is getting one less value than actual if there are total 5 post its getting 4 any when can plz check it .......... another thing is for first row it works properly but for second row it gets one less post


Calendar active state when on a post?

I am using the calendar as navigation for a blog. My main issues is when you click a day from the calendar: 1) it goes to that day's archive page instead up first post of that day. 2) when you get to a post's page the calendar does not show you current the month your in (it defaults to current month in reality). 3) the calendar also does not have active class on the day your currently viewing. Any help?


How can I attach a gallery to a post with a short code?

I would like to attach an image gallery to a post. Here how i am trying to do it:   * from the posts administration page i click on: add new media -> create gallery   * Select the images and click to: create new gallery After that i dont have a button: "Save gallery", i have just "insert gallery", but this add the shortcode to the content of my post. I would like to include the gallery like an "object" in my template using wordpress API. If i remove the shortcode from the post content i loose completely my gallery... Is there a way so?


Add post tag without post id

How can I add a new Tag without an post-id? wp_set_post_tags() needs a Post-Id, but a client want import Post-Tags without assignment to a post (for choosing later into the posts).


Setting up widgets in wordpress with a unique ID for the after_title argument

I try to get the collapsible-widget-area plugin so that every widget it creates inside the collapsible area has a unique id `<div>` after its title.               function get_args() {         $this->args = apply_filters( 'collapsible-widget-area-args', array(             'name'          => __( 'Collapsible Widget Area', 'collapsible-widget-area' ),             'id'            => 'collapsible-widget-area',             'description'   => __( 'Drag widgets into this area in order to use them inside of the Collapsible Widget.', 'collapsible-widget-area' ),             'before_widget' => '
',             'after_widget'  => '
',             'before_title'  => '
',             'after_title'   => '

',         ) );         $this->sidebar_id = $this->args['id'];         if ( ! class_exists( 'collapsible_widget' ) ) {             require_once( 'class.collapsible-widget.php' );         }         add_action( 'widgets_init', array( $this, 'register_widget' ) );     }      This is the function that sets the args, but as far as i understand it, it is only called one time and the arguments apply to every widget. Can somebody tell me now to use seomthing like the `%1$s` for the `before_widget` or even better the exact same value in the `after_title`? The entire plugin can be viewed at in the wordpress plugin svn, the function i am shoing above is in the class.collapsible-widget-area.php and the only thing i added so far is the `<div id="i_want_to_be_a_unique_id_for_every_widget_but_i_am_not"></div>`. This is not a "write me a programm" question, its just a example i give. Maybe there needs to be a complete other solution to accomplish this, or its very easy to do with this plugin wich already extends wordpress widget class, i don't know.


Alter the reset password link

after clicking on the reset password option in WP, we're getting this link               wp-login.php?action=rp&key=[theKey]&login=testing>      instead of getting this can we alter it to something link to out custom page?


Plugin dont work after W3 Total Cache and Wordpress Update - Error

After the latest W3 Total Cache and WP Update (3.9) one of my plugins to create images don´t work. This error shows up after i create and publish the post (image) in the front end: > Warning: copy(/var/www/vhosts/dotdotododood.com/httpdocs/custom-wp-content- > name/plugins/xyzplugin/images/soft/9111397677283.jpg): failed to open > stream: No such file or directory in > /var/www/vhosts/dotdotododood.com/httpdocs/custom-wp-content- > name/plugins/xyzplugin/output.php on line 73 This is the code from the mentioned file:                               $_pid = wp_insert_post( $my_post );                 $filename = $apath;                      $wp_upload_dir = wp_upload_dir();                 $upath = $wp_upload_dir['path'];                 $ufile = $upath .'/'. basename($filename);     This is line 73-->  copy( $filename, $upath .'/'. basename($filename) );                 $filename   = $ufile;                    $wp_filetype = wp_check_filetype(basename($filename), null );                 $attachment = array(                      'guid' => $wp_upload_dir['url'] . '/' . basename( $filename ),                       'post_mime_type' => $wp_filetype['type'],                      'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ),                      'post_content' => '',                      'post_status' => 'inherit'                 );      Update: i debug my site and get this error: > Warning: Cannot modify header information - headers already sent by (output > started at /var/www/vhosts/ccccccccccc/httpdocs/wp-includes/wp-db.php:1342) > in > /var/www/vhosts/xxxxxxxxxx.com/httpdocs/xxxxxxx/plugins/xxxxxxxxxx/generator.php > on line 104 When i deactivate W3 Total Cache the Plugin works again. Any idea? Thank you so much


Show Child Taxonomies in Posts Dropdown

I've written a simple dropdown script and I am looking to expand it to include the child taxonomies and posts. I'm not quite sure how to accomplish checking if there are child categories for `$tax_slug` and to list them if they exist. My goal is to make it look like this:                   Post 1 (Submits post ID)         Post 2 (Submits post ID)         Child Taxonomy (Links to taxonomy page)         -Post 3 (Submits post ID)         -Post 4 (Submits post ID)      Current Code:
         $tax_slug = 'interior';     $args = array(         'post_type' => 'manufacturer',         'orderby' => 'title',         'order' => 'ASC',         'tax_query' => array(             array(                 'taxonomy' => 'product_category',                 'field' => 'slug',                 'terms' => $tax_slug;             )         )     );     $the_query = new WP_Query( $args ); ?>              <?php if ( $the_query->have_posts() ) : ?>
Interior
                           <form action="<?php bloginfo('url');?>" method="get">           <select onchange="return this.form.submit()" name="page_id" id="page_id">             <option value="">Select a Brand</option>             <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>             <option value="<?php echo $post->ID; ?>"><?php the_title();?></option>             <?php endwhile; ?>           </select>           </form>                                           <?php wp_reset_postdata(); ?>              <?php else:  ?>
<?php _e( 'Sorry, no posts matched your criteria.' ); ?>
         <?php endif; ?>


Hide a div to subscribers(user role) in one page (is_page)

Hello have been looking at this for quite a while and cant seem to resolve it was hoping someone more familiar with the wordpress core and php could share some idea. What I want to accomplish essentially is to Hide a div that permits buddypress users (the subscrivers) from adding new topics to a group forum. But I dont want this to be hidden from all the forums just 1 of them. So I need 2 pieces 1 that determines whether someone is a subscriber or an admin. so its only hidden to the subscriber. and 2 that it hides it from only 1 page. Example of potential code just need to fit it together (all code would go in the functions.php unless there is another way)               <?php /* If this is the frontpage */ if ( is_home() || is_page() ) { ?>     have info link or whatever in here     <?php } ?>       Thats for the frontpage but similarly you can get the page by ID For role I saw this               is_admin()      I would assume there is a               is_subscriber()      and from there you can do an if in the php something like if is_subscriber() and is_page( 42 ) call .js file and from there add a class that hides the div I want to hide by jquery Thats as far as I got from what I know and looking around. I would greatly appreciate any and all assistance.


Plugin to set all Posts in a certain Category to a certain Post Format

I want to setup my WordPress so that whenever I create a post with the category "Tweet", my wordpress installation automatically changes the post format from post to aside. This will help me because I want to use my wordpress for posting longer than 140 tweets to my twitter feed. The posting to twitter has been setup and it works. The problem is that the Wordpress iOS app doesn't allow me to change the post format to Aside, so the only thing I can do is set the category of the post to "Tweet" and as soon as my wordpress receives it, it changes the post to aside. I found the plugin "Set Aside" but it lets me change the post formats for all posts of a certain category that have already been posted, not the ones that I will post in the future. Is this possible?


Temporary capability for current_user_can()

Is it possible to intercept calls to current_user_can() ? Example: `current_user_can('rate', $post_id)` There's no "rate" capability registered, but could I somehow hook into that function and do my own checks, without having to register a role capability?


Change image size when inserting Media?

When you insert media with the media upload, it will generate images of several sizes according to the media settings. But sometimes I only need thumbnails. Other times I only need medium images. If each post has images that aren't being used, it waste space. Is it possible to select custom image size to be generated when you open Insert Media?


how to return only custom fields using get_posts()

I'm trying to get only the fields that I need using the `get_posts()` function in Wordpress. I currently have the following code:                   $posts_args = array(             'orderby' => 'post_date',             'order' => 'DESC',             'post_type' => 'post',             'post_status' => 'publish',             'posts_per_page' => 5,             'fields' => 'ids'         );              $post_ids_r = get_posts($posts_args);      This works fine if I only want to get the id. But if I want to get the permalink or the title of the post along with the ids that's where I'm not sure what to do. I already tried the following:               'fields' => array('ids', 'post_titles')     'fields' => 'ids,post_titles'     'fields' => 'ids,titles'     'fields' => array('ids','titles')      But nothing works, I guess the only one that it recognizes is the `ids` field. Is there any other way to do this if its really not possible to do it using `get_posts()`? Thanks in advance.


How to cache a shortcode functions output?

I would like to show on my startpage the total count of posts in a WordPress Multisite. Those are nearly 7000 in 500 Blogs. So I made a function which has to go through every blog to count the posts. Of cause that need a lot of time so this function isn't very useful. But is there a way to say that it should cache the output for let's say 1 Week?! Here's my code:               function posts_count_func( $args ){              global $wpdb;         $blogs = $wpdb->get_results( $wpdb->prepare(                 "SELECT * FROM {$wpdb->blogs} WHERE  spam = '0'                  AND deleted = '0' AND archived = '0'                  ORDER BY registered DESC, 2", ARRAY_A ) );              $original_blog_id = get_current_blog_id();               $args = array(             'numberposts'     => -1,             'post_type'       => 'post',             'post_status'     => 'publish' );         $total_network = $draft_network = 0;         $total_sites = 0;              foreach ($blogs as $blog)         {             wp_cache_flush();             switch_to_blog( $blog->blog_id );             $args['post_status'] = 'publish';             if (count(get_posts($args))<2) { continue; }             $total_posts = count( get_posts( $args ) );             $total_network += $total_posts;             $total_sites += 1;                  $args['post_status'] = 'draft';                  }           return $total_network;           switch_to_blog( $original_blog_id );     }     add_shortcode( 'posts', 'posts_count_func' );      Thank you so much and have a good time!


Creating a Link Text like Submit Button in Admin Page

I'm making an admin page for my plugin and I'd like to make a text link designed like the form button of admin pages. I tried this but didn't work well. `Submit` I also tried just putting a submit button, expecting that the page goes to the url in the action attribute.               <form action="$url" target="_self">         <input type="submit" class="button-primary" value="Submit" />     </form>      Does anybody know how?


after server upgrade, if I enable custom permalinks, my /feed stops working

I have recently moved server and upgraded my wordpress install to the latest version. Now if I try to access /feed, I get a 404. It used to work. /?feed=atom works correctly. Thanks. **UPDATE** : I fixed it. Virtual host definition had AllowOverrides turned off, so .htaccess was not being picked up. Thanks all for the comments.


Hide page title in Wordpress 3.0

I can't find the option to hide the page title. Is there some other plugin required to get this functionality? If you look in this video video you can see the option to set the page title. I don't have this option. I'm not looking for a code solution here, I need something which will allow end users to hide the title.


How Facebook.com knows about duplicate pages on my site?

I have facebook Like Button and I use Wordpress 3.4.1. I notice if I make "like" on URL like http://example.com/{post_type}/{post_slug}/ facebook knows about copy of this page on URL http://example.com/?{post_type}={post_slug}. I see that Like Button is on and off on these pages simultaneously. And I don't understand why. I've disabled <link rel="canonical"> tag. I've looked for HTTP-headers like "Link" or "Canonical" or something else on my pages and I have had nothing about it. I have no Open Graph Protocol on my site. But facebook.com knows that these pages are just duplicates. Where is the answer?


Secondary Sort (fallback) for WP_Query

What I'm after is creating a secondary (or default) `orderby` option for a custom query. Here is what I have:               $post_args = array(         'post_type' => $taxfunc_post_type,         'meta_key'  => '_mouldings_dimensions_height',         'orderby'   => 'meta_value_num',         'order'     => 'ASC',         'paged'     => get_query_var('paged'),         'tax_query' => array(             array(                 'taxonomy'         => $taxfunc_tax_name,                 'field'            => 'id',                 'include_children' => 0,                 'terms'            => $term_id             )         ),         'meta_query' => array(             array(                 'key' => 'special_profile',                 'value' => $special_logic_serialized             )         )     );      What I'd like to do is if `_mouldings_dimensions_height` is `NULL`, then default back to `title`. I did see Jan's answer on this, which does appear to be related, but I think I'm after the opposite. Ideally, I'd also be checking for just this query with `query_var['post_type']` as the original questioner asked, but am not sure I am approaching this correctly. Any nudges in the right direction would be greatly apprecaited. Thanks! _Update_ After a bit more testing, it appears to list the oldest first as a fallback when the meta value is the same across multiple posts (NULL in this case) -- looking to change this behavior.


bbPress or WordPress + forum plugin?

I've been using bbPress for a while and I've noticed some bugs in my fresh installs. This makes me wonder if I should consider to just use WordPress with a forum plugin. Any experience building a bbPress website? Do you recommend a WordPress plugin to build forums?


Adding data to an array in usermeta and displaying it in a loop

I have a front end post form where I take a file upload of an image. That image gets stored as a custom field which is easy enough to do. What I need to do though is store each unique image url for each user into an array in their usermeta. I want to do this so I can show them a list of those images they've already uploaded and give them the option of choosing one of those instead of uploading a new one. So to elaborate I have a basic file upload choice in my form.               <input type="file" name="music_image" id="music_image"/>      Beneath this I need a check box select showing them the images of any others they have uploaded and somehow make it so if they choose a file they can't select an image an vice versa. And then I need to add the uploaded file to an array as usermeta on form submit. Awful explanation but I think it makes sense. Here is what I use to activate the form.                <?php if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&  $_POST['action'] == "new_post") {     if ( ! function_exists( 'wp_handle_upload' )) {                  require_once(ABSPATH . "wp-admin" . '/includes/image.php');                 require_once(ABSPATH . "wp-admin" . '/includes/file.php');                 require_once(ABSPATH . "wp-admin" . '/includes/media.php');     }     $file=$_FILES;     // Do some minor form validation to make sure there is content     if (isset ($_POST['title'])) {         $title =  $_POST['title'];     } else {         echo 'Please enter a game  title';     }     if (isset ($_POST['description'])) {         $description = $_POST['description'];     } else {         echo 'Please enter the content';     }     $tags = $_POST['post_tags'];          // Add the content of the form to $post as an array     $new_post = array(         'post_title'    => $title,         'post_content'  => $description,         'post_category' => array(11),         'tags_input'    => array($tags),         'post_status'   => 'publish',           // Choose: publish, preview, future, draft, etc.         'post_type' => fod_music  // Use a custom post type if you want to     );     $overrides = array( 'test_form' => false);     $uploaded_music = wp_handle_upload( $file['music_file'], $overrides );     $uploaded_music_art = wp_handle_upload( $file['music_image'], $overrides );      //save the new post and return its ID     $pid = wp_insert_post($new_post);     update_post_meta($pid,'music_code',$uploaded_music['url']);     update_post_meta($pid,'music_art',$uploaded_music_art['url']);     wp_redirect( get_permalink($pid));      exit();          }      do_action('wp_insert_post', 'wp_insert_post');     ?>


How to enumerate a list of posts?

I've created a page with a list of posts from a specific category. I would like to enumerate this list like this:   * lecture 1: post title 1   * lecture 2: post title 2   * lecture 3: post title 3   * etc. How can I do this? Thanks


List Category Posts rewrite necessitates rewrite of customised templates

I just upgraded the List Category Posts plugin from .17 to .18.3, and it broke my customised template :(. My setup: WP 3.0.4 multisite network enabled, local installation with MAMP, PHP 5.3.2. LCP plugin installed automatically. Works fine with the default template. However, you've rewritten the code such that the template had to be rewritten also. I've managed, with a bit of a struggle (not strong in PHP), to tweak the default template and save it as my own customised template, and now it's displaying as I want. I think this needs to be pointed out in documentation accompanying the updates. One feature you've added - which I really appreciate - is to allow access to templates either in the parent theme or child theme. Thank you, this is working very well, and the best solution to the problem of whenever we update Wordpress. Now, if only I can get the thumbnail to display. :(


How to retrieve the value stored in a multi-dimensional array and SUM the entries?

I'm trying to retrieve multidimensional values stored in user_meta where the meta key is my_posts and the meta_value is > a:3:{i:0;s:2:"23";i:1;s:2:"20";i:2;s:1:"9";} Somewhere in the admin page i want to show the sum of the selected posts which are stored in the value above....