I'm trying to add a nonce to my plugin's Ajax. I'm not sure why I'm getting this error: > Fatal error: Call to undefined function wp_create_nonce() In my php file :               wp_localize_script('my-ajax-handle', 'the_ajax_script', array('ajaxurl'=> admin_url('admin-ajax.php'), 'my_nonce' => wp_create_nonce('myajax-nonce')));      In js file:               jQuery.post(the_ajax_script.ajaxurl, {my_nonce : the_ajax_script.my_nonce}, jQuery("#theForm").serialize() + "&maxLat="+ map_bounds[0] + "&maxLong="+ map_bounds[1] + "&minLat="+ map_bounds[2] + "&minLong="+ map_bounds[3],         function(response_from_the_action_function){            jQuery("#response_area").html(response_from_the_action_function);         });      Any suggestions on how to solve this? Thank you.


Display "Post 2 of 4" on single post page?

I have a custom post type called Projects. When viewing a single 'project' post I have next/prev buttons to navigate through them. I also want to display text saying "Project 2 of 4" or ideally pagination icons. This is easy on index.php but I can't work out how to do this on a single post page. Thanks


Thumbnail Image Rounded Corners w CSS (or any other good method)

I've been researching how to display thumbnails with rounded images, but every solution ends up running out of gas. One trick I tried was wrapping the thumbnail in a division with the same size and shape, showing the image, but with CSS of "opacity:0" so that the actual image doesn't show. What shows is the background image for the division, and it's this, also that is styled using: border-radius: 15px; (plus other browser related hacks) To do this on WordPress, I'm going to have to use inline styles, it seems, to give the same div the right background image using               the_post-thumbnail()      Seems to lead to nowhere because I don't see a way to pull just the image url in a way that I can call within               <div style="   ";      Any ideas? I'm trying to avoid Javascript, but if that's the only way... Here's a link to the method I mentioned:


change attachment custom field onChange event

The form is in post creating window. Ajax is posting values, but the values doenst renews. Where can be problem ? Ajax                   <script>     function dynamic_Select(field, aid, value)       {     console.log(field, aid,value);       jQuery.ajax({         type: "POST",         url: ajaxurl,         data:{                  field:    field,                  aid:      aid,                   value:    value,              },              error: function(){alert('Error!')},         success: function(){alert(value)}                 });       }      </script>      functions.php               add_action('wp_ajax_dynselect', 'update_dynamic_select');     add_filter("attachment_fields_to_save", " update_dynamic_select", null , 2);           function update_dynamic_select($field, $aid, $value) {            update_post_meta($aid, $field, $value);          }      HTML:               <select aid="104" name="_image_matmenys" onchange="dynamic_Select(this.getAttribute('name'), this.getAttribute('aid') ,this.value)">        <option value="10x10">10x10</option>        <option value="20x20" selected="selected">20x20</option>        <option value="30x30">30x30</option>     </select>


Best/Correct way to add an option to a category

I'm currently writing my first plugin, which will let the site admin/editor use a different image as a background/header for each post/page, and I would also like to have defaults for each category. Here is where I'm not sure how to proceed: If for each post/page the image (which is an attachment, so is just an id in the db) is a simple post meta field, there is no such (implicit) thing for categories. So there are more ways to go:   * Create an option for every category - something like `background_cat_$id_`   * Add the categories which correspond to a certain image to the attachment post ( `corresponding_cats` ? )   * Modify the term_taxonomy table to add a column (last resort? bad design?) Right now I believe I'll go with my first option but I'm really curios how you handle such issues.


How to query post ids liked by the Author

