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


How can I open WP rich editor within colorbox in the front end?

I have a site on which I've created a form to add new posts. The form opens in colorbox and I want it to contain a rich editor. I've added this code:               <?php     $args = array('textarea_rows' => 15, 'media_buttons' => false);     wp_editor( '', 'editor_content_1', $args );     ?>      instead of a textarea. The WP editor is displayed but the rich editor buttons does not appear and it doesn't work well. You can see the actual site here - link directly to that element. The "colorbox" opens when pressing the `\+ Add New` button This is the Button, it's around 2/3 of the page ![enter image description here](http://i.stack.imgur.com/tvhku.png)


JetPack comment threads are displaying above comment box?

As you can see in the attached image (http://i.imgur.com/V7642.png) my JetPack comments are rendering above the Discuss box. How do I go about moving them down? When I look in Chrome Inspector there doesn't even seem to be any Class or ID for me to latch onto to bring them down. In my theme I am using the following code to place the entire comment form:               <?php comments_template( '', true ); ?>


Cannot locate specific <a href> link/string using String Translation with WPML?

I have added a link on the footer of my page in the format `<a href="URL">Link</a>` I would like to allow wmpl to translate it in french and have tried scanning my theme but the link's text doesn't appear in the string translation manager in the dashboard. After reading this: http://wpml.org/faq/language-setup/ I have tried wrapping the link in gettext but do not know how to add an href link into this line of Php: ## How could I do that?


show tags on "single"-template sidebar only

If a post has tags, I would like to show only those tags as a list in the sidebar when viewing the single post; how do I do this? I have searched to find a suitable plugin, but didn't find one, as all the ones I've looked up end up showing every tags on the site or for categories. I'm happy to go with a non-plugin solution.


How to get custom image sizes into media uploader dropdown?

I searched net to solve the problem with images size uploaded from media. But not even one worked to me. When I try to insert images from the media into post it does not show my custom image size 608 X 350 px               function setup_image_sizes() {         if ( function_exists( 'add_image_size' ) ) {             add_image_size( 'post-image', 608, 350, true );         }              function post_image_sizes($sizes){             $custom_sizes = array(                 'post-image' => 'Post Image'             );             return array_merge( $sizes, $custom_sizes );         }              add_filter('image_size_names_choose', 'post_image_sizes');     }          add_action( 'after_setup_theme', 'setup_image_sizes' );      please advise me


Running WordPress on low-end hardware/resources?

I knew about Atom-based dedicated servers, but these plug-class servers take it to whole new level of low-end extreme. Most of WordPress optimization talk is about surviving on shared hosting or scaling up. I got curious - how viable is it to run WordPress on such low-end, but dedicated hardware? At which point will CPU or slow storage become bottleneck? How will it compare to generic shared hosting (even lower resources, but no neighbors and freedom to optimize).


Adding Page Attributes Metabox and Page Templates to the Posts Edit Page?

_( **Moderators note:** Title was originally "How can I add the "Page Attributes" and/or "Page Attributes > Template" selector to POSTS editor")_ WP currently only allows the assignment of a "template" to Pages (i.e. `post_type=='page'`.) I'd like to extend this functionality to Posts as well (i.e. `post_type=='post'`.) How can I add the _"Page Attributes"_ meta box and more specifically, the template switcher to the posts editor? I'm assuming this is code I will place in my `functions.php` for my theme. UPDATE: I've managed to add the hardcoded templates pulldown menu to my post editor, by simply adding the select box html to my existing custom meta options box. Here's the code I'm using for that...               add_meta_box('categorydiv2', __('Post Options'), 'post_categories_meta_box_modified', 'post', 'side', 'high');      And here's the function that writes out the options and the template select box...               //adds the custom categories box     function post_categories_meta_box_modified() {         global $post;         if( get_post_meta($post->ID, '_noindex', true) ) $noindexChecked = " checked='checked'";         if( get_post_meta($post->ID, '_nofollow', true) ) $nofollowChecked = " checked='checked'";     ?>

<input value="noIndex" type="checkbox" name="chk_noIndex" id="chk_noIndex"<?php echo $noindexChecked ?> /> noindex

<input value="noFollow" type="checkbox" name="chk_noFollow" id="chk_noFollow"<?php echo $nofollowChecked ?> /> nofollow

Template
          Post Template<select name="page_template" id="page_template">          <option value='default'>Default Template</option>          <option value='template-wide.php' >No Sidebar</option>         <option value='template-salespage.php' >Salespage</option>         </select>
     <?php     }      And finally, the code to capture the selected values on save...               function save_post_categories_meta($post_id) {         if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id;         $noIndex = $_POST['chk_noIndex'];         $noFollow = $_POST['chk_noFollow'];         update_post_meta( $post_id, '_noindex', $noIndex );         update_post_meta( $post_id, '_nofollow', $noFollow );         return $post_id;     }      Now, I believe all that's left is (1) capturing the selected template and adding it to the post meta for this post and (2) modifying index.php and single.php so that it uses the chosen template.


Facebook-like Notification Plugin for WordPress Community Blog Sites?

I am a member of a community blog site run by WordPress engine. But I often feel that if there were a notification system like Facebook tracking the site would be much easier. I know about the notification emails and RSS feeds but those do not serve the whole purpose. I need to have notification when:   * Somebody comments on any of my blog posts.   * Somebody comments after any of my comments in any posts.   * My blog post is rated. Almost like Facebook. Is there any plugin for that?


Analytics plugins that allow for inclusion of _trackPageLoadTime()?

Are there any plugins that allow one to make use of the _trackPageLoadTime(); functionality available in the new version of Google Analytics yet?


Preventing Duplicating Posts from Widgets

I am making a theme that has the main loop in a widget. Also widgetized is a feature slider and a display of four feature post boxes, each with their own loop. How do I prevent duplicate posts from appearing in my main loop widget when the other feature widgets are also displayed? I know I have to declare a global variable and assign that variable an array of the posts IDs from the feature widgets I want to exclude from my main loop widget. Below is the sample code from the three widgets. Feature Slider Loop:               <?php global $themename_do_not_duplicate;     $themename_do_not_duplicate = array();     $arr = array();     $i=1;     $width = $instance['ImgWidth'];     $height = $instance['ImgHeight'];     $cat_posts = new WP_Query("showposts=" . $instance["featuredNum"] . "&cat=" .       $instance["cat"]);     while ($cat_posts->have_posts()) : $cat_posts->the_post() $themename_do_not_duplicate[] = $posts->ID;?>
<a href="<?php the_permalink();?>">                 <?php                 $post_title = get_the_title();                 $thumbnail = get_thumbnail($width,$height,'thumb',$post_title,$post_title);                 $thumb = $thumbnail["thumb"];                 print_thumbnail($thumb, $thumbnail["use_timthumb"], $post_title, $width, $height, 'thumb'); ?>

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

         <?php endwhile; wp_reset_query();   ?>      A loop from another Feature loop - this widget actually has four loops like the one below:               <?php query_posts("showposts=1&cat=".get_catId($instance['catOption4']));                        while (have_posts()) : the_post(); $themename_do_not_duplicate[] = $post->ID;?>          stuff             <?php endwhile; wp_reset_query(); ?>      The main loop widget               <?php global $themename_do_not_duplicate;           if ($instance['NoRepeatPost'] == 1)   {$arrgs=array('posts_per_page'=>$instance['postNum'],'post__not_in' => $themename_do_not_duplicate,'paged'=>$paged,);}  else {$arrgs=array('posts_per_page'=>$instance['postNum'],'paged'=>$paged,);}     query_posts($arrgs);          if(have_posts()) : while (have_posts()) : the_post();$themename_do_not_duplicate[] = $post->ID; //begin the loop ?> stuff  <?php endif;wp_reset_query(); //and so ends the loop ?>      I have put the `global $themename_do_not_duplicate` in the header. What do do, oh what to do?


How to debug a plugin with Xdebug?

I was able to install and setup quite easily NetBeans 6.9.1 and Xdebug on my local environment, based on PHP 5.3.0 (XAMPP). My problem now is the following: if I put a breakpoint on Wordpress's index.php or other Wordpress core PHP files, NetBeans correctly stop at desired position. If instead I put a breakpoint on a plugin file, an trigger the code execution NetBeans does not stop there. Do you known how can be solved? **UPDATE:** More info about what I am trying to debug Plugin is called **Vanilla Forums** and has the following file structure:               - plugins       - vanilla-forums         + assets         + nbproject         + templates           admin.php           embed.php           functions.php           hooks.php           plugin.php           sso.php           widgets.php      I set the breakpoint inside a function named `vf_validate_options` defined in `functions.php`. I am sure that this function is executed, but NetBeans does not break there.


Login with OpenID, similar to Stack Exchange sites?

Basically, I would like to add something like this into my WordPress site (which obviously will also give the user an option to sign up for an account using WordPress' default sign up system): ![Stack Exchange login system with OpenID](http://i.stack.imgur.com/dOBzo.png) Is there any plugin or tutorial that may be helpful to accomplish this?


Remove duplicate main - submenu in admin?

When I use `add_menu_page` & `add_submenu_page` to add menu items,               add_menu_page( 'Forms', 'Forms', 'administrator', 'forms', 'forms_job_menupage_cb' );     add_submenu_page( 'forms', 'Job Applications', 'Job Applications', 'administrator', 'job-applications', 'forms_job_menupage_cb' );     add_submenu_page( 'forms', 'Quote Requests', 'Quote Requests', 'administrator', 'quote-req', 'forms_req_menupage_cb' );     add_submenu_page( 'forms', 'Contact', 'Contact', 'administrator', 'contact', 'forms_contact_menupage_cb' );      I will get something like   * Forms      * Forms     * Job Applications     * Quote Requests     * Contacts Is it possible to create it such that it becomes   * Forms      * Job Applications     * Quote Requests     * Contacts In other words Forms will link to Job Applications and I dont want the extra Forms submenu item


Poedit not able to create a catalogue

I'm trying to translate my plugin using poedit. I have following code in main plugin file:               <?php              /*         Plugin Name: FixFormData         Description: If you want to autocomplete a form with existing data, this plugin is for you.         Version: 1.1         Author: Stijn Aerts         Text Domain: ffd         Author URI: http://stijnaerts.be         License: GPL2         */          require( plugin_dir_path( __FILE__ ) . 'menu.php');     require_once( plugin_dir_path( __FILE__ ) . 'getuser.php');          add_action( 'wp_enqueue_scripts', 'ffd_load_scripts');          function ffd_load_scripts()     {         load_plugin_textdomain('ffd', false, dirname(plugin_basename(__FILE__)));     }      In menu.php is the string I'm trying to translate:               public function page_init()         {                     register_setting(                 'fixformdata_group', // Option group                 'fixformdata_options', // Option name                 array( $this, 'sanitize' ) // Sanitize             );                  add_settings_section(                 'setting_section_id', // ID                 'FixFormData options', // Title                 array( $this, 'print_section_info' ), // Callback                 'my-setting-admin' // Page             );                    add_settings_field(                 'tablename',                  __('Table name', 'ffd'),                  array( $this, 'title_callback' ),                  'my-setting-admin',                  'setting_section_id'             );     }      Where the string I try to translate is:               __('Table name', 'ffd'),       However when I use poedit to create a catalogue, this fails, he says he can't find any strings to translate. What am I doing wrong?


Disable wp-admin console for subscribers

I do not want the users (role: subscriber) to be able to login via the wp- admin. How would you suggest I do this ?


Child Pages Loop

If anyone can help that'd be great. I've found a snippet of code that I've used which is pretty much doing what I want it to do, which lists out subpages of the parent, adds a thumbnail if there is one, and added a custom excerpt. However, the problem is that I can't add individual `<?php post_class(); ?>` to a div inside the loop, its using the class from the parent and repeating for the subpages.               <?php     $child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = ".$post->ID."    AND post_type = 'page' ORDER BY menu_order", 'OBJECT');    ?>     <?php if ( $child_pages ) : foreach ( $child_pages as $pageChild ) : setup_postdata( $pageChild ); ?>          <?php     // Must be inside a loop.     if ( has_post_thumbnail($pageChild->ID) ) {     get_the_post_thumbnail('page-thumb-mine');     }     //  else {     //  echo '';     //  }     ?>          <div <?php post_class(); ?>>         <?php echo get_the_post_thumbnail($pageChild->ID, 'page-thumb-mine'); ?>
<a href="<?php echo get_permalink($pageChild->ID); ?>" rel="bookmark" title="<?php     echo $pageChild->post_title; ?>"><?php echo $pageChild->post_title; ?>
     <?php echo excerpt(28); ?>

     <?php endforeach; endif;     ?>      Any help would be appreciated! Thanks Andy


How can I delete all users which have never commented / have posted spam comments?

My user database is full up with robots. Is there a useful SQL command to delete all the users that either a) have posted a comment marked as spam by Akismet or b) never posted a comment ?


The normal loop with different styles doesn't work in search.php

This code in the search.php file does not work:               <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>     <?php if( get_post_type() == 'post' ) {?>

<a href="<?php the_permalink() ?>"><?php the_post_thumbnail( 'thumbnail', $attr ); ?>

     <?php foreach((get_the_category()) as $category) {      echo '
cat_name. '">term_id ).'">' . $category->cat_name . '
';}?>
     <a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>">
<?php the_title(); ?>

Escrito por <?php the_author_posts_link(); ?> el <?php the_time('d/m/Y') ?> a las <?php the_time('G:i'); ?>

<?php comments_number('0 Comentarios', '1 Comentario', '% Comentarios' );?>

     <?php the_excerpt() ?>
<a href="<?php the_permalink() ?>">Continuar

     <?php } if( get_post_type() == 'articulo' ) {?>

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

     Escrito por <?php the_author_posts_link(); ?> el <?php the_time('d/m/Y') ?> a las <?php the_time('G:i'); ?>
<?php comments_number('0 Comentarios', '1 Comentario', '% Comentarios' );?>

     <?php the_content(false); ?>
<a href="<?php the_permalink() ?>">Continuar

          <?php } else; endwhile;?>     <?php endif; ?>


Add Post Screen Keep Category structure

So on the add post screen in wordpress there is the category checkbox div. Before you select a category for your post it shows the correct hierarchical structure as defined in the category admin screen. After selecting a category and saving the post it will put your selected category at the top of the list instead of keeping the structured layout. Is there a way to stop it from doing this?


Fatal error: Call to undefined function get_header() and BuddyPress

I've run into this error today and I can't find anyway to get past it. Fatal error: Call to undefined function get_header() in /members/index.php on line 1 The site is running WP 3.2.1 and BuddyPress 1.2.9 and uses the Arras 1.5.1.2 theme. The error only appears on the BuddyPress index page (http://towermix.com/home/members), but the rest of the site and the other parts of BuddyPress work as advertised. I've looked at that index.php file, which is came from the BuddyPress Template Pack plugin (and makes any theme BuddyPress compatible) and it's nothing unusual for a theme header call. Here's the file:               <?php get_header() ?>

                  <form action="" method="post" id="members-directory-form" class="dir-form">
<?php _e( 'Members Directory', 'buddypress' ) ?>
                      <?php do_action( 'bp_before_directory_members_content' ) ?>
                     <?php bp_directory_members_search_form() ?>

<a href="<?php bp_root_domain() ?>"><?php printf( __( 'All Members (%s)', 'buddypress' ), bp_get_total_member_count() ) ?>
                              <?php if ( is_user_logged_in() && function_exists( 'bp_get_total_friend_count' ) && bp_get_total_friend_count( bp_loggedin_user_id() ) ) : ?>
<a href="<?php echo bp_loggedin_user_domain() . BP_FRIENDS_SLUG . '/my-friends/' ?>"><?php printf( __( 'My Friends (%s)', 'buddypress' ), bp_get_total_friend_count( bp_loggedin_user_id() ) ) ?>
                         <?php endif; ?>                              <?php do_action( 'bp_members_directory_member_types' ) ?>
                                  <?php _e( 'Order By:', 'buddypress' ) ?>                             <select>                                 <option value="active"><?php _e( 'Last Active', 'buddypress' ) ?></option>                                 <option value="newest"><?php _e( 'Newest Registered', 'buddypress' ) ?></option>                                      <?php if ( bp_is_active( 'xprofile' ) ) : ?>                                     <option value="alphabetical"><?php _e( 'Alphabetical', 'buddypress' ) ?></option>                                 <?php endif; ?>                                      <?php do_action( 'bp_members_directory_order_options' ) ?>                             </select>

                     <?php locate_template( array( 'members/members-loop.php' ), true ) ?>
                      <?php do_action( 'bp_directory_members_content' ) ?>                      <?php wp_nonce_field( 'directory_members', '_wpnonce-member-filter' ) ?>                      <?php do_action( 'bp_after_directory_members_content' ) ?>                  </form>

              <?php locate_template( array( 'sidebar.php' ), true ) ?>          <?php get_footer(); ?>        * So far, I've reinstalled the 3.2.1 update from Dashboard - no change.   * I copied the /members/index.php from another site (that's working fine) - no change    * I deactivated, then reactivated BuddyPress - no change    * I added the semi-colon after the () - no change    * I uploaded and overwrote the wp-admin and wp-includes folder - no change. What's truly bizarre - I even commented that line out and I still get the same error. There are no caching plugins installed. I flushed my browser cache, so that's not it. Any ideas?


display custom post on separate page

I have been able to register a new post type. 'code' and now I would like to display it. I added               add_filter( 'pre_get_posts', 'my_get_posts' );          function my_get_posts( $query ) {     if ( is_home() )         $query->set( 'post_type', array( 'post', 'page', 'album', 'movie', 'quote', 'code', 'attachment' ) );         return $query;     }      but this makes it show with other blog posts. I want a new page that only displays 'code' posts. I created a file single-code.php but I dont think this is correct. How do I create a new page that just shows code posts?


Is there an easy way to separate themes on network?

Assume we have a multisite network. All sites in the network are separated into groups by some option value. What I want to do is to separate network available themes to be available to specific groups. For instance, I have `A-Z` themes installed. I want to activate `A-K` themes to group 1, `L-O` themes to group 2 and `P-Z` themes to group 3. Is there an easy way to do it?


Recent posts headlines. How to optimize the loop

I'm using this in my page template to display the 20 recent posts headlines from category number 8, 17, 23, 423

Football

Ice Hockey

Basketball

Tennis

          <?php $cat_array=array(23,17,8,423);           foreach ($cat_array as $catid) {            $args = array( 'category' =>$catid, 'numberposts' => 20 );            $myposts = get_posts($args); ?>
              <?php foreach($myposts as $post) { ?>              <a href="<?php the_permalink(); ?>"><?php the_title(); ?>
              <?php } ?>
          <?php } ?>

      But this code adds more than 15 database queries. Without this code page makes 26 db queries and with it 46. Is it possible to optimize?


wp_hash_password unexpected behaviour

When I run `wp_hash_password("password")` twice the outputs are different. I was under the impression that this is not how hashes are supposed to work. So how should I use `wp_hash_password` to compare two hashes?


Cannot update .../tags folder in SVN Repository

Could you please supply (I'm stupid) step by step process of what I'm trying to do? Thanks! I uploaded my first plugin using tortoiseSVN. With some difficulty, I got the files into the /tags dir but I need to update/overwrite. I really only want to present version 1.0. I added *.01, etc versions because was I was not able to overwrite. I need to update readme and the .php file, and ideally, to version 1.0. Thus, okay (but I don't know how) to delete the tag files from server, or worst case, make version 1.03, etc. Here it is: https://plugins.svn.wordpress.org/responsive-mini-storage- calculator/ Thanks!


Using Posts Like a Page

I'm working on a client project and they would like to use posts much like we would traditionally use pages due to there being a limited number of pages one WordPress install can handle and the ability to categorize posts more efficiently. The problem I'm running into is the client would like there to be child posts for each post, much like a child page. I have to be able to both **title the child posts** and **present them in a menu on the parent post and child posts of the parent** (the same menu on both the parent and child post). I considered wp_link_pages, but that does not allow a menu of child posts nor real titling of each child post. I hope somebody has a solution they may be willing to share.


pre_get_posts Tax Query not working for custom author page

I am using the theme TwentyTwelve and modified the standard post query in the file author.php with the following code:               function wpd_author_query( $query ) {     //CODE to set $current_user_name here     //This gets the author from the URL     $author = get_user_by('slug',get_query_var('author_name'));     $current_user_name = $author->user_nicename;              if ( $query->is_author() && $query->is_main_query()) {                 // your code to set $current_user_name here                 $query->set( 'meta_key', '_writer_relation_added_date_'.$current_user_name );                 $query->set( 'orderby', 'meta_value_num' );                 $query->set( 'post_status', $post_status );                      $tax_query = array(                       array(                         'taxonomy' => 'writer',                         'field' => 'name',                         'terms' => $current_user_name                     )                 );                 $query->set( 'tax_query', $tax_query );         }                    }     add_action( 'pre_get_posts', 'wpd_author_query' );      However, the tax_query is not working for the author page. It is still not retrieving the posts in the writer taxonomy. I did try applying that code for other pages such as is_home() is_archive() and it does work. So, there must be a conflict in with wordpress and the author template page that is not allowing me to use the tax_query for retrieving posts in the writer taxonomy.


WordPress Network Feature

I have to create a simple network of websites (different sub-domains) using WordPress. There are just going to be 3 or 4 such websites. I know that WordPress MU was integrated directly within WordPress 3.0 and I can create a Network and use it. Are there any pitfalls or disadvantages that I should be aware of if I go for this route? Or, generally what are your thoughts on WP 3 Networks?


Is it better practice to use 'This Name Format' or 'this-name-format' for custom fields?

I've seen in various tutorials where people white the custom field Name in this fashion: intro-image. I thought I would make more sense to use (user friendly names instead of something that looks like a variable). Is using hyphen (or underscore) a good practice?


Custom Field is getting the value of another page/post instead of the current one?

I'm using this same come in two files: `single.php` and `home.php`: (Outside of the loop). (There is a `#mainbar` div in both **single posts** and **home page** but the image should be different)               <?php // Set and display custom field             $mainbar_right_title = get_post_meta($post->ID, 'Mainbar Right Title', true);             $mainbar_right_image = get_post_meta($post->ID, 'Mainbar Right Image', true); ?>

<?php echo $mainbar_right_title; ?>
                 <img src="<?php echo $mainbar_right_image ?>" alt="" />
 <?php         ?>
      I thought the **home page** would get the value of its own custom field but instead is getting the value of the **single post**. Is this a default behaviour or I'm doing something wrong? **EDIT:** I tried adding a value to another single post and the image is indeed the one of the post not of the another so the problem is only the home page. home.php:               <?php     /**      * Template Name: Home      * @package WordPress      * @subpackage Prominent      * @since Prominent 1.0      */     get_header(); ?>          <?php get_sidebar(); ?>
         <?php // Insert image using custom field             $postimageurl = get_post_meta($post->ID, 'Intro Image', true); ?>
                 <img src="<?php echo $postimageurl; ?>" alt="Post Pic" />
 <?php         ?>              <?php // Start the Loop             if ( have_posts() ) while ( have_posts() ) : the_post();         ?>
                 <?php the_content(); ?>
              <?php endwhile; // end of the loop. ?>              <?php // Create and run custom loop             $custom_posts = new WP_Query();             $custom_posts->query('post_type=blocks&location=Front Page&section=Mainbar');             while ($custom_posts->have_posts()) : $custom_posts->the_post();         ?>

<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>
         <?php endwhile; ?>                  <?php // Set and display custom field                 $mainbar_left_title = get_post_meta($post->ID, 'Mainbar Left Title', true);                 $mainbar_left_image = get_post_meta($post->ID, 'Mainbar Left Image', true); ?>

<?php echo $mainbar_left_title; ?>
                     <img src="<?php echo $mainbar_left_image ?>" alt="" />
 <?php             ?>                  <?php // Set and display custom field                 $mainbar_right_title = get_post_meta($post->ID, 'Mainbar Right Title', true);                 $mainbar_right_image = get_post_meta($post->ID, 'Mainbar Right Image', true); ?>

<?php echo $mainbar_right_title; ?>
                     <img src="<?php echo $mainbar_right_image ?>" alt="" />
 <?php             ?>
              <?php // Create and run custom loop             $custom_posts = new WP_Query();             $custom_posts->query('post_type=blocks&location=Front Page&section=Sidebar');             while ($custom_posts->have_posts()) : $custom_posts->the_post();         ?>

<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>
                 <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail(); ?>
<?php the_excerpt(); ?>

<?php echo get_post_meta($post->ID, "Other_Work", true); ?>

         <?php endwhile; ?>              <?php // Create and run custom loop             $custom_posts = new WP_Query();             $custom_posts->query('post_type=blocks&location=Front Page&section=Featured');             while ($custom_posts->have_posts()) : $custom_posts->the_post();         ?>

<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>
                 <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail('large'); ?>
<?php the_excerpt(); ?>

         <?php endwhile; ?>              <?php // Create and run custom loop             $custom_posts = new WP_Query();             $custom_posts->query('post_type=blocks&location=Front Page&section=Content');             while ($custom_posts->have_posts()) : $custom_posts->the_post();         ?>

<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>
                 <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail(); ?>
<?php the_excerpt(); ?>

<?php the_meta(); ?>

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


Pretty permalinks and Facebook comments

I have pretty permalinks enabled like this:               http://domain.com/category/post_name      I also use facebook comments widget for the comments, Currently the `href` attribute is set to the pretty permalink by calling `the_permalink()`. The issue is that if i ever happen to edit the post name (slug) or the category, Facebook thinks it's a new URL so the old comments are not displayed anymore. I tried fixing the issue by pointing the `href` to the non-pretty permalink like: `http://domain.com/?p=XXX` but now Facebook shows a warning that it can't reach the URL, that's because WP redirects non-pretty urls to pretty with a 301 redirect. Any idea how to work around this?


Get all the contents of taxonomy and sort by term

I'm doing this in a page template. So far, I can query all the contents under my taxonomy. But I need to sort them in terms of their term. Any idea on how to do this? Providing an example would be very much appreciated.


Storing state between hook functions

I have two functions which I'm hooking into a plugin. Both functions are called (at different times) during a single page creation by the server. I want to set a flag in function_a which can be read by function_b. **Question: Is there any problem with just declaring my flag in the global scope? Is there a preferred WP-style for doing this?** ps. I realize that I will need to be defensive when function_b reads the flag --by making sure that the value was explicitly set, etc.


Only display authors who have posts

I am using the code below to display all authors and their posts (in a custom post type called "publication"). This works, however it also lists users who do not have posts. How can I adapt this code to only show authors who have posts? Thank you!
Articles by Author
              <?php          $allUsers = get_users('orderby=title&order=ASC&post_type=publication');         $users = array();         // Remove subscribers from the list as they won't write any articles         foreach($allUsers as $currentUser)         {             if(!in_array( 'subscriber', $currentUser->roles ))             {                 $users[] = $currentUser;             }         }         ?>              <?php foreach($users as $user) { ?>

<?php echo $user->display_name; ?>
               <?php query_posts( array( 'post_type' => 'publication', 'showposts' => -1, 'author'=>$user->ID ) ); while (have_posts()) : the_post(); ?>                 <?php the_content(); ?>                 <?php endwhile; ?>
              <?php } ?>      UPDATE: Using the function from the answer below and a few things I read last night, here's what I have now (still not working as requested above, but wanted to give you my most recent code):               <?php           // count number of Articles (CPT) written by a user     function count_user_posts_by_type( $userid, $post_type = 'publication' ) {         global $wpdb;         $where = get_posts_by_author_sql( $post_type, true, $userid );         $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" );         return $count;               $post_count = count_user_posts_by_type($userid, $post_type);     $allUsers = get_users('orderby=title&order=ASC&post_type=publication&role=author');     $users = array();          // CONDITIONAL -- IS THIS CORRECT?     if ($post_count > 0 ) {          // Remove subscribers from the list as they won't write any articles     foreach($allUsers as $currentUser)     {         if(!in_array( 'subscriber', $currentUser->roles ))         {             $users[] = $currentUser;         }     }     foreach($users as $user) { ?>
<?php echo $user->display_name; ?>
           <?php query_posts( array( 'post_type' => 'publication', 'showposts' => -1, 'author'=>$user->ID, 'orderby' => 'date', 'order' => 'DESC' ) );       while (have_posts()) : the_post(); ?>             <?php the_content(); ?>             <?php endwhile; ?>               <?php } } ?>


Issue with RSS Feed in Firefox and Safari

The feed for a site (http://www.affordabledrumlessons.com/feed/) shows fine in Google Chrome, but in Firefox and Safari it gives errors. I've tried clearing the cache, but that doesn't solve the issue. Any idea what could be causing the problem?


Customise the add media pop-up to include rel attribute option

So many jQuery light boxes these days use the 'rel' attribute to identify objects that should be targeted. Unfortunately when it comes to Wordpress, when inserting a thumbnail/link, to add a rel attribute you have to either edit the html source code or pull up a separate pop-up after the initial insert. This makes the process complicated for some less confident users. What I want to be able to do is include, in the insert media pop-up, a checkbox to add a rel='lightbox' attribute to the tag when inserted. While I am quite confident when it comes to theme development, I wouldn't know where to start modifying Wordpress admin functionality. Can somebody point me in the right direction?


the_excerpt(), get_the_excerpt() and the_content() all killing "the Loop"

Before I call the_excerpt(), the_permalink() displays the correct thing. Afterwards, it does not...                           <?php                  global $query_string;                      //strip out the "pagename=blog" so that the query will grab all of the posts instead of the content of the blog page                 $query_string = preg_replace("/pagename=[a-zA-Z0-9]*/", "", $query_string);                 query_posts( $query_string . "posts_per_page=3" );                      if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

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

Posted on <?php print get_the_date(); ?> by <?php the_author(); ?> in <?php the_category(', ') ?>
                                                                   <?php the_excerpt(); ?>
<?php the_tags('') ?>

<a class="alignright" href="<?php the_permalink(); ?>">READ MORE »

                  <?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
                 <?php endif; ?>      I have a page called "blog.php" that I have defined as a Template named "blog" that people can apply to a page they create (so that they can have a blog listing page, I know there is probably a better way, but this is the solution that was gone with for various reasons). It was working just fine, but now (a month after I wrote it) it suddenly stopped working. I have narrowed the problem (I think) down to the the_excerpt() call. The permalink displays fine before that, but afterwards craps out and instead displays the permalink for the blog.php page... I think that the_excerpt() is throwing everything completely out of "The Loop" and then the current post it sees just becomes the page that uses the blog.php template (it spits the contents of that page out and then stops as if that page were the last post in The Loop). This also happens if I replace "the_excerpt()" with "the_content()" or "get_the_excerpt()"


How to enable a site administrator to edit users in a WordPress network/ multisite setup?

I have a few sites in a network. I don't want the site administrators to manage things like network plugins, but I would like them to be able to edit profiles of all network users, not use those on their site. At the top of the `/wp-admin/network/users.php` file is this:               if ( ! current_user_can( 'manage_network_users' ) )         wp_die( __( 'You do not have permission to access this page.' ) );      How can I grant site administrators priviledges to `manage_network_users` without promoting them to Super Admin? Here's what the code is looking like:                    /**      * Retrieve a list of super admins.      *      * @since 3.0.0      *      * @uses $super_admins Super admins global variable, if set.      *      * @return array List of super admin logins      */     function get_super_admins() {         global $super_admins;              if ( isset($super_admins) )             return $super_admins;         else             return get_site_option( 'site_admins', array('admin') );     }                         /**      * Determine if user is a site admin.      *      * @since 3.0.0      *      * @param int $user_id (Optional) The ID of a user. Defaults to the current user.      * @return bool True if the user is a site admin.      */     function is_super_admin( $user_id = false ) {         if ( $user_id )             $user = new WP_User( $user_id );         else             $user = wp_get_current_user();              if ( empty( $user->id ) )             return false;              if ( is_multisite() ) {             $super_admins = get_super_admins();             if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins ) )                 return true;         } else {             if ( $user->has_cap('delete_users') )                 return true;         }              return false;     }                             /**          * Whether user has capability or role name.          *          * This is useful for looking up whether the user has a specific role          * assigned to the user. The second optional parameter can also be used to          * check for capabilities against a specfic post.          *          * @since 2.0.0          * @access public          *          * @param string|int $cap Capability or role name to search.          * @param int $post_id Optional. Post ID to check capability against specific post.          * @return bool True, if user has capability; false, if user does not have capability.          */         function has_cap( $cap ) {     #       fb($cap);             if ( is_numeric( $cap ) ) {                 _deprecated_argument( __FUNCTION__, '2.0', __('Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead.') );                 $cap = $this->translate_level_to_cap( $cap );             }                  $args = array_slice( func_get_args(), 1 );             $args = array_merge( array( $cap, $this->ID ), $args );             $caps = call_user_func_array( 'map_meta_cap', $args );                  // Multisite super admin has all caps by definition, Unless specifically denied.             if ( is_multisite() && is_super_admin( $this->ID ) ) {                 if ( in_array('do_not_allow', $caps) )                     return false;                 return true;             }                  // Must have ALL requested caps             $capabilities = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args );             $capabilities['exist'] = true; // Everyone is allowed to exist             foreach ( (array) $caps as $cap ) {                 //echo "Checking cap $cap       ";                 if ( empty( $capabilities[$cap] ) || !$capabilities[$cap] )                     return false;             }                  return true;         }      Code from users.php in wp-admin showing a second capability check for editing network users:               // Only allow super admins on multisite to edit every user.     if ( is_multisite() && ! current_user_can( 'manage_network_users' ) && $user_id != $current_user->ID && ! apply_filters( 'enable_edit_any_user_configuration', true ) )         wp_die( __( 'You do not have permission to edit this user.' ) );


Wordpress tables and aliases?

I have imported some tables from my online wordpress database to my local to work on. However now I am getting some weird sql errors that I don't get online. I can see that the code of the plugin I am working on has some references (aliases?) that don't appear to reference anything that I see when I do a search:               $result = $wpdb->get_row( 'SELECT re.*                                         FROM ' . EVENT_ESPRESSO_RECURRENCE_TABLE . ' re                                         INNER JOIN ' . EVENTS_DETAIL_TABLE . ' ed                                         ON re.recurrence_id = ed.recurrence_id                                         WHERE re.recurrence_id = ' . $recurrence_id .                             ' ORDER BY ed.start_date ASC                                         LIMIT 1', ARRAY_A );      What is table 're'? In re.recurrence_id?


Calling Permalinks With PHP

I'm developing a theme which supports WordPress' post formats. As a result I am using a big if statement, which can be found below.   * I would like to link my post titles to the posts while maintaining my theme as XHTML valid.   * I would like to call images (with classes) in the if statement while maintaining my theme as XHTML valid.   * I would appreciate if somebody could add the appropriate code to the following code to do so _               if ( has_post_format( 'video' )) {                     echo the_title();                     echo the_excerpt();     }      **EDIT: Basically, the most important thing I'm looking for is that it calls the post name as a link which links to the actual post.**


get_the_post_thumbnail() returns nothing?

Here's my code:                   function widget($args, $options) {         extract($args);              global $post;         $post_type = $options['post_type'];         $num_of_posts = $options['limit'];              // Create a new instance         $second_query = new WP_Query( array(                             'post_type' => "$post_type",                             'posts_per_page' => "$num_of_posts",                             'post_status' => 'publish',                         ) );               // The Loop         if ($second_query->have_posts()) :           while( $second_query->have_posts() ) : $second_query->the_post();               $content .= '' . get_the_title($post->ID) . '';               $content .= '
' .get_the_post_thumbnail($post->ID, array(290,290)). '
';               $content .= '
' . get_the_excerpt() . '
';           endwhile; else :               $content = '
No ' . $options['post_type'] . 's found.
';         endif;         wp_reset_postdata();              $title = "
" . $options['title'] . "
";              echo $before_widget.$title.$content.$after_widget;     }      Everything displays fine except the thumbnail :-\


Wordpress Tiny MCE won't accept line breaks

Encountered an infuriating issue where I f i want to add multiple linebreaks   for layout between paragraphs, Wordpress doesn't recognize them in th wysiwig editor. If I enter them in the code window, and publish they DO save, but the next time the Wysiwig is edited and published those breaks disappear. is there a workaround or a plugin hat lets Tinymce handle this better?


Including a PHP file via a function that is part of a plugin?

I struggled with this all day, and now am here... I have a contact form generated by including a php. Presently, I have this code in my theme's index.php to include it:               if ( is_page('contact') ) {         include("../contact.php");     }      which renders and functions as expected: http://www.derekbeck.com/1775/contact/ However, editing this into the theme is problematic because of theme upgrades (I have to hard code it back in each time) and now, especially, because I'm using a mobile theme for mobile users, who will not see my contact form when they use the mobile theme. Bottom line: I need to put this into a plugin. I know the mechanics of making a plugin, that's not my question. My question is: I cannot seem to figure out a way to properly include the above via a function in my plugin file. For instance, I've tried this:               add_shortcode( 'ContactForm', 'ContactInsert' );          function ContactInsert() {            $file = include(ABSPATH . "../contact.php");            return $file;     }      And I place the shortcode [ContactForm] into the body of my test page, but it renders strange results: http://www.derekbeck.com/1775/test/ (ignore the "1" and "2" which I added for testing) If I make it simply               function ContactInsert() {            ob_start();            include(ABSPATH . "../contact.php");            return ob_get_clean();     }      I get no results on the page, and only have of the theme displays. What am I doing wrong? Thanks! (PS: If I were to simply paste all of that included contact.php into my plugin page, it might work, but it is a very long file, and I have other reasons to keep it separate.)


Wordpress Page Protect forwards to Admin Login

Once I upgraded to WP 3.4.1, the password protect feature stopped working correctly. The password submit form leads to /wp-login.php?action=postpass and displays the admin login screen. I've sought out answers around the web to no avail, and I've tried disabling all plugins, and still no dice. Does anyone have a solution?


Best way of adding CSS which can be manipulated by the user via theme option panels?

I thought about adding it as inline CSS with code from the `functions.php` (not really sure how to do it). Something like this:               function addcss() {        background: $this_is_the_css_value;     }      I would like to know that. But if there's is a better option (without adding inline CSS). I would like to know it too.


wp_list_pages() refuses to output posts

Someone help me understand why the following do not output anything:               wp_list_pages( 'post_type=post' )     wp_list_pages( 'post_type=event' )      Yet the following work as expected:               wp_list_pages( 'post_type=page' )     WP_Query( 'post_type=post' )     WP_Query( 'post_type=event' )      I'm stumped.


WP frontend output of custom textarea fields not respecting line breaks. In admin it's OK

WP frontend output of custom textarea fields not respecting line breakes. In admin it's OK. Right now I am using this:               <?php $options = get_option('my_custom_plugin_options'); ?>     <?php echo $options['my_custom_plugin_options_textarea']; ?>      The output in frontend is this: > Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris aliquet > elementum mi, ac adipiscing metus suscipit in. Quisque venenatis ante non > nulla faucibus viverra. In ultrices nisl sit amet quam commodo ut feugiat > magna aliquet. Aenean sit amet odio magna. Maecenas pretium ante a urna > dictum vel dignissim erat porta. Aenean rhoncus elementum nisi, nec euismod > est tempus commodo. Instead of saved: > Lorem ipsum dolor sit amet, consectetur adipiscing elit. > > Mauris aliquet elementum mi, ac adipiscing metus suscipit in. > > Quisque venenatis ante non nulla faucibus viverra. > > In ultrices nisl sit amet quam commodo ut feugiat magna aliquet. Aenean sit > amet odio magna. > > Maecenas pretium ante a urna dictum vel dignissim erat porta. Aenean rhoncus > elementum nisi, nec euismod est tempus commodo. In admin it is saved with as many line breaks and it's OK. How to do it in my frontend too?


How to use get_results() in widget front end?

I'm trying to get_results() in my widget's front end, this is my current code:               public function widget( $args, $instance ) {         echo $args['before_widget'];         if($children = $wpdb->get_results( "SELECT ID FROM $wpdb->posts" ))              echo "working";         echo $args['after_widget'];         }      However I'm getting error "Fatal error: Call to a member function get_results() on a non-object". I need to access the database to create a menu with the page children. What's am I doing wrong?


Help with shortcode in admin-ajax

I've been playing around with ajax in wordpress and I've gotten my efforts to work on both back and front-end without too much trouble, however I've run into a problem getting post shortcodes to run when loading `post_content` to the front-end. Here's what I've noticed:               apply_filters( 'the_content', $content );      ..will run but it only wraps my shortcode in `<p>` tags, the way it does in the admin. `do_shortcode()` will work when using `[gallery]` or other native wordpress shortcodes, but not the one i've registered in my plugin. My plugin shortcode does however run in the normal wordpress post page (not ajax). Having read about this, I'm aware that **admin-ajax.php** has **WP_ADMIN** set to **true** and so I think that what happening is that `apply_filters( 'the_content', $content );` runs differently depending on whether `is_admin` or not. Either that or native shortcodes and plugin shortcodes `add_shortcode()` are registered differently and not accessible in the same places. Does anyone have any insight on what's going on here? Much appreciated.


Getting error of unexpected output during activation

I have seen one plugin named `lordlinus business hours` Here is the link for that http://wordpress.org/plugins/lord-linus-business-hours/ When I am trying to install it, I am getting error :               The plugin generated 2 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.      How can I resolve this error, please help me


query_posts thumbnail condition

I am trying to call in all posts in the current category, showing their thumbnail or 'featured image'. The code below does not work, it throws out a syntax error...                           <?php $temp_query = $wp_query; ?>                 <?php foreach(get_the_category() as $category) {                     $cat = $category->cat_ID; }                     query_posts('orderby=date&cat=' . $cat . '&order=ASC&posts_per_page=-1'');                  ?>                 <?php while (have_posts()) : the_post(); ?>
                             <?php                                 if ( has_post_thumbnail() ) {                                         the_post_thumbnail();                                     } else {                                             echo '';                                 }                             ?>
                 <?php endwhile; ?>      ...however, this code does retrieve the thumbnail;                           <?php $temp_query = $wp_query; ?>                 <?php foreach(get_the_category() as $category) {                     $cat = $category->cat_ID; }                     query_posts('orderby=date&cat=' . $cat . '&order=ASC&posts_per_page=-1'');                  ?>                 <?php while (have_posts()) : the_post(); ?>
                             <?php the_post_thumbnail(); ?>
                 <?php endwhile; ?>      Can someone explain to me what it is i am doing wrong and why this occurs? It may also help me answer another question; How can i create a condition inside this call to say 'if post has tag... do... if post has other tag... do...' Thanks guys!


Security and .htaccess

About a month ago I started a WordPress blog on a hosted server related to a hobby. So, I am new to this at present. Since I'm concerned about security, one thing I did was to install the plugin WP Security Scan. According to the plugin results, my site checks out except that I get this in the results as a red flag: > The file .htaccess does not exist in wp-admin/ (I ssh'd in there and it does > not exist) Ok, so I did a considerable search on the issue and find too much info on .htaccess. I've been through Hardening WordPress on the WordPress.org site, etc. And also ran into this article: http://digwp.com/2010/07/wordpress- security-lockdown/ Anyway, I've basically gotten confused with the plethora of information available. **What should the .htaccess file in wp-admin contain?** I've read that this .htaccess file should password protect the wp-admin directory and I've also read that this can cause functionality problems. Help with this is greatly appreciated. Thanks. -wdypdx22 **Update** Ok, so I'm not logged in to my blog and using a different computer than usual. I enter the url www.mysite.com/wordpress/wp-admin/ and there is a redirect to login. If that's what happens, then is an htaccess file even needed in the wp-admin directory?


Modifying Search to Exclude results from within short code or HTML

I've been struggling with this one for some time and I was wondering if anyone has any ideas on how to fix this. I'm not asking about stripping out short codes or HTML from the excerpt, that's fairly straight forward, what I'm asking about is as follows. Say your search word is "align" and you hit search. I'm getting results where the word align appears in either html or a short code. How do I exclude these results while still returning results that have the word in the normal text i.e. exclude < p class="alignleft"> or [shortcode align=left] while showing "The font was aligned left as a test of the align function in html"


Custom page in archive page for certain category

In my archive page I want a certain category not to display. The rest of the code I'm adding, but it goes to a custom page The logic is like, if is `category=33`, then include photo.php

<?php if (have_posts()) : ?>     <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>     <?php /* If this is a category archive */      if (is_category()) {              ?>        <?php           _e('', 'bilanti'); ?>         '<?php echo single_cat_title(); ?>'          <?php _e('Archive For', 'bilanti'); ?>                                               <?php /* If this is a tag archive */           } elseif( is_tag() ) { ?>        <?php _e('Archive for the', 'bilanti'); ?>         <?php single_tag_title(); ?> Tag            <?php /* If this is a daily archive */          } elseif (is_day()) { ?>       <?php _e('Archive for', 'bilanti'); ?>        <?php the_time('F jS, Y'); ?>                                                 <?php /* If this is a monthly archive */        } elseif (is_month()) { ?>       <?php _e('Archive for', 'bilanti'); ?>       <?php the_time('F, Y'); ?>                                                <?php /* If this is a yearly archive */         } elseif (is_year()) { ?>      <?php _e('Archive for', 'bilanti'); ?>       <?php the_time('Y'); ?>            <?php /* If this is a search */          } elseif (is_search()) { ?>         <?php _e('Search Results', 'bilanti'); ?>              <?php /* If this is an author archive */              } elseif (is_author()) { ?>             <?php _e('Author Archive', 'bilanti'); ?>                  <?php /* If this is a paged archive */         } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>              <?php _e('Blog Archives', 'bilanti'); ?>                                                 <?php } ?>
         <?php get_template_part( 'post-excerpt' ); // Post Excerpt (post-excerpt.php) ?>             <?php else : ?>
404 not found
       <?php endif; ?>
      What should the exact code be?


Programmatically set 'meta_query' for filter

I am trying to set 'meta_query' programaticaly for a filter which is supposed to filter a custom post type depending on the existence of a metakey. I have tried several ways, which I have left in the below code, commented out. None of the solutions change the actual $query 'meta_query' property, which stubbornly remains set to 'false'. I have a feeling that i'm missing something basic. Please assist. Thank you.               add_filter( 'parse_query', 'filter_posts_by_no_associated_contact' );     function filter_posts_by_no_associated_contact( $query ) {          global $pagenow;          $qv = &$query->query_vars;          if( $pagenow == 'edit.php' &&         isset($qv['post_type']) && $qv['post_type'] == 'act'          && isset($_GET['contact_status']) && $_GET['contact_status'] != '' ){              $compare = ( $_GET['contact_status'] == 'with_contact' ) ? 'EXISTS' : 'NOT EXISTS';              // $query->meta_query[] = array(         $metaquery = array(                 'key'       => 'contact_associated',                 'value'     => 'justAstring',                     'compare'   => $compare,                 'type'      => 'CHAR'         );              $query->set( 'meta_query', $metaquery );              }          }      i have seen this done elsewhere:               $qv = &$query->query_vars;     $qv['meta_query'] = array();     $qv['meta_query'][] = array(       'field' => 'meta-key',       'value' => $whatever,       'compare' => '',       'type' => ''     );      But this solution results in a php "Warning: Attempt to modify property of non-object".


Hops / redirects delay loading site

I notice my site is quite slow to load when bypassing server and browser cache. The delay can be anywhere between 4 and 20 seconds. Take the login page as an example and looking in Firebug, I can see where the delay is coming from. The hops are: /login (http) /wp-login.php (http) /login/ (http) /login/ (https) ![redirects](http://i.stack.imgur.com/HFsGR.png) I'm using 'Theme my login' plugin to use my own templates instead of the standard WordPress login page, so that explains the jump from /login to /wp- login.php. I'm also forcing the login page to https, so that explains that jump. Is there a way I can make this more efficient and reduce the delays as much as possible?


Long running action from plugin

I'm creating a WordPress plugin that will copy posts data to a remote database, I know it will take a while to transfer all the posts. How should I create copy functionality so it won't timeout? Ideally it would run in background and show some notification on completion.


How do I define a lookup table that will work across all PHP elements of the template?

I'm using a lookup table to define a few things for the qTranslate plugin **Table**               $trans_home = array('en' => 'Home','it' => 'Home','de' => 'Home','zh' => '首页','es' => 'Página de inicio','fr' => 'Page d\'accueil');     $trans_company = array('en' => 'Company','it' => 'L\'azienda','de' => 'Firma','zh' => '公司','es' => 'Empresa','fr' => 'Société');      **Code calling up lookup table**               echo $trans_home[qtrans_getLanguage()];     echo $trans_company[qtrans_getLanguage()];      I thought that if I put the lookup table in the header file I would be able to call on the table throughout the template, but it seems I need to define the lookup table in each part of the template I need it in, so for example I would have to define the table in both in the header and footer for it to work. So the question is how do I define a lookup table that will work across all PHP elements of the template?


Custom Taxonomy drop downs for parents and child

I have taxonomies like Cities and they have child sub taxonomies. I have a code that display as metabox on post publish page. But I want to display on front page as search filter. How can I do that? Thanks in advance. functions.php               add_action('add_meta_boxes', 'my_custom_metabox');      function my_custom_metabox() {         add_meta_box('custom-taxonomy-dropdown','Brands','taxonomy_dropdowns_box','post','side','high'); } function taxonomy_dropdowns_box( $post ) {         global $brand_taxonomy, $taxonomy_name;         wp_nonce_field('custom-dropdown', 'dropdown-nonce');         $terms = get_terms( $brand_taxonomy, 'hide_empty=0');         if ( is_a( $terms, 'WP_Error' ) ) {             $terms = array();         }              $object_terms = wp_get_object_terms( $post->ID, $brand_taxonomy, array('fields'=>'ids'));         if ( is_a( $object_terms, 'WP_Error' ) ) {             $object_terms = array();         } ?>                  <?php         echo "Brand:";         echo "<select id='custombrandoptions' name='custombrands[]'>";         echo "<option value='0'>None</option>";         foreach ( $terms as $term ) {             if ( $term->parent == 0) {                 if ( in_array($term->term_id, $object_terms) ) {                     $parent_id = $term->term_id;                     echo "<option value='{$term->term_id}' selected='selected'>{$term->name}</option>";                 } else {                     echo "<option value='{$term->term_id}'>{$term->name}</option>";                 }             }         }         echo "</select>
";         echo "
Loading...
";         echo "
";         echo "Models:";         echo "<select id='custommodeloptions' name='custombrands[]'>";         if ( isset( $parent_id)) {             $models = get_terms( $brand_taxonomy, 'hide_empty=0&child_of='.$parent_id);             foreach ( $models as $model ) {                  if ( in_array($model->term_id, $object_terms) ) {                     echo "<option value='{$model->term_id}' selected='selected'>{$model->name}</option>";                 } else {                     echo "<option value='{$model->term_id}'>{$model->name}</option>";                 }             }         }         echo "</select>";         echo "
";     }          add_action('save_post','save_my_custom_taxonomy');     function save_my_custom_taxonomy( $post_id ) {         global $brand_taxonomy, $taxonomy_name;         if ( define('DOING_AUTOSAVE') && DOING_AUTOSAVE )             return;              if ( !wp_verify_nonce($_POST['dropdown-nonce'], 'custom-dropdown'))             return;              $brands = array_map('intval', $_POST['custombrands']);         wp_set_object_terms($post_id, $brands, $brand_taxonomy);     }           add_action('wp_ajax_get_brand_models', 'get_brand_models');     function get_brand_models() {         global $brand_taxonomy, $taxonomy_name;         check_ajax_referer('custom-dropdown', 'dropdown-nonce');         if (isset($_POST['custombrand'])) {             $models = get_terms( $brand_taxonomy, 'hide_empty=0&child_of='. $_POST['custombrand']);             echo "<option value='0'>Select one</option>";             foreach ($models as $model) {                 echo "<option value='{$model->term_id}'>{$model->name}</option>";             }         }         die();     }      source: https://gist.github.com/hameedullah/997350


How to access the WordPress DB from a plugin file

I'm building a basic video management plugin, with an embed feature that will have URLs like: mysite.com/wp-content/plugins/embed-video.php?video=[POST ID] I plan on using the [POST ID] url parameter to query the database and retrieve the relevant information for the embeds (stored in custom fields). However, because the file is referenced directly WP isn't being loaded. Could anyone tell me what the best (and correct) way to load WordPress (and its DB) directly from this file would be? I don't even know where to start with this, so any help or insight would be greatly appreciated.


wp_schedule_event won't accept args

I'm trying to schedule event on hourly basis but it doesn't work. Why, I can't understand. Here is a function that i use to schedule event.               add_action( 'scheduled_update_feeds', 'update_feeds', 10, 2 );          function scheduled_activation() {         wp_schedule_event( time(), 'everyhour', 'scheduled_update_feeds', array( 0, 'everyhour' ) );     }     register_activation_hook( __FILE__, 'scheduled_activation' );      Per my understandings this should activate on plugin activation and pass schedule event based on my settings. When I use it **without array args it works** , but I need to use args to pass them my scheduled function. And this is the function               function update_feeds($ids = false, $timing = false) {         do something     }      When i use it like this it works.               wp_schedule_event( time(), 'everyhour', 'scheduled_update_feeds' );      Even if I don't use args in my update_feed function it doesn't work either. The strange thing is that when I use single schedule it works. like this               wp_schedule_single_event( time() + 10, 'scheduled_update_feeds', array($ids) );      So I don't get it why it won't work. And I did defined 'everyhour' in my scheduled list.               add_filter( 'cron_schedules', 'my_schedule' );           $schedules['everyhour'] = array(         'interval' => 60,         'display' => __( 'Every hour', 'easy-video-grabber' )     );      I checked its existance with the _Cron Schedules_ plugin and the schedule exists.


Correct code to use php in text widget

This code is used to display php inside a text widget               add_filter('widget_text','execute_php',100);     function execute_php($html){         if(strpos($html,"<"."?php")!==false){                              ob_start();                              eval("?".">".$html);             $html=ob_get_contents();             ob_end_clean();          }     return $html;     }      I'm currently using it in my theme. I'm constantly looking for better ways to do things. Every google search and website returned tells you to use this code or code similiar to this. With one google search I came up with this question How to allow PHP In WordPress text widget. One user came up with code similiar to this to which @Mark Kaplun commented that it will break anything that starts with `<?` My question now is, I like to use the text widget to quickly test code like say something like related posts before coding it into my theme. Creating a shortcode here is unneccesary. Is there a better way to allow php in a text widget.


Loop custom taxonomy to get lists of cutom post types?

I have a custom post type 'products' and custom taxonomy of 'maker' that i have connected to that cpt 'products'. I have written this code :                 <?php $myproducts = new WP_Query(array('post_type' => 'products', 'maker'=>'samsung')); ?>       <?php while($myproducts->have_posts()) : $myproducts->the_post(); ?>            <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?>            <?php endwhile; ?>       <?php wp_reset_postdata(); ?>      and this allows me to loop products from one of added makers (in this case samsung). What I am actually trying to do is to create a page that will loop through all of items from 'maker' taxonomy that a client might add to it. It would be great if I could use these elements of the 'maker' taxonomy to show lists of all 'products' that belong to those makers. Basically loop the taxonomy elements and use those results to loop all products that belong to those makers. Sorry if i'm being redundant, I'm just trying to be as specific as a beginner might be. Thank you all.


Displaying a custom field containing a list creates unwanted markup

I display my custom field like this :
<?php echo get_post_meta($post->ID, $my_field, true); ?>
      As long as the field contains plain text, the markup is normal :
something
      But if I put some HTML list in it, the content jumps out of the P tags and some additional P tags are even added :

something

something

      Why is that and how to fix the problem ?


remove custom post type permalink

I've registered post type with following --               $holidayLabels = array(         'name' => __( 'Holidays'),         'singular_name' => __( 'Holidays'),         'all_items' => __( 'All Holidays'),         'add_new' => __( 'Add New Holiday'),         'add_new_item' => __( 'Add New Holiday'),         'edit_item' => __( 'Edit Holiday'),         'new_item' => __( 'New Holiday'),         'view_item' => __( 'View Holidays'),         'not_found' => __( 'No Holidays found'),         'not_found_in_trash' => __( 'No Holidays found in Trash'),         'parent_item_colon' => ''          );          $holidayArgs = array(         'labels'               => $holidayLabels,         'public'               => true,         'publicly_queryable'   => true,         '_builtin'             => false,         'show_ui'              => true,         'query_var'            => true,         'rewrite'              => array( "slug" => "holidays" ),         'capability_type'      => 'post',         'hierarchical'         => false,         //'menu_position'        => 6,         'supports'             => array( 'title'),         'has_archive'          => false,         'show_in_nav_menus'    => false,          );     register_post_type('holidays', $holidayArgs);      And I want to remove permalink that appears below title when I post new holiday or start editing existing one. ![enter image description here](http://i.stack.imgur.com/CzcVQ.png) I want to remove this because, holidays will be displayed in separate widget. I don't want admin to be able to see it as single post anyhow. There's no template defined for such.


Get first comment link on the post itself

I have this function and a link to a post:               <?php     foreach ($results as $id) {       $post = &get_post( $id->ID );       setup_postdata($post);
<a <?php href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?>
       <?php     } ?>      What I want to do is this: if there is a comment posted **today** , than show me the link to the first comment that has been posted. So for example: if there are 4 comments made today, I want the link to the first comment instead of the permalink just like now. I tried using this:   `<a <?php href="<?php the_permalink(get_comments->$post_id) ?>">postname</a>` and variations of this like `comment_post_ID`, but I could not get it to work. What am I doing wrong and what should I do? Please, help me...


How to detect when admin user is on the All Posts page?

Could anyone be kind enough to descrive how to I can detect (in my functions file) when admin an user is on the 'All Posts' page? I have tried get_post_type() but it returns nothing. Thanks.


Multisite subdirectory blogs missing slash

New WordPress 3.5.2 multisite (subdirectory) install is missing a slash when creating new blogs. WordPress is installed to server like: > blogs.domain.com When a new user registers, the conformation email has the URL for their blog like: > blogs.domain.comnewuser (missing the / between the domain and blog name). From Network Admin, I can edit the site, adding a `/` to either the end of the Domain field or the begining of the Path field and the site can be accessed: > blogs.domain.com/newuser wp-config:               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]          # add a trailing slash to /wp-admin     RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]     RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]     RewriteRule . index.php [L]     </IfModule>      Adding `$base = '/';` to wp-config didn't seem to make a difference. .htaccess:               define('WP_ALLOW_MULTISITE', true);     define('MULTISITE', true);     define('SUBDOMAIN_INSTALL', false);     define('DOMAIN_CURRENT_SITE', 'blogs.domain.com');     define('PATH_CURRENT_SITE', '/');     define('SITE_ID_CURRENT_SITE', 1);     fine('BLOG_ID_CURRENT_SITE', 1);      DB: wp_site has: > **domain:** blogs.domain.com **path:** / wp_blogs has: > **domain:** blogs.domain.com **path:** / but when a new user/blog is added, `wp_blogs` gets: > **domain:** blogs.domain.com **path:** user/


Get a list of the last posts grouped by author and filtered by category

i need a list of the latest post published by various authors, but filtered by category, like for example the latest posts of author that write about music. i wrote this query and looks like working in mysql               SELECT * FROM     (         SELECT *          FROM $wpdb->posts         INNER JOIN              wp_term_relationships ON $wpdb->posts.ID = wp_term_relationships.object_id         WHERE              wp_term_relationships.term_taxonomy_id = 7             AND             $wpdb->posts.post_status = 'publish'              ORDER BY $wpdb->posts.post_date DESC     )     AS x GROUP BY post_author      _(the 7 is just an example category id)_ i just would like to know the other `$wpdb` functions to call the `wp_term_relationships` table and if is there something wrong with this query thank you in advance


Using Same User Database on Subdomain

How can I create a subdomain that uses the same database as the main domain? For example, I have `mywebsite.com` which has my main WordPress installation. I also want, say, `subdomain.mywebsite.com` which has the same user base. I know I can simply use queries on the database, but this seems like an unnecessary workaround. I also need to allow the user to log on to the subdomain, but the account is the same for both the subdomain AND the main domain. How can I accomplish this? I've tried using multisite but I was unable to figure it out. Thanks!


The best way to add stylesheets to WordPress

I am in the process of converting a mobile responsive page, currently built in Bootstrap into WordPress. Using `wp_register_style()` and `wp_enqueue_style()` will add the stylesheets to all pages, including the wp-admin. I know I could get around that by using an `if ( ! is_admin() )` conditional statement. Is it better to use the conditional statement, or to just to use:               <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/bootstrap.css" media="screen" />      in the theme's header.php?


Enabling canonical links to force search engines to go to site.com rather than site.net

I want visitors who have typed `site.com`, stay on `site.com` and visitors who have come to `site.net`, stay at `site.net` (They have one host and `site.net` has been parked on `.com`). When it comes to search engines, because of SEO they should understand that the both domain are locating to the same host. I know that I should do it with **canonical links**. I searched and got that I should install **WordPress SEO Plugin** located at http://yoast.com/wordpress/seo/#canonical But now I see that the image at the link which is: ![what I should see](http://i.stack.imgur.com/hSa1N.png), is different from what I see at my wordpress admin panel: ![what I see](http://i.stack.imgur.com/ztbUE.png) So I have only 3 options: **Leave default** (selected right now), **http** and finally **https**. I expected to have a text box so that I could enter `site.com` to force google redirect visitors to `site.com`; Also note that my version is different what I should see as the the example has stated. * * * **IF** the solution with Yoast wordpress SEO plugin is the best way, please help me to understand what should I do. **ELSE IF**!!! you know a better solution, please tell me to use the new one!


is this code properly secured

The input will be an address. This is what I gather from looking at the Codex. See here: codex               $wpdb->insert($address_table, array('address' => $address),array('%s'));


How many databases do I need?

I have been asked to build another site for someone else. Eventually, I will turn it over to them. I will develop it locally, then take it live, then turn over full control. In the meantime I need a database for WP to interface with. Do I hook the new site into my existing database that I already have for my personal site or is it one database per website? I would hate to have export my database along with someone else's.


Pull Random Images From Options Page

Using this code to get my options               echo eh_get_option('eh_slide_image_4');      Using the options framework from http://www.wptheming.com I have 8 options set up using the above tag like               echo eh_get_option('eh_slide_image_1');     echo eh_get_option('eh_slide_image_2');     echo eh_get_option('eh_slide_image_3');     echo eh_get_option('eh_slide_image_4');     echo eh_get_option('eh_slide_image_5');     echo eh_get_option('eh_slide_image_6');     echo eh_get_option('eh_slide_image_7');     echo eh_get_option('eh_slide_image_8');      I want to display only 4 at a time and have them on random. Anyway to do this? I should add the entire code looks like this
        <img src="<?php echo eh_get_option('eh_slide_image_1'); ?>" />

<?php echo eh_get_option('eh_slide_text_1'); ?>

      So it would also need to match the text with the image


CSS from textarea in options page to frontend what to do

I have a textarea for small css enhancements on the plugins page i output them directly to the head. My Question is how to sanitize the CSS i have validation function registered for the options with `register_setting`. On the setting page right now `$output['css'] = (string) $input['css'];` is all what i am doing. Should i escape it somehow? What does word-press with it? Does it some escaping by itself for database? I could there some evil injection take place here. For output i use the `esc_attr()` so far its working great but i just want to ask if there is something better for it. I just tested `"` characters they are obviously translated into `"` i just tested it and they seem not to break the CSS in firefox but of course this feels bad. So what should i use instead?               echo '<style type="text/css" media="screen">' . esc_attr( $css ) . '</style>';      Btw I don't care about `"` you only don't really need them in CSS or am i wrong you can do url("bla") or url(bla) and both work. Or is there a reason of support `"`s in CSS? Update1: After 2 answers, a lot if talk and thinking i still like to know if my thought process is so wrong to escape it twice now with wp_filter_nohtml_kses() on database input **and on output**. I would be be happy to get a answer from someone with security expertise. Update2: I just notices that wp_filter_nohtml_kses() would not allow `>` or `<` since they are CSS selectors maybe it isn't the right filter after all. Maybe other things it filters that i might want in CSS?


wp_insert_post or wp_set_post_terms do not save taxonomy, but wp_set_post_terms does

I have a litlle problem. I have a custom taxonomy 'rodzaj' with value i.ex. obrazek. I use this code to add post:               $postArray = array(                     'post_status' => 'publish',                     'post_author'=> get_current_user_id(),                     'post_category'=>array($catId),                     'post_title' => $_POST['titlePhoto'],                     'tax_input' => array( 'rodzaj' => array( 'obrazek') ) ,      );      This code adds a post but without taxonomy. I tried also this:               wp_set_object_terms($postId, "obrazek", 'rodzaj', false);      Doesn't work too. Working code is:               wp_set_post_terms( $postId, array( 'obrazek'), 'rodzaj' );      Why first 2 functions doesn't work? I made mistake at the begining. This is full working code:               $catId = get_cat_ID("Obrazki");                   $postArray = array(                 'post_status' => 'publish',                 'post_author'=> get_current_user_id(),                 'post_category'=>array($catId),                 'post_title' => $_POST['titlePhoto'],                 'tags_input' => explode(',', $_POST['tagsPhoto'])              );                        $postId = wp_insert_post($postArray);              if($postId)               {                   wp_set_object_terms($postId, "obrazek", 'rodzaj', false);                    }      Still doesn't working: wp_set_post_terms($postId, "obrazek", 'rodzaj', false); and 'tax_input' => array( 'rodzaj' => array( 'obrazek') ) in postArray()


Exclude posts from homepage having a specified tag

I am pretty new in WordPress development and I am trying to implement this custom theme that handle the so called **featured posts** As you can see in the posts area of the homepage I have the _Articoli in evidenza_ sub area that contains my _featured posts_ and under it the _Ultimi Articoli_ subarea that contains the latest posts. To implment this I use the posts tag and in the futured posts area I show the posts having the `tag=featured` condition. So this is my code:

Articoli in evidenza
               <?php query_posts('tag=featured');?>     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

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

     Scritto da <?php the_author_link(); ?>  //   <?php the_category(', ') ?>   //   <?php comments_popup_link('Nessun Commento', '1 Commento ', '% Commenti'); ?>

<?php the_excerpt()?>           <?php $featured_img = get_post_meta($post->ID, 'featured_img', $single = true); ?>           <a href="<?php the_permalink(); ?>"><img src="<?php echo $featured_img ?>" alt="<?php the_title(); ?>" />

          <?php endwhile; ?>     <?php else : ?>     <?php endif; ?>
Ultimi Articoli
                       <?php         if (have_posts()) :             // Start the Loop.             while (have_posts()) : the_post();                      /*                  * Include the post format-specific template for the content. If you want to                  * use this in a child theme, then include a file called called content-___.php                  * (where ___ is the post format) and that will be used instead.                  */                 get_template_part('content', get_post_format());                  endwhile;         else :             // If no content, include the "No posts found" template.             get_template_part('content', 'none');              endif;         ?>
      As you can see first I show the posts having a tag `featured` by the use of `query-posts()` function:               <?php query_posts('tag=featured');?>      Now my problem is that, if a post have the `featured` tag, I don't want that it is shown in the latest post area (at this time it is shown). So I tried to use this code:
Ultimi Articoli NOT FEATURED
               <?php query_posts('tag != featured');?>          <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

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

     Scritto da <?php the_author_link(); ?>  //   <?php the_category(', ') ?>   //   <?php comments_popup_link('Nessun Commento', '1 Commento ', '% Commenti'); ?>

<?php the_excerpt()?>           <?php $featured_img = get_post_meta($post->ID, 'featured_img', $single = true); ?>           <a href="<?php the_permalink(); ?>"><img src="<?php echo $featured_img ?>" alt="<?php the_title(); ?>" />

          <?php endwhile; ?>     <?php else : ?>     <?php endif; ?>      But this don't work and the featured posts still shown in the homepage. As you can see, I've tried to specify that, to be shown, a post can't have the `featured` tag:               <?php query_posts('tag != featured');?>      Why don't this work? What am I missing?


Which file displays the date archive?

I'm building a new theme. I'm now working on to figure out which file is needed to show the "whole" post for a specific date which displays when you click on a date in the built in WordPress calendar widget? Somebody who has a clue which it is?


Change permalink structure for pagination only

I am using following functions to display pagination on archive pages of my site.               <?php previous_posts_link('< Previous', $loop->max_num_pages); ?>     <?php next_posts_link('More >', $loop->max_num_pages); ?>      And it is working very fine on my localhost. But not on my server, the issue is that we have some redirects written on my server's .htaccess and since my wordpress is subdomain I dont really want to touch my root .htaccess file. Default pagination links my pages to               domain.com/wordpress/posttype/page/2     domain.com/wordpress/posttype/page/3      and so on.. but the above links gets redirected to something like following               domain.com/wordpress/posttype/page/blah2     domain.com/wordpress/posttype/page/blah3      which eventually returns 404 page. (ofcourse its due to .htaccess redirects on my server) So All I want to do is change permalink structure for my pagination so that my pagination links look something like these :               domain.com/wordpress/posttype?page=2     domain.com/wordpress/posttype?page=3      Thank You.


Create more Meta Boxes as needed

I'd like users to be able to create and remove additional meta box fields as needed. For example, say a music podcast with a variable amount of songs played per episode. The user should be able to click a button that will add additional fields to enter each song as needed. Ideally this would be done without the use of a plugin, but coded into the functions file.


dynamically add a custom field or metabox to custom post type

> **Possible Duplicate:**   >  Create more Meta Boxes as needed I am creating a plugin that registers a Custom Post Type. Let's call it "Cars". I am looking to be able to add custom fields(or metaboxes) when I am editing a car, just like what you can do now with a custom field in a post or a CPT but I want to be able to control the HTML/CSS for it(for example I would like it to have 3 input fields). So for example when you are editing a car, there would be a "add new field" button and when you press it a new custom field/metabox(with predefined structure and styling by me) would be added. Let me know if I am not clear. Thank you!


Display Category only if there are posts of custom type

I need to do a small modification on WP site done by someone else. And my WP experience is close to zero. But I'm comfortable with PHP. Wordpress Version: 3.8 Plugins: ONLY **Advanced Custom Fields 4.3.4 [ACF]** http://wordpress.org/plugins/advanced-custom-fields/ There's only one group **Products** made with ACF with fields like **title, description, price, store**. Site owner add Products with details & which stores they are available at. currently the products are displayed correctly based on the url               http://mysite.site/store1      will take to a list of product categories. When user clicks any of the category it will show the filtered products list with the ACF field **store** **The Problem** All categories are displayed regardless of whether it contain products for the specific stores ie., **category 2** has only one product **product 10** and it is only available in **store1**. But store2 & store3 shows **category 2** even though it doesn't have any valid product. Currently the following code is used to display categories.               $args = array(         'type'                     => 'post',         'child_of'                 => 0,         'parent'                   => '0',         'orderby'                  => 'name',         'order'                    => 'ASC',         'hide_empty'               => 1,         'hierarchical'             => 1,         'taxonomy'                 => 'category',     );     $top_categories = get_categories($args);      I want $top_categories to return only those categories with products for current store Thank you


feedburner plugin for WP 3.5

I was using FD Feedburner Plugin for feeds redirection to feedburner, but now after updating to WP 3.5 it stops working. Is there any feedburner plugin which forks for WP 3.5 ?


comments are coming on improper posts

If someone comments on any post on my site, that comment gets displayed under another post. Moreover, if I login to my site. And click on logout link (under comment section) it redirects me to another article after log out. One possible reason as I read on many places, may be showing related posts. I am using following code for this               <?php do_action('erp-show-related-posts', array('title'=>'Most Related Post', 'num_to_display'=>10, 'no_rp_text'=>'No relevant article found.')); ?>      Which is basically given by a wordpress plugin efficient related post.


What is a good way to present templated content in WordPress?

I'd like to be able to add a template for a page that will present pages with similar data in the same style. For example, I want to be able to create a "Person Profile" template so that all personal profile pages have the same look and feel. Currently, the way I might do that is copy and paste a set of `<div>` tags into different pages and update my style.css file to handle the custom classes in the `<div>` tags. While this convention would work, it requires anyone who adds content to be able to understand how to insert their images and text correctly between the `<div>` tags. What I would really like is the ability to have someone fill out a simple "form" and then take that content and display it in a templated way on the site. For example, there's might be a form like this:               1. Image: _______________________________ [Browse]     2. Person's Name : ______________________     3. About this Person: ___________________     [Save] [Cancel]      I'm thinking that this problem has been solved by others using WordPress, but I don't know where to look to solve this problem in a way that can be easily maintained.


Create dynamic wordrpess blank page

I've created a submenu in wordpress using add_submenu_page:                   add_submenu_page(null,'Page Title','Page Title','administrator','page-slug','page-callback');      I want to create another page like this with the condition that the page will be totally blank without creating a new file does wordpress have a function like this?I want it because I want to generate and download an xml file there and if the page has headers and footers the page downloads them too.Any Sugestion? Thank You.


Restrict a Post Types Post Status

I have a custom post type and a completely custom user interface to access it, and would like these posts to have a publish status. I know how to make them skip trash and be deleted immediately, but this still leaves me with draft posts and private posts. Is there a way to prevent posts getting flagged as drafts or private? I can hide the controls in CSS but I want to do this in code to make sure it isn't possible, is there a handy filter I can use?


List plugins used in a WP site - guest, not admin

> **Possible Duplicate:**   >  How to detect WP plugins used on a site Is there any way to list which plugins are used in a wordpress blog? I am a guest - normal visitor of the site, not the admin! Thanks!


Plugins admin page in tabs

How do I init custom Plugins admin page if pages are enbeded in tabs I try the following but You do not have sufficient permissions to access this page.                   class MyPlugin{           public function iniAdmin() {                 add_action('admin_menu', array($this, 'register_collections_menu_page'));                 add_action('admin_enqueue_scripts', array($this, 'style_bootstrap'));             }                  function register_collections_menu_page() {                 add_menu_page(                         'MyCollections','My Collections', 'manage_options', 'collections&tab=items', array($this, 'init_collections'));                 add_submenu_page(                         'collections', 'Categories', 'Categories', 'manage_options', 'collections&tab=categories', array($this, 'collection_categories')                 );                  }           function init_collections($current = 'items') {             if ($this->tab) {                 $current = $this->tab;             }             $tabs = array('items' => 'MyCollection', 'categories' => 'Categories');             echo '

';             echo '
';             foreach ($tabs as $tab => $name) {                 $class = ( $tab == $current ) ? 'class="active"' : '';                 echo "
$name
";             }             echo '

';             if ($tab == 'items') {                 $this->collection_items();             }          }              }              $plugin = new MyPlugin();         if (is_admin()) {            $plugin->iniAdmin();         }


wp_kses vs wp_strip_all_tags

Apart from providing a granular control for allowed HTML tags does `wp_kses` provide any additional benefits over `wp_strip_all_tags`? Essentially, if I were to use `wp_kses` and set it to `not` allow any HTML or protocols, would it carry any benefit over just using `wp_strip_all_tags`?


How to install wordpress theme's plug-ins?

I need you're help, as I'm sort of a noob at installing extras in themes. I installed the Metro Magazine theme on my wordpress site, but the metro magazine theme has some plug-ins to increase functionality that I can't install in my theme. When I upload each plug-in in zip or rar format, I get this error: **Failed to install plug-ins** When I try to install this theme completely using the Appearance > Theme as theme installation, with all it's plug-ins in zip or rar format, I can't install this theme so first I installed theme with out the extra plug-ins and it installed with out any Error. Can someone help me find a way to install this theme completely, using it's own plug-ins as a theme installation or how can I install this theme's plug-ins, after I install the theme without the plugins. : Raha


Why is jquery-ui-core enqueueing in my footer instead of the header?

This is what I'm using to make sure that I have jquery-ui-core available:               if (!is_admin()) add_action('wp_enqueue_scripts', 'zg_load_scripts');     function zg_load_scripts(){         wp_enqueue_script("jquery-ui-core");     }       I also tried `wp_enqueue_script("jquery-ui-core", null, null, false, false);` in a vain attempt to force it into the header. No dice. What's going on here?


How to set a cookie for logged in users to md5($user->ID . "my_secret")?

For all logged in visitors of my WordPress website I would like to set 2 cookies based on their user ID - so that I can use their user IDs in WordPress-unrelated PHP scripts at the same domain. In one cookie I would like to store the user ID. In the other cookie I'd like to store a md5 hash of the user ID and a secret word - so that I can verify in my PHP scripts, that the first cookie hasn't been faked. Here is my code:                   $year = time() + 60 * 60 * 24 * 30 * 12;         $auth = md5(join('_', array($user->ID, 'my_secret')));              setcookie('visitor_id', $user->ID, $year, '/', '.example.com');         setcookie('visitor_auth', $auth, $year, '/', '.example.com');      Please advise me, where to put this code in my plugin? I have looked at the wp_set_auth_cookie, but I don't see how it could be used for my purpose. It seems to be a function to set some WordPress internal cookies, but not my custom cookies. Or should I mayber put the above code into `init` hook? How can I find the user ID in there?


Is there a way to list all the JavaScript scripts that are actually loaded by WordPress? Do we care?

This page on the Codex gives us a list of all the default scripts that ship with WP. But how do we know which ones are actually being used so we don't have to manually enqueue them? Or do we care, and just enqueue the ones we need, and `wp_enqueue_script()` will just ignore the enqueue request if that script is already loaded? But what about versions? If I'm going to be specifying versions with `wp_enqueue_script` and the version that ships with WP is less than that, will the `wp_enqueue_script` call just be ignored, and I find myself without the script I'm looking for?


How to change post to page

If I have to change a number of posts to pages, does this require anything more complex that setting the post-type to page on the table wp_posts? Do any other settings need to be changed. Is it better to use a plugin like Convert Post Types or Vice Versa instead? I have a number of posts that I like being able to categorize on a site, but I may need to change to pages in the future. Thanks,


Can WP ecommerce collect card info without charging?

I'm new to ecommerce but have some experience with Wordpress. My client is wanting to have the customer put their card information in but not charge them. They are wanting to do it manually. Is WP ecommerce okay for this? If not, what should I do? Thanks.