I'm using wti_like plugin and this is how i get the number(count) of post liked by the author               // Get the author object     $author = get_user_by( 'slug', get_query_var( 'author_name' ) );          // Get the post ids liked by the author     $like_ids = $wpdb->get_var("SELECT SUM(value) FROM {$wpdb->prefix}wti_like_post                 WHERE user_id = {$author->ID} AND value > 0                 GROUP BY post_id ORDER BY SUM(value) DESC");     ?>          echo (int)$like_count;      * * * How can i query the posts liked by the author and use my post format to display them in my author.php template? ie:               get_header(); ?>
                   <div id="content" role="main"     < ?     $args = array(       //QUERY OPTIONS GOES HERE//     );          $wp_query->query( $args ); ?>                       <?php if ( have_posts() ) : ? >


Custom rewrite rule serves content, but returns 404 error code

I have a plugin that sets up a custom rewrite rule. I can access the short URL and the content is returned correctly, but the HTTP response is `404, Page not found`. From searching the web it seems like WordPress is returning 404, because it thinks this is not a valid WP page (http://wordpress.org/support/topic/404-on- custom-non-wordpress-pages). Is there a recommended solution to this problem? How can I get WP to return a normal status code for a rewritten URL?               global $wp_rewrite;     add_rewrite_rule('list-data$',                       '/wp-content/plugins/data-lister/list-data.php', 'top');      Thanks! Mark


How to filter custom posts by tags and custom fields?

I'm planning a site for a client who wants users to be able to filter upcoming events by the following criteria: **Type** i.e. Comedy, Theatre, Music etc. **Date** Daily or Weekend **Duration** Daily or Half day I want to delve into Custom posts more, so will set up a Custom Post Type for 'Events' (non-hierarchical) and when creating a new post I'll add Custom Fields for Type, Date and Duration. The question I have is how would I use query_posts() to:   1. List the events so that the soonest (i.e. next event to occur) appears first and later events last?    2. Filter by **multiple** meta values (Type, Date and Duration)?  I presume I need to create a series of options in my form's dropdown lists based on the custom field values right? I've created a list of Events for a client before, but with no filtering possibilities. I used this query_posts() code to get the custom posts and order things:               // List the events by custom field 'Date':     $todaysDate = date('Y/m/d'); // set todays date to check against custom field          // query posts     query_posts('post_type=Event&meta_key=Date&meta_compare=>=&meta_value=' . $todaysDate . '&orderby=meta_value&order=ASC');      However, I can't see how I might change this code to filter by multiple custom fields...any ideas? Thanks


How do I use the 'http_request_host_is_external' filter

I'm having a really hard time trying to use the `http_request_host_is_external` filter. For some background, I'm trying to set up a separate server to handle private plugin and theme updates. The problem is that it's on a separate server, so the Wordpress `wp_http_validate_url` (wp-includes/http.php) function kills the request. The following are lines 481-503 of that file.               if ( $ip ) {             $parts = array_map( 'intval', explode( '.', $ip ) );             if ( '127.0.0.1' === $ip                 || ( 10 === $parts[0] )                 || ( 172 === $parts[0] && 16 <= $parts[1] && 31 >= $parts[1] )                 || ( 192 === $parts[0] && 168 === $parts[1] )             ) {                 // If host appears local, reject unless specifically allowed.                 /**                  * Check if HTTP request is external or not.                  *                  * Allows to change and allow external requests for the HTTP request.                  *                  * @since 3.6.0                  *                  * @param bool false Whether HTTP request is external or not.                  * @param string $host IP of the requested host.                  * @param string $url URL of the requested host.                  */                 if ( ! apply_filters( 'http_request_host_is_external', false, $host, $url ) )                     return false;             }         }      You'll notice that there is a comment in there that mentions we should be able to apply the filter and make external requests, but what I'm trying doesn't seem to work.                   require 'plugin_update_checker.php';     apply_filters( 'http_request_host_is_external', true, "my-update-server.com", 'http://my-update-server.com/update/8b6b28f1a2604deea192076cb2343ff4/' );     $MyUpdateChecker = new PluginUpdateChecker_1_3(         'http://my-update-server/update/8b6b28f1a2604deea192076cb2343ff4/',         __FILE__,         'testslug'     );      I thought that if I set the filter in my plugin's main file it would take care of it, but I think the issue is that the external request is happening right in Wordpress's updater, so maybe my filter doesn't apply?


Multisite wordpress search loop and pagination?

OK I have a wordpress custom loop looping across 3 blogs and returning the results like so:               <?php                      $posts_per_page = get_option('posts_per_page');                      $searchfor = get_search_query(); // Get the search query for display in a headline                      $query_string=esc_attr($query_string); // Escaping search queries to eliminate potential MySQL-injections                      $blogs = get_blog_list( 0,'all' );                      $notfound = true;                      $current_blogid=get_current_blog_id();                      $blogs_ordered = array($current_blogid);                  foreach ( $blogs as $blog ):                     if ($blog['blog_id']!=$blogs_ordered['0']){                             $blogs_ordered[]=$blog['blog_id'];                     }             endforeach;                  foreach ( $blogs_ordered as $blogid ):                     switch_to_blog($blogid);                    $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;                                   $search = new WP_Query($query_string.'&posts_per_page=1&paged='.$paged);                                           if ($search->found_posts>0) {                              foreach ( $search->posts as $post ) {                                       POST CONTENT ECHOS HERE!!!                                          <?php                                     $post = $postx;                                     wp_reset_query();                                 }                             }                          wp_reset_query();                  endforeach;                $page_links_total =  $search->max_num_pages;                      if ($page_links_total>1) :                               ?>

                             <?              $search->query_vars['paged'] > 1 ? $current = $search->query_vars['paged'] : $current = 1;         $pagination_args = array(             'base' => @add_query_arg('paged','%#%'),             'format' => '',             'total' => $page_links_total,             'current' => $current,             'show_all' => false,             'end_size' => 0,             'mid_size' => 0,         );         if ( $wp_rewrite->using_permalinks() ) $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'paged/%#%/', 'paged' );         if ( !empty($wp_query->query_vars['s']) ) $pagination['add_args'] = array( 's' => get_query_var( 's' ) );                $prev = get_previous_posts_link('< FORRIGE');         $next = get_next_posts_link('NESTE >');          $links = paginate_links($pagination_args);         $links = "
                     $prev

                      $next
         ". $links;         echo $links;                 ?>

                             <a href="<?php echo get_site_url(1) . "/?s=" . get_search_query() . '&paged=' . ($current - 1); ?>">< FORRIGE

Side <?php echo "$current/$page_links_total"; ?>

                             <a href="<?php echo get_bloginfo('home') . "/page/" . ($current + 1) . "/"; ?>">NESTE >                             <?php echo the_search_query(); ?>                             <a href="<?php echo get_site_url(1) . "/?s=" . the_search_query() . '&paged=' . ($current + 1); ?>">NESTE >

             <?php             endif;      ?>      My problem arrises that whenever i try and use the pagination links it just refreshes the same page or jumps to the home page... if i change this:                $search = new WP_Query($query_string.'&posts_per_page=1&paged='.$paged);      to :                 $search = new WP_Query($query_string.'&posts_per_page=1&paged=10');         it does jump to the right page and the next prev links just refuse to work, i've tried turning off permalinks I've tried a myraid of different things (some still in the code..) Please help this is driving me up the wall! Kind regards Chris


Make password invalid once logged out of password-protected page

In a WP-based site I have a custom form which I need to hide from the general public and give access to only a select few who would then get a password from me, enter it and access the form and submit it. On form submission, I redirect them to another page. I have employed this bit of code below in my `functions.php`, which logs them out of the password-protected page, once redirected:               add_action( 'wp', 'post_pw_sess_expire' );         function post_pw_sess_expire() {         if ( isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) )         // Setting a time of 0 in setcookie() forces the cookie to expire with the session         setcookie('wp-postpass_' . COOKIEHASH, '', 0, COOKIEPATH);     }      Now the twist: once any of these select few are logged out of the password- protected page, I need the password to become invalid. Not necessarily, but sort of like a one-time password. A solution would be great, or please give me some pointers or alternatives if it's not possible.


Adding an email column to a Custom Post Types Admin Screen?

I am trying to add a column to my Custom Post Type Admin Screen that will show the author's email address. Any advice for novice coders (such as myself) that describe how to accomplish this? I've come up empty in searching for a tutorial specific to what I'm trying to do. Thanks, Sean


How can I embed a .php file inside of a widget?

I have a currency exchange that I'm trying to put in the sidebar of my Wordpress site. The currency exchange is a simple php file that I'm trying to 'embed' as a widget. I created a simple plugin, and tried to embed my php file using the `require_once` function, but it crashed my site. This is the plugin content:               <?php     /*     Plugin Name: Cotação do Dólar     Description: Conversor de moedas e cotação atual de moedas.     */     /* Start */          // Creating the widget      class wpb_widget extends WP_Widget {          function __construct() {     parent::__construct(     // Base ID of widget     'wpb_widget',           // Widget name will appear in UI     __('Dollar Exchange Plugin', 'wpb_widget_domain'),           // Widget description     array( 'description' => __( 'Plugin Description', 'wpb_widget_domain' ), )      );     }          // Creating widget front-end     // This is where the action happens     public function widget( $args, $instance ) {     $title = apply_filters( 'widget_title', $instance['title'] );     // before and after widget arguments are defined by themes     echo $args['before_widget'];     if ( ! empty( $title ) )     echo $args['before_title'] . $title . $args['after_title'];          // This is where you run the code and display the output               **require_once("cotacao.php");**          echo $args['after_widget'];     }          // Widget Backend      public function form( $instance ) {     if ( isset( $instance[ 'title' ] ) ) {     $title = $instance[ 'title' ];     }     else {     $title = __( 'New title', 'wpb_widget_domain' );     }     // Widget admin form     ?>     <p>     <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>      <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />     </p>     <?php      }          // Updating widget replacing old instances with new     public function update( $new_instance, $old_instance ) {     $instance = array();     $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';     return $instance;     }     } // Class wpb_widget ends here          // Register and load the widget     function wpb_load_widget() {         register_widget( 'wpb_widget' );     }     add_action( 'widgets_init', 'wpb_load_widget' );               /* End */     ?>      What's a feasible way to just include a .php file as a widget? I tried to use a iframe but nothing happened. Thank you.


Show Custom Field of Current Page in For Loop

I'm implementing a scrolling horizontal template and this is the code to divs that are the pages of the template.                <?php for($i=1;$i<=2;$i++) { ?>     <div class="container" id="page-<?php echo $i ?>">
             <?php                  $specialPosts = new WP_Query();                 $specialPosts->query('pagename=page-'.$i.'');                      $mykey_values = get_post_custom_values('custom_select');                     foreach ( $mykey_values as $key => $value ) {                         if ($value='one') {                             include 'templates/slideshow-template.php'; }                         else if ($value=='two') {                             include 'templates/full-page.php';                      }  ?>

     <?php } ?>      As you can see I get the page name, and I have a custom field where you can choose the template page. The problem is that it get always the custom field value of the first page. So if i choose option one in the first page and option two in the second page it shows always the first template. How can I fix that?


Does WordPress send a 301 header message when you change permalink structures?

I have a super old blog that I upgraded from 2.0.7 to 3.1 by upgrading over multiple versions. One of my biggest concerns was losing all the link juice from my legacy URLs but they were clearly made at a time when I hadn't considered how the URLs would need to change. To my surprise I found that changing my permalink structure from /articles/%category%/%postname%/ to /id/%post_id%/%postname%/ went really smoothly as WordPress automatically looked up the appropriate URL -- which is great. But I'm wanting to know since Ive changed link structures, does it send 301 header messages so I dont lose link juice from 5+ year old links, or is there a way for me to force WordPress to do this for old URLs? Thanks!


Plugin for visitors to edit content without logging in?

I have a company catalog and want visitors to edit the information without logging in. I have tried TDO Mini Forms and it almost worked, too many bugs. Is there any other good plugin for this?


Should I use spl_autoload_register() in my plugin?

When I use spl_autoload_register in my plugin, I get:                   Fatal error: Uncaught exception 'LogicException' with message        'Class wp_atom_server could not be loaded'              wp-includes\pluggable-deprecated.php on line 182      I did some reading and found various fixes. One on SO said not to use spl_autoload_register with WordPress. Is that accurate? I'm sure I can find a "fix" for the error, but I'm not sure I want to do that with each WP release. If I do not use the autoload function, how should I be loading my classes? Here is what breaks now:               spl_autoload_extensions(".php");     spl_autoload_register();          use MyPluginClasses\Student as MS;          $student = new MS\Student();          echo $student->sayHello();      In student:               <?PHP     namespace MyPluginClasses\Student     {         class Student{             public function __Construct(){                 echo "Hello Johnny";             }             public function sayHello(){                 echo "Hello Johnny's Method";                  }              }     }      This design works fine outside of WordPress.


using custom taxonomies on non wp table?

I'm building a program registration system that will have a complex data structure. There are programs (custom post type, CPT), teachers (CPT), registrations (custom table and meta table), payments (custom table and meta table), and later accommodations (CPT) and lastly Users (wp users table). I want to be able to use nice wordpress taxonomy features with my custom registration and payment tables. But I'm assuming I can't because the taxonomy system is only for the posts table. Is this correct? Basically I want to easily assign categories to registrations, and later be able to search on that, and have it flexible so the user can create their own categories. I ruled out using custom post type for the registrations and the payment tables only because then I would need a separate plugin to link everything up (scribu's post to post plugin) and it would make any mysql queries incredibly complicated. any advice would be greatly appreciated.


customizing wp user with custom fields

I want to allow the admin of a site i'm building to highly customize the wordpress user. This will be a highly advanced plugin so I'm fine creating a whole new page in the admin to do this customization (to avoid the weak hooks in the current user admin page). My question is this: how can I enable the admin to easily create custom fields of different types without coding? It is kind of like a custom meta box, but for users instead of posts. I know buddypress does this for the front end, the latest version 1.5 is quite powerful. I'm sure it could be adapted for the admin area, but that might be a lot of work. I also have coded a custom solution, but it is feature poor at the moment and I'm wondering if there is a better solution out there.


querying with custom meta field with meta_query

How do we get posts where the meta key does not exist in a post. I have created a meta_key video. and i want to be able to get some posts with WP_Query where custom field video does not exist or is blank.               $fsquery = new WP_Query(                              array (                              'posts_per_page' => 1,                             'featured' => 'yes',                             'meta_key'=>'video',                             'meta_value'=>''                             )                         );      this is not working.


Better way to display multiple plugin output on the same page?

Using two plugins on one page; promoslider & events list.   Tried to produce desired output.               +-----------------+     |  slider output  |     +-----------------+     Text related to events list     +-----------------+     |  events output  |     +-----------------+      Code listed below did not produce expected results.               // original code     [promoslider width="600px"]     Text related to events list     [events_list]      Instead produced output out of order.               Text related to events list     +-----------------+     |  slider output  |     +-----------------+     +-----------------+     |  events output  |     +-----------------+      Encapsulated short codes in html table seems resolve the issue               // Table code

[promoslider width="600px"]

Text related to events list

[events_list]

      Is there a better way to display multiple plugins on the same page?


Making a Plugin work based on URL Location

Is there any way to make my plugin work based on a URL instead of creating a page and attaching a shortcode? IE http://mysite.com/myplugin and that would bring up the starting page of the plugin


How to add all categories into an array and extract the categories names and use it with a custom meta box

Basically I need to add custom meta boxes to pages and one of this options must be a list of categories from previous posts. I've managed to add the metaboxes and wrapped the categories in a array, however there must be something I missing as on the page, only the first letter of the category name is being displayed. Here's a screenshot of the result: ![screenshot of the problem](http://i.stack.imgur.com/ow8Rf.jpg) I can't figure it out what I'm missing. Here's the code for the metabox:                           // Check if is page-homepage.php template             $post_id = (isset($_GET['post'])) ? $_GET['post'] : ((isset($_POST['post_ID'])) ? $_POST['post_ID'] : false);                  if ($post_id) :              $post_template = get_post_meta($post_id, '_wp_page_template', true);             if ($post_template == 'page-homepage.php') {                  // Add the Meta Box             function home_custom_meta_box() {                 add_meta_box(                     'home_meta_box', // $id                     'Custom Meta Box', // $title                      'home_show_custom_meta_box', // $callback                     'page', // $page                     'normal', // $context                     'high'); // $priority             }             add_action('add_meta_boxes', 'home_custom_meta_box');                  // Field Array             $prefix = 'custom_';             $home_custom_meta_fields = array(                 array(                     'label' => 'Title for the middle column',                     'desc'  => 'Optional',                     'id'    => $prefix.'title1',                     'type'  => 'text'                 ),                     array(                     'label' => 'Category',                     'id'    => $prefix.'category',                     'type'  => 'select',                     'options' => $wp_cats                 ),                 array(                     'label' => 'Title for the right column',                     'desc'  => 'Optional',                     'id'    => $prefix.'title2',                     'type'  => 'text'                 ),                 array(                     'label' => 'Textarea',                     'desc'  => 'A description for the field.',                     'id'    => $prefix.'textarea',                     'type'  => 'textarea'                 ),                 array(                     'label' => 'Checkbox Input',                     'desc'  => 'A description for the field.',                     'id'    => $prefix.'checkbox',                     'type'  => 'checkbox'                 ),                 array(                     'label' => 'Select Box',                     'desc'  => 'A description for the field.',                     'id'    => $prefix.'select',                     'type'  => 'select',                     'options' => array (                         'one' => array (                             'label' => 'Option One',                             'value' => 'one'                         ),                         'two' => array (                             'label' => 'Option Two',                             'value' => 'two'                         ),                         'three' => array (                             'label' => 'Option Three',                             'value' => 'three'                         )                     )                 ),                 array (                     'label' => 'Radio Group',                     'desc'  => 'A description for the field.',                     'id'    => $prefix.'radio',                     'type'  => 'radio',                     'options' => array (                         'one' => array (                             'label' => 'Option One',                             'value' => 'one'                         ),                         'two' => array (                             'label' => 'Option Two',                             'value' => 'two'                         ),                         'three' => array (                             'label' => 'Option Three',                             'value' => 'three'                         )                     )                 ),                 array (                     'label' => 'Checkbox Group',                     'desc'  => 'A description for the field.',                     'id'    => $prefix.'checkbox_group',                     'type'  => 'checkbox_group',                     'options' => array (                         'one' => array (                             'label' => 'Option One',                             'value' => 'one'                         ),                         'two' => array (                             'label' => 'Option Two',                             'value' => 'two'                         ),                         'three' => array (                             'label' => 'Option Three',                             'value' => 'three'                         )                     )                 ),                 array(                     'label' => 'Post List',                     'desc'  => 'A description for the field.',                     'id'    =>  $prefix.'post_id',                     'type'  => 'post_list',                     'post_type' => array('post','page')                 ),             );                  // The Callback             function home_show_custom_meta_box() {                 global $home_custom_meta_fields, $post;                 // Use nonce for verification                 echo '<input type="hidden" name="custom_meta_box_nonce" value="'.wp_create_nonce(basename(__FILE__)).'" />';                      // Begin the field table and loop                 echo '
';                 foreach ($home_custom_meta_fields as $field) {                     // get value of this field if it exists for this post                     $meta = get_post_meta($post->ID, $field['id'], true);                     // begin a table row with                     echo '
                             '.$field['label'].'	                             ';                             switch($field['type']) {                                 // text                                 case 'text':                                     echo '<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="30" />
'.$field['desc'].'';                                 break;                                 // textarea                                 case 'textarea':                                     echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'" cols="60" rows="4">'.$meta.'</textarea>
'.$field['desc'].'';                                 break;                                 // checkbox                                 case 'checkbox':                                     echo '<input type="checkbox" name="'.$field['id'].'" id="'.$field['id'].'" ',$meta ? ' checked="checked"' : '','/>                                             '.$field['desc'].'';                                 break;                                 // select                                 case 'select':                                     echo '<select name="'.$field['id'].'" id="'.$field['id'].'">';                                     foreach ($field['options'] as $option) {                                         echo '<option', $meta == $option['value'] ? ' selected="selected"' : '', ' value="'.$option['value'].'">'.$option['label'].'</option>';                                     }                                     echo '</select>
'.$field['desc'].'';                                 break;                                 // radio                                 case 'radio':                                     foreach ( $field['options'] as $option ) {                                         echo '<input type="radio" name="'.$field['id'].'" id="'.$option['value'].'" value="'.$option['value'].'" ',$meta == $option['value'] ? ' checked="checked"' : '',' />                                                 '.$option['label'].'
';                                     }                                     echo ''.$field['desc'].'';                                 break;                                 // checkbox_group                                 case 'checkbox_group':                                     foreach ($field['options'] as $option) {                                         echo '<input type="checkbox" value="'.$option['value'].'" name="'.$field['id'].'[]" id="'.$option['value'].'"',$meta && in_array($option['value'], $meta) ? ' checked="checked"' : '',' />                                                  '.$option['label'].'
';                                     }                                     echo ''.$field['desc'].'';                                 break;                                 // tax_select                                 case 'tax_select':                                     echo '<select name="'.$field['id'].'" id="'.$field['id'].'">                                             <option value="">Select One</option>'; // Select One                                     $terms = get_terms($field['id'], 'get=all');                                     $selected = wp_get_object_terms($post->ID, $field['id']);                                     foreach ($terms as $term) {                                         if (!empty($selected) && !strcmp($term->slug, $selected[0]->slug))                                              echo '<option value="'.$term->slug.'" selected="selected">'.$term->name.'</option>';                                          else                                             echo '<option value="'.$term->slug.'">'.$term->name.'</option>';                                      }                                     $taxonomy = get_taxonomy($field['id']);                                     echo '</select>
Manage '.$taxonomy->label.'';                                 break;                                 // post_list                                 case 'post_list':                                 $items = get_posts( array (                                     'post_type' => $field['post_type'],                                     'posts_per_page' => -1                                 ));                                     echo '<select name="'.$field['id'].'" id="'.$field['id'].'">                                             <option value="">Select One</option>'; // Select One                                         foreach($items as $item) {                                             echo '<option value="'.$item->ID.'"',$meta == $item->ID ? ' selected="selected"' : '','>'.$item->post_type.': '.$item->post_title.'</option>';                                         } // end foreach                                     echo '</select>
'.$field['desc'].'';                                 break;                                 // date                                 case 'date':                                     echo '<input type="text" class="datepicker" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="30" />
'.$field['desc'].'';                                 break;                                 // slider                                 case 'slider':                                 $value = $meta != '' ? $meta : '0';                                     echo '

                                             <input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$value.'" size="5" />
'.$field['desc'].'';                                 break;                                 // image                                 case 'image':                                     $image = get_template_directory_uri().'/images/image.png';                                       echo ''.$image.'';                                     if ($meta) { $image = wp_get_attachment_image_src($meta, 'medium'); $image = $image[0]; }                                                    echo    '<input name="'.$field['id'].'" type="hidden" class="custom_upload_image" value="'.$meta.'" />
                                                     <input class="custom_upload_image_button button" type="button" value="Choose Image" />                                                      Remove Image
'.$field['desc'].'';                                 break;                                 // repeatable                                 case 'repeatable':                                     echo '+
';                                     $i = 0;                                     if ($meta) {                                         foreach($meta as $row) {                                             echo '
|||                                                         <input type="text" name="'.$field['id'].'['.$i.']" id="'.$field['id'].'" value="'.$row.'" size="30" />                                                         -
';                                             $i++;                                         }                                     } else {                                         echo '
|||                                                     <input type="text" name="'.$field['id'].'['.$i.']" id="'.$field['id'].'" value="" size="30" />                                                     -
';                                     }                                     echo '
                                         '.$field['desc'].'';                                 break;                             } //end switch                     echo '
';                 } // end foreach                 echo '
'; // end table             }                  // Save the Data             function home_save_custom_meta($post_id) {                 global $home_custom_meta_fields;                      // verify nonce                 if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__)))                      return $post_id;                 // check autosave                 if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)                     return $post_id;                 // check permissions                 if ('page' == $_POST['post_type']) {                     if (!current_user_can('edit_page', $post_id))                         return $post_id;                     } elseif (!current_user_can('edit_post', $post_id)) {                         return $post_id;                 }                      // loop through fields and save the data                 foreach ($home_custom_meta_fields as $field) {                     $old = get_post_meta($post_id, $field['id'], true);                     $new = $_POST[$field['id']];                     if ($new && $new != $old) {                         update_post_meta($post_id, $field['id'], $new);                     } elseif ('' == $new && $old) {                         delete_post_meta($post_id, $field['id'], $old);                     }                 } // enf foreach             }             add_action('save_post', 'home_save_custom_meta');                  }      Here's how I've wrapped all categories into a array:                           // Get all categories from WP and create a dropdown             $categories = get_categories('hide_empty=0&orderby=name');             $wp_cats = array();             foreach ($categories as $category_list ) {                    $wp_cats[$category_list->cat_ID] = $category_list->cat_name;             }             array_unshift($wp_cats, "Choose a category");


How to search through pdf media files?

I have a blog with reasonable number of pdf files. How can I make wordpress look into pdf files when I search it? Thanks


Breaking up multiple words and inserting an image after first word

I'm not sure if it's possible, however, what I'm after is to break up WordPress titles that are multiple words and then insert an image. My current loop works just fine. Right now it gets the page's featured image, then shows the page title:                    WordPress Development      Here's the loop:               $args = array(         'post_parent' => $page_id->ID,         'showposts' => $show,         'post_type' => 'page',         'orderby' => 'menu_order',         'order' => 'ASC'     );     $subpages = new WP_query($args);          if ($subpages->have_posts()) : while ($subpages->have_posts()) : $subpages->the_post();              $output .= '
post_name.'-link">
post_name.'-info">
post_name.'-img">'.get_the_post_thumbnail($page->ID,'icons').'

'.get_the_title().'

';          endwhile; endif;          wp_reset_postdata();          return $output;      What I'm trying to accomplish is having the put more like this:               WordPress          Development      All of the page titles used in this loop with be 2 words. Any thoughts or suggestions on how to do this would be greatly appreciated.


How to log mysql errors from wordpress core?

I am developing a wordpress site and I would like to be able to log and handle mysql errors from wordpress core. My site has a mix of wordpress pages and posts + a few php pages that run under the wordpress engine. I configured the php.ini to prepend a php file to all php scripts with the error handling functions. They are working fine to catch php errors both in the wordpress core and in my own php scripts. I also catch all the MySQL errors in my own php scripts. For example, failure to connect to a database, etc. I would like to be able to also catch, log and process eventual MySQL errors from the wordpress core application. Any suggestions? Thanks. I was reading through the codex and I couldn't find an answer


Permalinks - Different structures for different categories?

Currently I use /%category%/%postname%/ as my permalink structure. However, I would like to have a different structure for different categories. This is because I have a "News" blog that I would like to have organized by date like this - /2011/10/02/. But I have other categories where I do not want a date structure at all. Is this possible?


How to remove pingback from head?

I know this question has been asked and answered 1000 times. However, I've never truly found a solution that removes pingback link tag from "wp_head". While there are several ways to block xml-rcp/pingback/trackback from wordpress I'm trying to add to that by blocking it from the head So basically I don't want this showing up in the rendered html:   Closest solution I've ever found was this:               add_filter( 'bloginfo_url', 'pmg_kt_kill_pingback_url', 10, 2 );     function pmg_kt_kill_pingback_url( $output, $show ) {         if( $show == 'pingback_url' ) {             $output = '';         }         return $output;     }      But it still shows up like this:               <link rel="pingback" href>      I know this isn't really a big deal, it was more annoying me than anything. I've been messing learning regex the past few days and I think I got the right patterns to remove pingback from the head. The following two patterns remove all cases (from what I've tested of pingback):               /<link.*?rel=("|\')pingback("|\').*?href=("|\')(.*?)("|\')(.*?)?\/?>/i          /<link.*?href=("|\')(.*?)("|\').*?rel=("|\')pingback("|\')(.*?)?\/?>/i      I used the output buffer to achieve this:               if (!is_admin()) {                   function link_rel_buffer_callback($buffer) {                 $buffer = preg_replace('/<link.*?rel=("|\')pingback("|\').*?href=("|\')(.*?)("|\')(.*?)?\/?>/i', '', $buffer);                 return $buffer;             }             function link_rel_buffer_start() {                 ob_start("link_rel_buffer_callback");             }             function link_rel_buffer_end() {                 ob_flush();             }             add_action('template_redirect', 'link_rel_buffer_start', -1);             add_action('get_header', 'link_rel_buffer_start');             add_action('wp_head', 'link_rel_buffer_end', 999);         }      However if I try to combine the two regex patterns it doesn't work               if (!is_admin()) {                   function link_rel_buffer_callback($buffer) {                 $buffer = preg_replace('/(?:<link.*?rel=("|\')pingback("|\').*?href=("|\')(.*?)("|\')(.*?)?\/?>|<link.*?href=("|\')(.*?)("|\').*?rel=("|\')pingback("|\')(.*?)?\/?>)/i', '', $buffer);                 return $buffer;             }             function link_rel_buffer_start() {                 ob_start("link_rel_buffer_callback");             }             function link_rel_buffer_end() {                 ob_flush();             }             add_action('template_redirect', 'link_rel_buffer_start', -1);             add_action('get_header', 'link_rel_buffer_start');             add_action('wp_head', 'link_rel_buffer_end', 999);         }      I think the problem is I need to use preg_match. I tried checking with this and it worked:               function print_preg_match() {              $pattern = '/(?:<link.*?rel=("|\')pingback("|\').*?href=("|\')(.*?)("|\')(.*?)?\/?>|<link.*?href=("|\')(.*?)("|\').*?rel=("|\')pingback("|\')(.*?)?\/?>)/i';     $subject = '<link rel="pingback" href="http://example.com/xmlrpc.php">';     if (preg_match($pattern, $subject, $matches)) {        echo 'You Got A Match';        }     }     add_action('all_admin_notices', 'print_preg_match');      However, I don't know how to use it correctly in this situation. This may be more of a stackoverflow question since it's dealing with regex, but i figured since it was specific to wordpress I put it up here.


get all page templates

I am working on a one page WordPress site. It's the first time I have tried this. I am on the fifth version with various degrees of success. I am starting a new version and I deleted everything in the theme folder except the header.php index.php, functions.php, footer.php, page templates and styles.css When I look in my database in the wp_postmeta, I can see that there are several pages in there that have a template assigned. I have seen this code before so I tried it for the first time to see what I could get. In my index.php file. I have the simple standard loop. you can see that right after the_post() I have tried the get_post_meta. My thought was that it would return all the names of the page templates. But it doesn't I actually get nothing. I tried a var_dump and a foreach loop to see what was in it. I get nada. I don't know why As a secondary question still related, my query below does not return every post in the database. It is only returning 2 blog posts, ( there are only 2 ) and 8 posts out of a lot. It is not showing any pages that were made. Can you give me a hint as to why?                <?php if (have_posts()) : while (have_posts()) : the_post(); ?>         <?php $template = get_post_meta($post->ID,'_wp_page_template',false); ?>         <?php var_dump($template); ?>                 <li id="page_<?php the_title(); ?>">                       <?php if(has_post_thumbnail()) {                          }                     the_content('Read the rest of this entry »'); ?>                 </li>         <?php endwhile; ?>              <?php else : ?>              //Something that happens when a post isn’t found.     <?php endif; ?>


Social network plugins for Wordpress

I would like to make my blog fully integrated with social networks. This mean: * Login via facebook / twitter   * Share to facebook / twitter   * Include open graph data in the page   * any other suggestions I've tried:   * Twit Connect but if you enable showing of tweet button under posts, it is included under pages too.   * ShareThis - it has option to show only under posts, but it stopped working after I've installed Simple OpenGraph.   * Simple OpenGraph - I'm happy with this one. _So, I think a canonical answer for this would be helpfull for the community and I'll be happy to give bounty for such._


How to fetch post and related information from post and postmeta table in WordPress?

I want to fetch post information and its related meta information in WordPress setup. Is it possible from single SQL Query? Post table columns: ID, post_title, post_content Post Meta columns: meta_id, post_id, meta_key, meta_value Actually I want a SQL query for dump of post and related information.


Closed html class after counter = multiple of 3

How to closed my class in multiple of 3. i don't want to use this               if ( $counter  == 3 ||  $counter  == 6 || $counter  == 9 || $counter  == 12)          {              $output.=' </div>';         }      but i want multiple of 3. like               if($counter  == 3 || $counter  == 3n)


Simple plugins to post info about new blog entries?

I am looking for some plugins that would automatically post information about new blog entries (posts) to my facebook/google+ pages. But - simple search through plugins listing shows that such plugins don't exists, or are rare. Most of the plugins offer content sharing the other way (i.e. display entries from facebook/google+ in your wordpress blog), or simply provide a way to have "Like"/"+1" buttons. Can anyone of you suggest a simple plugin to send notifications about new blog posts?


How can I see all of a post's comments on a single page as a reader, if pagination is enabled?

Is there an URL I can access, or an argument that can be passed, to disable pagination on the reader's side? The blog uses standard Wordpress comment pagination, i.e., http://example.com/2012/01/post-title/comment-page-1/ I'd like to be able to reformulate the URL into something like http://example.com/2012/01/post-title/all-comments


How to execute a plugin on a single page only?

A few basic questions to accelerate my wordpress plugin development start. I'd like to develop a wordpress plugin that adds some javascript and css to a specific page. What filters or actions should be used? How to restrict execution of a plugin to a single (known) page? How can a plugin add some content to a page?


How set template for "custom post type" individual post

For example, I have post named "My book number 1", that is in "Book" custom post type group. And is another post named "My book number 2", that is too in "Book" custom post type. Question: How I can set specific design template for "My book number 1" post?


Database of names with search engine

Hi I'm interested in creating website with a database of names and a search engine that finds matches for queries and displaying the full record for the relevant field. I would like to know how I could do this using Wordpress. Thanks


the_post_thumbnail() returns nothing even though has_post_thumbnail() returns true

has_post_thumbnail seems to be working fine but the_post_thumbnail returns nothing. here is my code:               if ($favorite_post_ids):         foreach ($favorite_post_ids as $post_id) {                 $p = get_post($post_id);                 echo "
";                 echo "post_title ."'>" . $p->post_title . " ";                 wpfp_remove_favorite_link($post_id);                 if (has_post_thumbnail($post_id))                 {                     echo $post_id;                     the_post_thumbnail($post_id);                 }                 echo "
";             }      Here is the sample output: > >     * Post101 remove 101 >     * Post97 remove 97 >     * Post59 remove 59 >   Most of the code above is irrelevant, I just included it for clarity. I have echoed the $post_id to make sure that it is passing the if (has_post_thumbnail($post_id)), which it does but the_post_thumbnail fails silently. I tried echoing it too but that returns nothing either. I have got post_thumbnails turned on in the theme:               if ( function_exists( 'add_theme_support' ) ) {        add_theme_support( 'post-thumbnails' );      }      **any ideas? thanks**


How do I get link URL (not file URL or attachment URL) of an attached image

> **Possible Duplicate:**   >  Retrieving a custom link on an attachment I am using images on a Wordpress page to link to other pages in the site. I know how to get an attached image's file or attachment URL, but I can't figure out how to get its URL if it's linked to another page. Take a look at here .The first image, "Women's clothes" links to a separate page in the site. I'm trying to make the caption of the attachment have the same link. I know how I can use the filter below to alter the caption to wrap it in an anchor tag, but I don't know how actually retrieve the URL of the attachment if it links to a separate page. Anyone have any ideas?               //Change Caption output     function my_caption($output, $attr , $content) {         extract(shortcode_atts(array(             'id'    => '',             'align' => 'alignnone',             'width' => '',             'caption' => ''         ), $attr));              if ( 1 > (int) $width || empty($caption) )             return $content;              if ( $id ) $id = 'id="' . esc_attr($id) . '" ';              return '
'         . do_shortcode( $content ) . '
' . $caption . '

';return $output;     }     add_filter('img_caption_shortcode','my_caption' , 10 , 3 );


Custom URL rewrites work, but break my permalinks

I'm doing custom URL rewrites according to this method , which work beautifully. But as a result my regular post permalinks are broken. So, I'm rewriting "/pagename/1232432" into "/pagename?param=1232432" like this:                   $wp_rewrite->add_rewrite_tag( $rewrite_tag, '(.+)', 'param=' );         $rewrite_keywords_structure = $wp_rewrite->root . "%pagename%/$rewrite_tag/";      (plus all the surrounding code from the example in the link above). Works fine. However, my normal posts like "/2011/03/hello-world/" no longer work. Any ideas? Cheers MickP


how do I set a schedule event to modify all posts's meta value weekly or monthly?

so far, I have added some functions to set post views count in post meta. But I want more: post_views_count_all: this is a post meta and save all post views; post_views_count_weekly: this is a post meta and save post views weekly then clean to 0; post_views_count_monthly: the same as above, but clean to 0 monthly. and below are my codes so far:               function twenty_set_post_views($content) {     $count_key = 'post_views_count';     $key_array = array(         'all',         'monthly',         'weekly',         'daily'     );     if(is_single()) {         global $post;         $postID = $post->ID;         foreach ($key_array as $key) {             $count_key_t = $count_key . '_' . $key;                  $count = get_post_meta($postID, $count_key_t, true);             if($count == '') {                 $count = 0;                 delete_post_meta($postID, $count_key_t);                 add_post_meta($postID, $count_key_t, '0');             }else{                 $count++;                 update_post_meta($postID, $count_key_t, $count);             }              }     }     }     add_action( 'the_content', 'twenty_set_post_views' );      I would use post views count to list popular posts last week. So, how do I set a schedule event to clean post_views_count_weekly and post_views_count_monthly to 0 every week or every month?


Import and replace existing page/post content

Is there any way to import a basic, exported Wordpress content XML file and have it replace the existing content? What I'm trying to do is synch up two instances of a site (development and staging servers) and all I want to replace is the Page content. When I try to import the XML document it simply states that all the pages already exist and nothing is done. Is it possible to override that warning and replace the content of the pages with the content of the XML?


external wordpress pages using wp-blog-header

I am setting up a few sections of a website external to the core wordpress installation, but I still want to use the built in wpdb functions, and/or header files from wordpress. I follow the instructions outlined in wordpress, setting up my headers:                <?      require('../cms/wp-blog-header.php');      define('WP_USE_THEMES', false);          .      . ?>      Everything works great. I can use wordpress' built in functionality while extending my site to use other functionality. In one case, the file is outside of my wordpress directory. In another case, the file is nested in a folder in the root of my wordpress directory. However, when loading the page in question, I get a 404 in the Net Panel of my inspector of the exact page I'm loading, like Wordpress can't find the page, but since it's a real php page, of course it loads. Most importantly, the pages fail to load using IE8. Does anyone have insight to this issue? Example Link More links and screenshots available, but I don't have enough reputation.


Customizing get_the_excerpt() to specific length and "Read More" output.

I am costuming a template. There is a list grabbing the introduction from the first 1-2 paragraphs (all the articles from a category). If I set the excerpt to 295 words, sometimes the list grabs additional words from the next paragraph. I would like to add a Read More tag to stop it. Can someone help me with that part?

             <?php echo get_the_post_thumbnail($page->ID, 'thubmnailstorysmall'); ?>

                              <?php print substr(get_the_excerpt(),wp_trim_excerpt(),295); ?>                 <a style="color:#1975D1;float:Right;" class="title" href="<?php the_permalink() ?>" rel="bookmark">Click for Story & Video


Wordpress 3.5 dropdown menu

I'm pretty new with wordpress and I want to create my own dropdown menu without the use of any plugins. I have a few questions about this. I already did some research but there are some things i do not understand. In my header file I have the following code for my main menu.               <div id="navigation">         <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>     </div>      I didn't have to add any code in my function.php file. It worked well. In the most tutorial, you have to add this code in to the function.php file. But for me it worked without this code.               <?php     add_action( 'init', 'register_my_menus' );     function register_my_menus() {     register_nav_menus(     array(         'main' => __( 'main' ),         ));     }     ?>      When I want to add a custom menu in wordpress I have to add something to this code.               <?php       add_action( 'init', 'register_my_menus' );     function register_my_menus() {     register_nav_menus(     array(         'main' => __( 'main' ),         **'secondary-menu' => __( 'Secondary Menu' ),**         ));     }     ?>      From this moment on, i can see 3 menu's in the backend. (2X primary menu, 1X secundary menu) I know this was a lot but I have tried to be clear and i hope somebody will understand me. Can somebody please tell me where i'm going wrong? Thanks


Q&A lite plugin comments

I am trying out the Q&A lite plugin from WPMU. It looks great except for one thing. It looks like users can only ask and answer question, not make comments on them. This effectively makes a conversation between two users very short. One question, one answer, that's it, excepting answers from other users of course, but there can be no conversation as such, which I find puzzling as to how effective it could be. Can anyone tell me if I am using it wrong? I think not but if I am I would like to know, otherwise can anyone recommend something similar.


Show posts containing or not custom field

I'm trying to show aditional posts in the author's page. This page must have posts containing a specific `meta_key` and `meta_value`, where the displayed author it is not really the WP post's author. This is the function I have:               function my_pre_get_posts( $query ) {              if ( is_admin() )             return;              if ( $query->is_main_query() ) :                  if ( is_author() ):                 $query->set( 'meta_query', array(                     'relation'      => 'OR',                     array(                         'key'       => 'writer',                         'value'     => 'the same author name'                     ),                     array(                         'key' => '',                         'value' => ''                     )                 ) );             endif;              endif;     }     add_action( 'pre_get_posts', 'my_pre_get_posts' );      But at a glance, it won't work. Sorry if my english is bad.


Rename a current used post type

Hi guys I'm working on this public theme where the previous developer had created a post type called "blog" the problem is that when you create a page with the same slug it creates a conflict. The theme is being used by several clients and I'm trying to avoid this issue by renaming the post type without having the users/clients to run by any problem. I'm doing the following:               $theme_executed = false;     if(!$theme_executed) {      theme_blog_news();      $theme_executed = true;     }          function theme_blog_news(){       $theme_sql= mysql_query("UPDATE  wp_posts SET  post_type =  'news' WHERE  post_type = 'blog'");       if (!$theme_sql) {         die('Invalid query: ' . mysql_error());       }     }      It worked but I'm looking for a best practice or a more native way. Thanks


Register and enqueue conditional (browser-specific) javascript files?

The WP.SE community has always advised the use of `wp_register_script` and `wp_enqueue_script` for adding scripts in a theme/template (and likewise, `wp_register_style` and `wp_enqueue_style` for stylesheets). * * * This is how I register and enqueue my scripts... **First, I add something like this in functions.php**               add_action('init','wpse54189_register_script');     function wpse54189_register_script(){              //Register scripts         wp_enqueue_script( 'jquery' );         wp_register_script( 'aahan_bootstrap_transition', get_template_directory_uri().'/js/bootstrap-transition.js');         wp_register_script( 'aahan_bootstrap_carousel', get_template_directory_uri().'/js/bootstrap-carousel.js', array('aahan_bootstrap_transition'));             wp_register_script( 'wpse54189_ajax_comment', get_template_directory_uri().'/js/no-reload-comments.js');     }      **then call it in a template file (say, header.php) like this**               <?php wp_enqueue_script( 'aahan_bootstrap_carousel' ); ?>     <?php wp_enqueue_script( 'wpse54189_ajax_comment' ); ?>      * * * Now, coming to the point, how do I register and enqueue "conditional JavaScript files" that are there to be recognized by specific browsers? For example:               <!--[if lt IE 9]>     <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>     <![endif]-->      How do I register and enqueue this properly? **PS:** I use the Reddle theme, developed by the theme wranglers at Automattic. And the theme's header.php directly uses the just aforementioned code -- i.e. it's not enqueued. So, does that mean, it's the only way to do it?


FTP file manager AS wordpress site

Ok, maybe it a far fetch question, and a question about depersonalisation of something into something else, but let try. One on my client want a easy file bin for his client to go get the public HR file for publicity. The main company have the HR pdf and some newspaper or local advertising need it. Instead of sending those file by email, CD or free FTP like "senduit.com" a site will be created. A bunch of folder, with a bunch of file. Let say **Winter 2010 AD**   * french ad 8.5 x 11   * english ad 8.5 x 11 **Summer 2011 AD**   * french poster   * English poster and so on, understand the concept ? So what will be the best plugin set or system for that... wordpress seem fit to that, but it's sont OUT OF THE BOX as this.. system should be secure, but's that just adding a password page.. that simple... What will be your solution ?


media-library: how to insert thumbnails with a fixed width, regardless of landscape/portrait orientation

I've asked a similar question before: How to create thumbnails with a fixed width, so all of them will have the same width? But... this one is related, but different. Please bear with me. Right now: if you insert an image in a post as a thumbnail by the media- library, you can choose between 4 different sizes: thumbnail, medium, big and actual size. This is fine. However: the dimensions of the thumbnail are determined by whether the image is landscape or portrait. You can set a maximum width or height in your media-settings. Maximum 300 width and maximum 300 height, for instance, will make a landscape image 300px width and a portrait image 300px height. So it won't be **always** 300px wide. Only if it's a landscape image. Please correct me, if I'm mistaken, but this is what I've encountered so far. The point: my client used to work with movable type, but decided to switch to wp. In mt, however, you could set a maximum width of a thumbnail, so that a thumbnail would be **always** this width, regardless of it being portrait or landscape. He wanted to have all of his thumbnails the same width, regardless of its orientation. This is not compatible with the way wp works, since the width will depend on the image's orientation. Question: how to make wp work like my client wants (ie: to set all the thumbnails the same width, whether landscape or portrait) And yes, the question is very similar to the one I referred to in the beginning, but that one was concerned with post-thumbnails which would be always the same size and this fixed width could be set within templates. In this case this is different: images are inserted in posts and the media- library determines the size. Not sure if I made myself clear. If I have: anyone has a solution? Be it a plugin (haven't found one yet) or a hack. If I haven't: shoot me and I'll try to clarify. Tnx!


Display post shortcode content in the sidebar?

I need to display images and other content in the sidebar depending on a page. Pages are added dynamically and information that need to appear in the sidebar is different for each page. So I can't predict what will go where. So the idea was is to have a page's content as usual (with all the neccessary shortcodes) and then at the end of page content have a shortcode with all the info that needs to appear in the sidebar for that page. * * * ### Original question: displaying shortcodes selectively (suppress in the main content and instead display in a sidebar) I was wondering if it's possible to display shortcodes "selectively". For example, a specific shortcode, let's call it `[sc]`, is specified within a page content. Now, when displaying that page's content I would like to suppress that specific `[sc]` shortcode, but instead display it from the sidebar for that page. Content of a page will have other shortcodes. I only want to do selectively display the specific `[sc]` shortcode and process others as usual - i.e. other shortcodes will be processed within the page's content. Is that possible to do? And how?


Making a horizontal flyout menu from WordPress category listing

I'm looking for some options for creating a horizontal flyout/rollover menu from the WordPress categories listing when category items have child nodes. Ideally, all in css, but I can include javascript or enqueue jQuery too.


How to Get a List of Sub Blogs without Using get_blog_list()?

The `get_blog_list()` function has been deprecated from v3.0. How does one get a list of blogs in a multisite blog?


Permalink structure and dedicated comment pages

I want to edit my permalink structure so that individual post URLs are structured like this...blog.com/p1, blog.com/p2, blog.com/p523, etc I also want to edit my permalink structure so that comment URLs are structured like this this...blog.com/c1, blog.com/c2, blog.com/c324, etc Are these two things possible via the permalink settings? If not could it be possible via building a customized plugin? Also...I'd like each comment to live on a dedicated page. Comments would still appear below posts, but each comment would have its own permalink that went to a dedicate page containing just that comment. Would something like this be possible via building a customized plugin? Thanks in advance for any advice you can offer! Eddie


What is difference between blog id and site id?

The going through the mu functions source I come across references to two different ids for sub-blogs - site id and blog ids. In what context is each used?


Summary and Comments on Main landing Page

I am having a wordpress blog at http://thelazy.info/ . By default, only one post is displayed on the page. I want to increase the default content on the main page to 5-10 posts with a small ting of comments. Is there some plugin or setting to do that in buddypress/wordpress.


Displaying posts of given category

I'm facing a strange problem:                 <?php $loop = new WP_Query( array( 'post_type' => 'ff', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => 10 ) );                   while ( $loop->have_posts() ) : $loop->the_post(); ?>          (...)                        <?php endwhile; ?>       This code displays all posts of "ff" type. Works fine. But I do not want to list all posts of this type, I just want the ones that are in "ff_show" category (so the slug/term is "ff_show). Codex tells me that I should use 'category_name' but when I do the loop is always empty:                 <?php $loop = new WP_Query( array( 'post_type' => 'ff', 'category_name' => 'ff_show',  'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => 10 ) );      I've tried typing everything after 'category_name', nothing works. The funny thing is when I use category instead of category_name - it ALWAYS shows all the posts. No matter what ID I give. Am I doing something wrong? I'm sure about my category name, it is exactly as I said. When I login to my panel admin and go to categories and hover over one of them it points to: > http://localhost/wordpress/wp-admin/edit- > tags.php?action=edit&taxonomy=frontpage_categories&post_type=ff&tag_ID=19 BUT 'cat' => '19' shows nothing. :/


Display Yoast WordPress SEO title in archive template

The WordPress SEO plugin by Yoast allows users to add SEO titles and meta descriptions to taxonomy term archive pages. These are then used in the head of the document. I´m trying to display the SEO title of taxonomy terms as an H1 in my taxonomy archive template. To do this in a post, post type or page is easy:               echo get_post_meta($post->ID, '_yoast_wpseo_title', true);       On archive templates this doesn´t work. Does anyone know how to get this to work? ## Screenshot example This is the title of a specific tag term. I´m trying to display this title - but then for a custom taxonomy term - in my archive templates. ![The tag archive edit screen](http://i.stack.imgur.com/8HiCY.png) ## Final code This is what I ended up using in my `archive.php` template. It works if you´re using a custom taxonomy. For tags or categories have a look at Mike Madern´s answer below.
     <?php     if ( is_tax() ) :                                                                            $taxonomy = get_queried_object()->taxonomy;         $term_id = get_queried_object()->term_id;         $meta   = get_option( 'wpseo_taxonomy_meta' );         $title  = $meta[$taxonomy][$term_id]['wpseo_title'];         //printf( '
%s
', print_r( get_option( 'wpseo_taxonomy_meta' ), 1 ) );         if ( isset($meta) && !empty($title) ) :                      echo apply_filters( 'the_title', $title );         else :             single_term_title();             endif;     endif;                                   ?>


Moving local dev (mamp) wp site to production server

Ive been working on a site locally using mamp, like all sites it consists of 4 main part which need to be moved :   * DB   * Theme + theme settings   * content    * plugins + settings.  Is there a simple way for me to move all of these to my production server is there a way i can package the lot an deploy in '1 click' or close to 1 click ? If there isnt whats the 'easiest' way to do this ? Would it be to ftp all my local files to the server, export my local db import the .sql file to the production server and edit the config files on the server to point to it ?


Translate language locally by Machine Object(.mo) method

I am using WordPress 3.9 and using papercut theme in my website. For language translation i have used Transposh plugin, but client wants language translation locally. I uploaded .mo files to wp-content/languages folder. But 'Duplicate Post' Plugin only get translated, according to that .mo file. Other than all string in wp(pages, post...) only in english, i don't know what happens? Suggest me what happen... I take that .mo file from papercut theme/languages folder.


Image attachement management - a philosophical question

I'm building a theme which includes displaying images which are not embedded in the body of the post by the user. I understand the correct approach to this is to use the concept of attached images - ie. that images uploaded on a particular post edit page are associated with the post in the DB. What I don't understand is WordPress has such meager support for this seemingly essential functionality. It is very poorly supported in the admin area - you cannot remove or view attachments, or attach a file that is already uploaded. Am I missing something? Is there a plugin to solve this problem.


Show one post per author and order by custom field

I display one post per author with function below and works fine, but is possible order by custom field?               <?php     add_filter('posts_groupby', 'author_groupby');     function author_groupby($groupby)     {      global $wpdb;      $author_groupby = "{$wpdb->posts}.post_author";         if(preg_match("/$author_groupby/", $groupby)) {         // grouping we need is already there         return $groupby;       }       if(strlen(trim($groupby) == 0)) {         // groupby was empty, use ours         return $author_groupby;       }       return "$groupby, $author_groupby";     }      I've tried with code below but do not works:               ...     $author_groupby = "{$wpdb->posts}.post_author      AND pm.meta_key = 'KEY'      ORDER BY pm.meta_value DESC Limit 0,1";     ...      Thanks


Excluded category from loop

I'm using this to exclude a particular category from the loop. It DOES that, but it also does this: On my PAGES, it displays the posts from the categories other than this one which is excluded.               /** Replace the standard loop with our custom loop */     remove_action( 'genesis_loop', 'genesis_do_loop' );     add_action( 'genesis_loop', 'child_do_custom_loop' );          function child_do_custom_loop() {              global $paged; // current paginated page         global $query_args; // grab the current wp_query() args         $args = array(             'category__not_in' => 7, // exclude posts from this category             'paged'            => $paged, // respect pagination         );              genesis_custom_loop( wp_parse_args($query_args, $args) );     }


Convert Wordpress pages to PDF

Just like I customize the CSS print for a page, I want to be able to convert the page to PDF. Many plugins I tried just display main content of the page or post without design; just plain text. I want to be able convert the page to PDF as it is. Is there a way to do this even without a plugin?


How do I use WP_query with multiple post IDs?

I want to query multiple posts with an array of IDs (note: I am querying a custom post type). Here's what I have, which isn't working:               $myarray = array('144', '246');          $args = array(        'post_type' => 'ai1ec_event',        'p'      => $myarray     );     // The Query     $the_query = new WP_Query( $args );      Any tips on how to do this?


pre_get_posts and set

I have some functions into my `pre_get_posts` filter. So, the problem is that when I set a `meta_query`, **all the menus disappear from the page**.               function propersearchfilter($query) {         $taxarray = array();         $metaarray = array();              array_push($metaarray , array(             'key' => 'wpcf-market',             'value' => 'forsell',             'compare' => 'LIKE'         ));              $query->set('meta_query', $metaarray);         return $query;     }     add_action('pre_get_posts', 'propersearchfilter', 1);


Special characters in WordPress UTF-8

I have a problem regarding special characters that are appearing messed up on the front-end . mainly the get converted to question marks, or something like �?) Example - Frédèric becomes Fr�d�ric. some facts that made me puzzled:   * This WP install is on LOCAL machine, and shares the server with at   least 40 other installs - none of which have this problem.   * This WP install shares also the same DB as the others .   * My wp-config file has the collate and charset defined.   * The DB seems fine , because when I am viewing the post in the EDITOR (back end) - all is correct , the problem is only on the FRONT end .     * The DB seems fine (2) , opening the post in phpMyAdmin and checking the direct value - all characters are fine .   * This problem is NOT a browser/os encoding , it was checked in 4   different machines, 3 OS, and 9 browsers.. I have tried all the solutions which I know from past experience, which include :   * checking the wp-config (it is ok, utf-8 defined, collate ok)   * Checking the DB - all UTF-8   * checking my header `(<?php bloginfo('charset'); ?>`) - that renders correctly as utf-8 with valid markup.   * Open all theme files in my editor, convert encoding to UTF-8 without bom and save. Did i missed something ? Any Ideas ??


URL conflict with a 'Single Page Layout'

I'm in the technical planning stages of a project which i intend to implement a 'Single Page Layout' on. I've setup the pages 'people', 'clients', 'contact', 'case studies' etc and taken the content into my Front Page template using the get_page() function, feeding it the page IDs. This works OK. I'm intending to have the top navigation menu items, when selected, navigate down the page to there respective section and update the url accordingly. e.g - _Select on 'people' (scrolls down page to 'people' section), url updates to example.com/people_ however, the url is in conflict, since the 'people' content is setup as a page. And the end-user will be taken away from the front page. Is there best practice for getting around this? Thanks in advance, Cam


I want to remove the http:// that is added automaticly on the user profile adress

I am using this field for something else and I don't want http:// to be added infront when it is updated, how can this issue be solved ? custome theme based on twentyeleven, wp v3.1.1 Thanks


Query Custom Post by Taxonomy Category

i hope you are well today, My question is just breif i am trying to query from a custom post type by a certain taxonomy only; to keep it streamline lets use the below as an example; **Custom Post Type:** _'Products';_ **Taxonomy:** _'Categories';_ **Categories within 'Categories';** _(1) Category 1 (2) Category 2 (3) Category 3_ So i would like query posts from the Custom Post Type **'Products'** and within **'Category 1'** How would this be done ? Here is my code for what querying the custom post type and attempting to query the taxonomy category.               <?php         $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         $post_per_page = -1; // -1 shows all posts         $do_not_show_stickies = 1; // 0 to show stickies         $args=array(         'post_type' => 'products',         'taxonomy' => 'category-1',         'paged' => $paged,         'posts_per_page' => $post_per_page,         'order' => 'ASC',         );         $temp = $wp_query;  // assign orginal query to temp variable for later use         $wp_query = null;         $wp_query = new WP_Query($args);         if( have_posts() ) : while ($wp_query->have_posts()) : $wp_query->the_post(); ?>


Hardcode a Plugin into theme

Hi im looking at hardcoding a wp plugin into a theme, the plugin is Calendar. This is what i have done as of yet: 1) Moved files from wp-content/plugins into a folder within theme folder and made the changes so that paths are followed correctly. 2) Set to populate database via an SQL query rather than via plugin activation 3) Altered role caps so that contributers can add / delete bookings etc What i am now wanting to do is remove the functionality of it having to be edited within wp-admin dashboard (even though its no longer in plugins folder it still requires editing in wp-admin, due to how the plugin sets the menus etc) and rather have post_author edit it on a created page within the theme (edit_booking.php). Its not so simple as taking out chunks of code and adding them into edit_booking.php (only the html works), im looking for a way how to port the whole thing over and away from wp-admin, im guessing that in wp-admin there are functions called via the header/footer that need also to be ported over into my own theme functions.php does anyone have experience of doing similar and care to share a few enlightening tidbits of info on how to go about this. Regards Martin


Conditional css for custom post type

I'm using a wordpress theme which uses custom post types for portfolio items and "sets" to categorize them. When I hover over a "set" to edit, it reveals this at the bottom of the browser: taxonomy=portfoliosets, &tag-id=37 &post_type=portfolios. I am trying to make it so the header image will change depending on the category or tag. We different sets such as "videos" and "magazines" etc. So far I've tried adding the following into header.php:               <?php  is_single( 'videos' ) ?>     <style type="text/css">     .page_header {     background: url('mysite/image.jpg') no-repeat scroll center center / cover #F9F9F9 ;     </style>      Which just seems to change the image for everything and:               <?php if ( has_tag('videos') && (in_category('portfolios')) )      { echo '    <style type="text/css">     .page_header {     background: url('mysite/image.jpg') no-repeat scroll center center / cover #F9F9F9 ;     </style>' ; } else { echo '' ; } ; ?>      Which just seems to give errors - any help much appreciated - thanks


Sync my svn repositories

I use my own svn repositories for all my development. I am looking for an easy way to keep the svn repository wordpress provides for my plugin synced up with my own internal repository. The desired end result being that when I commit a change to my own internal repository it gets duplicated automatically to my repository at plugins.svn.wordpress.org. ANd just to make things fun and interesting, I do not have any access to the server where my svn repositorys are held, I use a svn hosting service.


Is there a way to display content from a post meta box in the sidebar?

I'd like to display content from a custom meta box that appears for a particular custom post type in the sidebar, when a single post of that type is being displayed. I know how to normally display that content in the post content area, but I'm assuming that using that same code in a widget won't work, since the sidebar is outside of the loop (right?). Any suggestions?


Use flash on a wordpress site as a widget

I have a banner from a site and it's in flash (.swf file). I want to have this banner onto the widget bar. I'm currently using WP-SWFObject plugin, but it only works on the homepage. If someone goes to another page, the flash is not working. How can I use this flash banner on my site (with or without a plugin). Thx and sorry for my bad english (not my native language)


Output author and description if description is not empty

Is it possible to only display the author's name and description (aka bio) _if_ the description contains text? This code doesn't work (it doesn't return the name or description) but hopefully it can be edited to accomplish this goal:               <?php     $authorDesc = the_author_meta($post->ID, 'description', true);     if (!empty($authorDesc)) {     ?>     by <?php the_author(); ?>     <?php the_author_meta('description'); ?>     <?php } ?>


Run function on settings save

I am using the Settings API for a plugin's settings page. One of the settings allows the user to change the cron job interval for the cron job created by this plugin. Therefore I'd like to run a function on saving of the settings page, which checks the value in the database and compares it to the value the existing cron job has. If they are different, the cron job should be recreated. Is my logic right, and if so how can I run such a function after the plugin settings have been saved?


Sort pages in loop by admin's page attributes order field?

Is it possible to sort pages in the loop using the admin's order field (under page attributes)?


Image Alignment on Featured Images

When a client edits a featured image, they notice that they have the ability to set its "Alignment". If they were working with standard images embedded via the Editor, then this wouldn't be a problem. But since it is a featured image, WordPress doesn't pass in the appropriate class. Is there a way to know which alignment option was set? If so, I can use that to add a class to the featured thumbnail accordingly.


Remove WHERE conditions from search query

The native search page runs a query like so:               SELECT SQL_CALC_FOUND_ROWS  wp_posts.*      FROM wp_posts      WHERE 1=1 AND (((wp_posts.post_title LIKE '%keyword%')      OR (wp_posts.post_content LIKE '%keyword%'))      AND (wp_posts.post_password = '')      AND wp_posts.post_type IN ('post', 'page', 'attachment')      AND (wp_posts.post_status = 'publish')      ORDER BY wp_posts.post_date DESC LIMIT 0, 10      I am passing specific post IDs to the query by hooking into pre_get_posts so I don't need the other `WHERE` conditions related to the keyword. e.g.               add_filter('pre_get_posts','my_search_filter');     function my_search_filter($query) {         if ($query->is_search) {                 // post IDs within distance X             $matches = array(1,3,5);             $query->query_vars['post__in'] = $matches;              }     }      How can I remove the conditions related to post_title and post_content from the query object by modifying the existing query rather than writing a new one.


Including content from legacy app: via plugin or custom content?

I am looking to integrate content that exist in a legacy system to a wordpress blog. The content can be accessed from the legacy system via SOAP. I have some PHP experience and some (limited) experience with Wordpress so I would like to ask what the best approach for something like this would be. In terms of how I need it to work there are three elements. One is that the content items would be displayed in a list, second is that more detail of each item could appear on it's own page and third is that there would be a specific form (which will need to eventually send some stuff back via SOAP) for each item (and detail page). At first I thought that I should create and use a plugin (or an existing one but I can't find a generic SOAP one) but I read a bit about custom post types and I wonder if maybe that's what I should use. The problem is that the content will be changing in the legacy system and this site needs to only have the current content so I guess plugin is maybe the only way. I just don't feel comfortable enough with my wordpress experience to feel I am going to make the best choice here. In terms of responses I would be willing to consider other options I haven't covered (because I just don't know what they would be) but otherwise some advice on direction here would be really appreciated. If this is too vague I would be happy to supply more info on any specific points.


How do I display something on a particular category page?

How would I display HTML conditional on a particular category page? Say my permalinks to the category pages are http://www.mysite.com/category/awesome-category How would I cast the `<?php if ... ?>` to do this, and within what template of my theme? I'm using WP 3.3.1. If I need to provide more information I'll be happy to. Thanks!


Is there a way to exclude posts based on meta_values?

I have a need to exclude posts based on a custom field type. It will probably be a field such as "legacy" or "depricated". I searched for an example on how this would be done but I haven't found anything worth while. Any help would be appreciated.               <?php                 $software = array('post_type' => 'software', 'category_name' => $model);                 query_posts( $software );                 get_template_part( 'loop', 'software' );                 wp_reset_query();                 ?>


WP disobeys disabling of the posts revision feature

I disabled the posts revision feature according to this codex by placing this code in the wp-config.php: `define('WP_POST_REVISIONS', false );` But revions are still being saved by the WP. Why? I am using wp3.1.3 and Twenty Ten theme. I have couple of plugins, and disabling them does not resolve the issue.


Function code problem

I changed my taxonomy slug from singular to plural ("state" to states"). Ever since then my taxonomy has been broken. It used to say OTHER instead of the state name. Now my urls look like this Domain.com/location/%states%/post- name Im using wp-types.com and their support has been EXTREMELY horrible. I barely even get a short useless response once every 4 days. They provided me with this code for my themes function file (i placed it at the end): ` add_filter('post_type_link', 'my_permalink_structure', 10, 4); function my_permalink_structure($post_link, $post, $leavename, $sample) { if ( false !== strpos( $post_link, '%states%' ) ) { $term = get_the_terms( $post->ID, 'states' ); $post_link = str_replace( '%states%', array_pop($term)->slug, $post_link ); } return $post_link; } ` And it gives me this error: Parse error: syntax error, unexpected T_FUNCTION, expecting T_STRING or T_VARIABLE or '$' in /home/content/33/8824133/html/wp- content/themes/education/functions.php on line 131


Programatically create a page

Is it possible to programatically create a page? I want to make it so that I can create a template file in a theme and be able to point links to that page without having to rely on the user to go and manually create a page using the tempalte. Is that possible? ### Update: Solution so Far This is what I have come up with so far:               add_action( 'init', 'add_virtual_page_template' );          function add_virtual_page_template()     {         global $wp, $wp_rewrite;              $wp->add_query_var( 'template' );         add_rewrite_endpoint( 'fish', EP_ROOT );              $wp_rewrite->add_rule(  'fish/?', 'index.php?template=fish', 'top' );         $wp_rewrite->flush_rules();     }          add_action( 'template_redirect', 'add_virtual_page_redirect' );          function add_virtual_page_redirect()     {              global $wp;         $template = $wp->query_vars;              if ( array_key_exists( 'template', $template ) && $template['template'] == 'fish' )         {              global $wp_query;         $wp_query->set( 'is_404', false );         include( get_stylesheet_directory() . '/page-fish.php' );         exit;     }      Both of these are in the functions.php file of my theme. This code successfully serves the content of page-fish.php as if I had created a page and set it as the template. The one thing that has come up so far: the URL of the site using this method is www.url.com/login/ However, if I create a page and set the template manually, the URL is as following: www.url.com/login It is relatively minor, but is there some way of fixing this issue? Are there any other issues that I might run into using the overall method that I used here?


Customize my custom taxonomy table in Admin panel

I've registered a new taxonomy for my custom post type, and now I'm trying to edit the taxonomy table. I've successfully removed the description column but I can't figure it out **how to edit column width for the column that shows the number of custom post types found** in that particular taxonomy. The column's CSS class seems to be `column-posts`, and thus, its width is set to `10%`. **Shouldn't the column's CSS class be`column-{my-custom-post-type}` and not the default?** **Can I somehow force the column's width be set to`auto` or set its class to match my custom-post-type?** Here's what I've done so far: **Custom Post Type**               function registerPersonnelPostType() {         $labels = array(             'name'                  => __( 'Personnel', 'xxx' ),             'singular_name'         => __( 'Personnel', 'xxx' ),             'add_new'               => __( 'Add New', 'xxx' ),             'add_new_item'          => __( 'Add New Personnel Member', 'xxx' ),             'edit_item'             => __( 'Edit Personnel Member', 'xxx' ),             'new_item'              => __( 'New Personnel Member', 'xxx' ),             'view_item'             => __( 'View Personnel Member', 'xxx' ),             'search_items'          => __( 'Search Personnel', 'xxx' ),             'not_found'             => __( 'No personnel found', 'xxx' ),             'not_found_in_trash'    => __( 'No personnel found in Trash', 'xxx' ),             'parent_item_colon'     => __( 'Parent Personnel:', 'xxx' ),             'menu_name'             => __( 'Personnel', 'xxx' )         );              $args = array(             'labels'                => $labels,             'hierarchical'          => true,             'description'           => 'Staff names and descriptions',             'supports'              => array( 'title', 'editor', 'thumbnail' ),             'public'                => true,             'show_ui'               => true,             'show_in_menu'          => true,             'menu_position'         => 20,             'show_in_nav_menus'     => true,             'publicly_queryable'    => true,             'exclude_from_search'   => false,             'has_archive'           => true,             'query_var'             => true,             'can_export'            => true,             'rewrite'               => true,             'capability_type'       => 'post'         );              register_post_type( 'personnel', $args );     }      **Taxonomy**               function departmentInit() {         $labels = array(                     'name'                  => __( 'Department', 'xxx' ),             'singular_name'         => __( 'Department', 'xxx' ),             'search_items'          => __( 'Search Departments', 'xxx' ),             'all_items'             => __( 'All Departments', 'xxx' ),             'parent_item'           => __( 'Parent Department', 'xxx' ),             'parent_item_colon'     => __( 'Parent Department:', 'xxx' ),             'edit_item'             => __( 'Edit Department', 'xxx' ),             'update_item'           => __( 'Update Department', 'xxx' ),             'add_new_item'          => __( 'Add New Department', 'xxx' ),             'new_item_name'         => __( 'New Department Name', 'xxx' ),             'menu_name'             => __( 'Department', 'xxx' )         );              $args = array(             'labels'                => $labels,             'hierarchical'          => true,             'show_ui'               => true,             'query_var'             => true,             'rewrite'               => array( 'slug' => 'department' )         );              register_taxonomy( 'department' , array('personnel'), $args );     }      **Hooks for editing columns**               add_filter( 'manage_edit-department_columns', 'departmentColumns' );          function departmentColumns( $columns ) {             if ( isset( $columns[ 'description' ] ) ) {             unset( $columns[ 'description' ] );         }              return $columns;             }


child of post type (custom)

I registered a custom post type (foo) with `register_post_type`, setting `'hierarchical' => true,`so now when I want to use it I have `post_type=foo`. How can I query child of foo? any ideas? thanks!


How to stop wordpress from mangling HTML in a metabox textarea

Can anyone lend a hand and suggest the best way to get a textarea in a meta box to stop mangling HTML? I've been digging around here online... and here...and also here...looking for answers, but I don't know how to piece them together properly to fit with what I've already done. Here's what I have...               add_action("admin_init", "tf_book_deets_create");          function tf_book_deets_create(){              add_meta_box('tf_book_details', 'Book Details', 'tf_book_details', 'books');     }          function tf_book_details () {         global $post;              $custom = get_post_custom($post->ID);              $tf_book_media = $custom["tf_book_media"][0];         $tf_book_review = $custom["tf_book_review"][0];              ?>

Reviews:<textarea rows="5" cols="70" name="tf_book_review" value="<?php echo $tf_book_review; ?>" ></textarea>

Media:<textarea rows="5" cols="70" name="tf_book_media" value="<?php echo $tf_book_media; ?>" ></textarea>

               <?php }              add_action ('save_post', 'save_tf_book_details');                 function save_tf_book_details(){          global $post;                  update_post_meta($post->ID, "tf_book_media", $_POST["tf_book_media"]);             update_post_meta($post->ID, "tf_book_review", $_POST["tf_book_review"]);              }      I'm just looking for some ideas. Thank You!