w3 total cache and post__not_in

I'm using a modified version of the Recent Posts plugin together with WP Total Cache. I'm using post__not_in as I don't want to display the current post again. It works well, but if Object Cache is activated, on some posts post__not_in does not work. Here is my code:               <?php function nothing_recent_posts_init() {                     register_widget('nothing_recent_posts');                 }                 add_action('widgets_init', 'nothing_recent_posts_init');                           class nothing_recent_posts extends WP_Widget {                          function __construct() {                         $widget_ops = array('classname' => 'nothing_recent_posts', 'description' => __( "Customized version of Recent Posts. You can choose what to display and add custom classes.") );                         parent::__construct('nothing-recent-posts', __('Customized Recent Posts'), $widget_ops);                         $this->alt_option_name = 'nothing_recent_entries';                              add_action( 'save_post', array($this, 'flush_widget_cache') );                         add_action( 'deleted_post', array($this, 'flush_widget_cache') );                         add_action( 'switch_theme', array($this, 'flush_widget_cache') );                     }                          function widget($args, $instance) {                         $cache = wp_cache_get('nothing_recent_posts', 'widget');                              if ( !is_array($cache) )                             $cache = array();                              if ( ! isset( $args['widget_id'] ) )                             $args['widget_id'] = $this->id;                              if ( isset( $cache[ $args['widget_id'] ] ) ) {                             echo $cache[ $args['widget_id'] ];                             return;                         }                              ob_start();                         extract($args);                              $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' );                         $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );                         $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 10;                         if ( ! $number )                             $number = 10;                         $show_title = isset( $instance['show_title'] ) ? $instance['show_title'] : false;                         $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;                         $show_img = isset( $instance['show_img'] ) ? $instance['show_img'] : false;                         $custom_class = ( ! empty( $instance['custom_class'] ) ) ? $instance['custom_class'] : ' ';                         $query_by_cat = isset( $instance['query_by_cat'] ) ? $instance['query_by_cat'] : false;                              if( $query_by_cat ){                             $current_category = wp_get_post_categories( get_the_id() );                             $r = new WP_Query( apply_filters( 'widget_posts_args', array(                                 'category__in' => $current_category,                                 'posts_per_page' => $number,                                 'no_found_rows' => true,                                 'post_status' => 'publish',                                 'ignore_sticky_posts' => true,                                 'post__not_in' => array(get_the_id())                             ) ) );                         }else{                             $r = new WP_Query( apply_filters( 'widget_posts_args', array(                                 'posts_per_page' => $number,                                 'no_found_rows' => true,                                 'post_status' => 'publish',                                 'ignore_sticky_posts' => true,                                 'post__not_in' => array(get_the_id())                             ) ) );                         }                         if ($r->have_posts()) : ?>                         <?php echo $before_widget; ?>                         <?php if ( $title ) echo $before_title . $title . $after_title; ?>                              <?php while ( $r->have_posts() ) : $r->the_post(); ?>                              <article class="hentry <?php echo $custom_class; ?>">                             <a href="<?php the_permalink(); ?>" rel="bookmark" title='Den Beitrag "<?php the_title(); ?>" ansehen'>                                      <?php if ( $show_img ) : ?>
                                     <?php the_post_thumbnail( 'thumbnail' ); ?>
                                 <?php endif; ?>                                      <?php if ( $show_title ) : ?>

<?php the_title(); ?>

                                                                  <?php endif; ?>                                      <?php if ( $show_date ) : ?>                                     <?php echo get_the_date(); ?>                                 <?php endif; ?>
                         <?php endwhile; ?>                              <?php echo $after_widget; ?>                         <?php wp_reset_postdata();                              endif;                              $cache[$args['widget_id']] = ob_get_flush();                         wp_cache_set('nothing_recent_posts', $cache, 'widget');                     }                          function update( $new_instance, $old_instance ) {                         $instance = $old_instance;                         $instance['title'] = strip_tags($new_instance['title']);                         $instance['number'] = (int) $new_instance['number'];                         $instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false;                         $instance['show_title'] = isset( $new_instance['show_title'] ) ? (bool) $new_instance['show_title'] : false;                         $instance['show_img'] = isset( $new_instance['show_img'] ) ? (bool) $new_instance['show_img'] : false;                         $instance['custom_class'] = strip_tags($new_instance['custom_class']);                         $instance['query_by_cat'] = isset( $new_instance['query_by_cat'] ) ? (bool) $new_instance['query_by_cat'] : false;                         $this->flush_widget_cache();                              $alloptions = wp_cache_get( 'alloptions', 'options' );                         if ( isset($alloptions['nothing_recent_entries']) )                             delete_option('nothing_recent_entries');                              return $instance;                     }                          function flush_widget_cache() {                         wp_cache_delete('nothing_recent_posts', 'widget');                     }                          function form( $instance ) {                         $title     = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';                         $number    = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;                         $show_title = isset( $instance['show_title'] ) ? (bool) $instance['show_title'] : true;                         $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false;                         $show_img = isset( $instance['show_img'] ) ? (bool) $instance['show_img'] : false;                         $custom_class     = isset( $instance['custom_class'] ) ? esc_attr( $instance['custom_class'] ) : '';                         $query_by_cat = isset( $instance['query_by_cat'] ) ? (bool) $instance['query_by_cat'] : false;                 ?>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?>                         <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" />

<label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of posts to show:' ); ?>                         <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo $number; ?>" size="3" />

<input class="checkbox" type="checkbox" <?php checked( $show_title ); ?> id="<?php echo $this->get_field_id( 'show_title' ); ?>" name="<?php echo $this->get_field_name( 'show_title' ); ?>" />                         <label for="<?php echo $this->get_field_id( 'show_title' ); ?>"><?php _e( 'Display post title?' ); ?>

<input class="checkbox" type="checkbox" <?php checked( $show_date ); ?> id="<?php echo $this->get_field_id( 'show_date' ); ?>" name="<?php echo $this->get_field_name( 'show_date' ); ?>" />                         <label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php _e( 'Display post date?' ); ?>

<input class="checkbox" type="checkbox" <?php checked( $show_img ); ?> id="<?php echo $this->get_field_id( 'show_img' ); ?>" name="<?php echo $this->get_field_name( 'show_img' ); ?>" />                         <label for="<?php echo $this->get_field_id( 'show_img' ); ?>"><?php _e( 'Display post image?' ); ?>

<label for="<?php echo $this->get_field_id( 'custom_class' ); ?>"><?php _e( 'Custom class:' ); ?>                         <input class="widefat" id="<?php echo $this->get_field_id( 'custom_class' ); ?>" name="<?php echo $this->get_field_name( 'custom_class' ); ?>" type="text" value="<?php echo $custom_class; ?>" />

<input class="checkbox" type="checkbox" <?php checked( $query_by_cat ); ?> id="<?php echo $this->get_field_id( 'query_by_cat' ); ?>" name="<?php echo $this->get_field_name( 'query_by_cat' ); ?>" />                         <label for="<?php echo $this->get_field_id( 'query_by_cat' ); ?>"><?php _e( 'Filter by current category?' ); ?>
                      <?php                     }                 }


How can I limit posts when using template_redirect?

I'm trying to redirect a query (http://example.com/custom-post- type/?action=create) to a template file (page.php) while also replacing the_content. I've more or less gotten it to work. But the end result show duplicate content on a page, so I guess it's being treated as archive page. I tried using a pre_hook to limit the query to 1 result, but that didn't work. Any suggestions? Here's my code.... http://pastebin.com/1SwaKKxW


Is there any way to set default for "Insert/Edit Link" to "Open link in new window"?

I almost always select "Open link in new window" when creating an URL/HREF. Is there any way to default this choice. Even if it requires a small source code change, I think it would be worthwhile (if someone can tell me where that might be.)


WP script versioning breaks cross-site caching?

I am loading JQuery from the google CDN using the following code:               wp_deregister_script('jquery');       wp_register_script(         'jquery', // handle - WP uses this name to refer to script         'http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js',          array(), // Array of handles representing scripts that this one depends on.          false, // Version number - defaults to false.          false // false = put script in header, true = put in footer      );     wp_enqueue_script('jquery');      In firebug I see that wordpress appends '?ver=3.0.4' to the URL to control caching. In fact there doesn't seem to be any way to stop WP from appending **something** to the URL - I can provide my own string in the call to wp_register_script() but WP will use the default 'ver=3.0.4' if i leave it blank (or "false") I believe the appended version string stop the user's browser from re-using a cached copy of the file that it might have downloaded from a **different** website. E.g.   1. User visits www.example.com which loads ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js so it is now in browser cache.   2. User then visits my site which loads ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js?ver=3.0.4   3. The user's browser not use it's cached copy because the URLs are different. Since cross-site caching is one of the main reasons I want to use Google's CDN, are there any solutions to this other than loading the script manually (not ideal) or hacking WP core? TIA /Eoin/


wp_schedule_event() set daily, but processed every second

Reading wp_schedule_event() documentation got me code something like this:               add_action('cr_paid_link_manager_generate_expiring_link_email_action','cr_paid_link_manager_generate_expiring_link_email');     wp_schedule_event(time(), 'daily', 'cr_paid_link_manager_generate_expiring_link_email_action');      The problem is, `cr_paid_link_manager_generate_expiring_link_email()` is generated everytime page load, or so it look's like. This code supposed to send email only once a day. I try to set first parameter of `wp_schedule_event()` to `$timestamp_start`:               $timestamp_start = '2011-01-26 00:00:00';     add_action('cr_paid_link_manager_generate_expiring_link_email_action','cr_paid_link_manager_generate_expiring_link_email');     wp_schedule_event($timestamp_start, 'daily', 'cr_paid_link_manager_generate_expiring_link_email_action');      Still no result. The code keep sending email Every minute. Is there something missing on my code?


Wordpress.com post editor replacement

I love Wordpress, and I keep a blog on a domain hosted at wordpress.com. However, it's so damn slow! (Blogger wasn't much better.) Are there any full- featured substitutes available? I use several computers, depending on where I am and what I'm doing: An older mac, a windows netbook, and a ChromeOS laptop, so the best solutions for me will be web-based, but I won't rule out desktop apps. Aside from the slowness, I can't stand the little tiny window in the posyst editor (there's a fullscreen view, but not in code view), and as I tend to edit the HTML directly, syntax highlighting would be extremely helpful.


After server migration only the homepage works

I have recently changed hosting of my WordPress site to VPS.net. I have moved all of my files and imported the database. Everything appeared to be fine until I clicked a link and noticed that all of my pages are bringing back a 404 except the homepage. Site URL is http://inksquared.com


wp_list_categories pagination

I was wondering if I can paginate wp_list_categories? I had a go with paginate_links but no luck. Or is there a good workaround? Thank you!!               <?php   $orderby = 'name';         $show_count = 0;         $pad_counts = 0;         $hierarchical = 1;         $taxonomy = 'categories';         $title = '';         $exclude = '16';              $args = array(         'orderby' => $orderby,         'show_count' => $show_count,         'pad_counts' => $pad_counts,         'hierarchical' => $hierarchical,         'taxonomy' => $taxonomy,         'title_li' => $title,         'exclude' => $exclude,         'hide_empty' => 0         );         ?>         <ul class="resourcelist">         <?php wp_list_categories($args); ?>         </ul>


Get top items number from wordpress menu

I've made a menu in Wordpress backend with 3 levels depth. (4 main tabs with 2 sub level items) I would like to know how I can get the number of tabs created automaticly and add this number to a class on the ul (i.e: .item-4) Any ideas? I'm already using a custom Walker. Thanks


Passing a variable via wp_head and then calling it on the page

As my question suggests I'm having difficulty creating a variable in the header, via functions.php and wp_head, and then calling that variable further down the page. For example, in functions.php               add_action( 'wp_footer', 'add_ran_var' );          function add_ran_var () {            $random_variable = "1";          }       And before the               </head>       tag include               <?php wp_head(); ?>      in header.php The problem arises if i try to call $random_variable later on in the page. It returns nothing.               <?php echo $random_variable; ?>      Could anyone please shed some light as to why this does not work? Has it something to do with the order the different files (header.php, functions.php) are called? Thanks in advance to anyone who can offer me some advice on the above. Cheers Noel


Is it possible to integrate Wordpress *posts* and social media (Facebook, Google+, Twitter)?

Is there a plugin available that will automatically post an excerpt of a blog post (perhaps up to the more tag) to specified social media groups/pages. So, for example, on posting an excerpt would be posted with a 'Read more' link to a user-defined Facebook group, G+ page and, possibly, twitter feed? If not, is there a method for automating this process? Or is copy>paste the only realistic option? (I know that Dsiqus provides the ability to link comments and social media but this functionality doesn't extend to posts, as I understand it.)


Managing database tables in WordPress multisite

I'm working on plugin that creates and stores some data in database table (using global $wpdb->base_prefix). In WordPress multisite I want sub-website owners to have access only to data that they've created. What is the best way to handle this? Should I create new table for each sub-website, or add "blog_id" column to table and check it every time? Thanks for help.


How to translate "ERROR: Invalid username. Lost your password?"

I want to translate the above message which appears on invalid username. I know the answer is very similar to the one proposed here by I cannot find the exact handler. Thank you.


Does anyone have a plugin that could automatically tag custom post types in wordpress?

I was looking at http://wordpress.org/extend/plugins/web-ninja-auto-tagging- system/ and unfortunately, it wont work on custom post types. Can anyone suggest (with what changes are needed) to have this work for custom post types?


Allow non-logged in users to see a future post after clicking on a list of future posts

I have been able to list out pages that are set for future in a custom template like this:               query_posts('post_type=page&post_status=future&posts_per_page=100&order=asc&orderby=date&meta_key=_wp_page_template&meta_value=show.php');      However, when I try to then click on one of the pages listed there I get a 404 (as a non-logged-in user). How do I alter a thematic page.php template to show a future page? We are already using a bunch of things in function.php and have a special page template for this particular type of post... I tried adding the following to the functions.php with `add_filter`, but it didn't help:               function show_future_where($where) {         return $where . ' AND (wp_posts.post_status = \'publish\' OR wp_posts.post_status = \'future\')';     }      BTW, I saw a post about automatically setting a post with a future date would be overridden with 'published' state, but couldn't get that to work. If I can edit the page template is there something else I can do? I am using 3.3, if that helps. Thanks.


How to override existing plugin action with new action

I'm using a plugin. It has an action like this.               add_action('publish_post', 'old_action');     function old_action($pid) {         "code goes here"         }     }      I'm writing a module for this plugin. So i need to override that old action function with my new action function. This is my new function.               function new_action($pid) {           "code goes here"             }         }      I want to replace that old_action function with my new_action function using hooks. Can anyone help me? Thanks


Finding the index page using the admin panel of wordpress

I am helping out a non profit and they wanted some help in modifying the home page of their site .I looked around the admin area but I couldnt not find the index page anywhere so that I could make the changes. Where should I be looking and if I cant find it from the admin page ,what other ways can I go about finding it.


Column sorting with emtpy meta values

I am trying to sort my custom post type columns in the admin area. There's two ways I found to do this: At first this was my way to do it, however I got some strange behaviours. If a meta value is not set, the filter will remove the post from the list, rather than sorting it.               add_filter('request', array($this, 'sort_columns') );     public function sort_columns( $vars ) {          if ( isset( $vars['orderby'] ) && 'startdate' == $vars['orderby'] ) {             $vars = array_merge( $vars, array(                 'meta_key' => '_start_event_datetime',                 'orderby' => 'meta_value_num'             ) );         }     }      Hoping to solve this strange behaviour I came across another way to do it, but I got the same behaviour.               add_action('pre_get_posts', array($this, 'sort_columns') );     public function sort_columns( $query ) {          $orderby = $query->get( 'orderby');                if( 'startdate' == $orderby ) {               $query->set('meta_key' , '_start_event_datetime');               $query->set('orderby' , 'meta_value_num');           }       }      How do I get my posts that have no meta value set to be sorted instead of removed?


WordPress permalinks  Yahoo hosting(no .htaccess allowed)

I have moved a Wordpress install to a client from sub folder to the root folder. Right now, everything works fine, except for the friendly URLs. I currently have to set the Permalink feature in "Common settings" to "Default", which means URLs with ?p=434... At least they work. Otherewise I get a very short 404 not found error message on a white screen. I was following this tutorial, but I found I cannot write an .htaccess to my Yahoo host account and so I could not follow one of the last steps... I wonder if the 404 not found errors have to do with this problem I have had uploading the .htaccess file... I currently do not have any .htaccess file up there... So maybe MOD_REWRITE is disabled... I have just ran phpinfo() and did not find any entry on mod_rewrite. Before moving the website, when it was still on a subfolder, the friendly URLs used to work, but now they don't. Has anyone came accross this experience and has successfully restablished the permalinks feature? Any help is appreciated. Thank you.


admin_notices on runtime in function

I have a function that is called at a post updated, inside of this function I am doing something and if this went wrong I want to display an `admin_notices`. **Inside** of my **function** I tried the following:               if($error) {         add_action( 'admin_notices', 'my_admin_notice' );     }      `my_admin_notice` looks like:               function my_admin_notice() {         ?>

Error happend

         <?php     }      If I call `add_action( 'admin_notices', 'my_admin_notice' );` outside of my function it's working, but unfortunately the notice is display always... :/ **Update - Context details:** My function is called with `add_filter ( 'publish_post', 'my_function' );` Inside of this function I check if the post is published the first time, than I am doing some stuff and if there is something wrong I want to call the `add_action( 'admin_notices', 'my_admin_notice' );` to display an error message... My function is working well and is only getting called if I want, so that's not the problem... What I think is that the `add_action( 'admin_notices', 'my_admin_notice' );` that I call inside of my function is getting ignored! **Update Code for Context:**               function my_admin_notice() {         ?>

Error happend

         <?php     }          function checkEdit()  {              if( ($_POST['post_type'] == 'post') && ( $_POST['post_status'] == 'publish' ) &&          ( $_POST['original_post_status'] != 'publish' ) ) {              $title =  get_the_title();              $postId = (string) get_the_ID();              $postUrl = get_site_url() . "?p=" . $postId;         $wp_category_array = get_the_category();                    $categoryArray = array();         foreach ($wp_category_array as $wp_category => $value) {             $categoryArray[] = $value->cat_ID;         }              $postDate = get_the_date('Y-m-j H:i:s');         $subTitle = get_the_date();              $parse = new parseRestClient(array(             'appid' => 'XXXXXXXXXXXXXXXXXXXXXXX',             'restkey' => 'XXXXXXXXXXXXXXXXXXXX'         ));              $params = array(             'className' => 'News',             'object' => array(                 'Title' => $title,                 'SubTitle' => $subTitle,                 'array' => $categoryArray,                 'code' => $postId,                 'Date' => $postDate,                 'Url' => $postUrl             )         );              $request = $parse->create($params);              $responseArray = json_decode($request, true);              $objectId = $responseArray['objectId'];              if ($responseArray ['error'] == true) {             // Called if error (working)             add_action( 'admin_notices', 'my_admin_notice' );         }else {             $sql = "UPDATE wp_posts SET parseId = '$objectId' WHERE ID = '$postId'";              $result = mysql_query($sql);         }              }     }          add_action ( 'post_updated', 'checkEdit');


Can't get the_content of the parent page from its single post?

This is a page that list posts witht he category `Content (CDs)`:

             <?php // Run main loop (The Loop). ?>             <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
                 <?php the_content(); // <- I want to get this ?>
             <?php endwhile; ?>

                 <?php $custom_posts = new WP_Query(); ?>                 <?php $custom_posts->query('category_name=Content (CDs)'); ?>                 <?php while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?>

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

                 <?php endwhile; ?>      `single.php` has the following:                   <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
             <?php $parent = get_post($post->post_parent); ?>             <?php $parent->post_content; ?>
         <?php endwhile; ?>      But still can't get `the_content` of the parent page. Any suggestions?


Load search results into a div

Is there anyway to load the search results into a div in wordpress? I am currently searching a custom post type only and am searching from a small box that pops up in a fancybox. is there anyway to just have the search results load into that same box? iframe maybe?


Adding 'current_post_item' class to current post in the loop

I'm using a loop in the sidebar of my site to show all the posts that are in that category. Now I'd like to include a 'current_post' class to the current post that is being displayed to style that item in the list. I've tried looking for conditional tags or this custom wp_list_post_types function but both haven't worked. Does anybody know if there's a way to do this? EDIT: Adding Loop from comment below               <?php foreach((get_the_category()) as $category) {      $postcat= $category->cat_ID;      $catname =$category->cat_name; }      $args = array( 'cat' => $postcat );      $my_query = new WP_Query();      $my_query->query($args); // Equivalent of query_posts()          while($my_query->have_posts()) : $my_query->the_post();      $id=get_the_ID();        $currentClass= ($post->ID == $id) ? "current_post": ""; ?>     <a class="<?php echo   $currentClass; ?>" href="<?php the_permalink();?>">ni      <?php endwhile; ?>


How to enable users to down-vote in this simple voting counter (that uses the post meta)?

This simple tutorial teaches you how to make a voting counter using the post's meta data. I would like to know how to add down-votes to this small script (e.g. -1, -2). In the following way: If the post has 0 votes and it gets down-voted, it ends up with -1. If the post has 1 vote and it is down-voted it ends up with 0 (only one counter). **the jQuery part:**               <?php wp_enqueue_script( 'jquery' ) ?>     <?php wp_head(); ?>               > When a member clicks on the vote link, the above code will get the post ID > and the member’s user ID and send it to a file called vote.php using a post > method. The vote.php file will perform everything we need to add the vote. **vote.php:**               <?php     $file = dirname(__FILE__);     $file = substr($file, 0, stripos($file, "wp-content") );          require( $file . "/wp-load.php");          $currentvotes = get_post_meta($_POST['post'], 'votes', true);     $currentvotes = $currentvotes + 1;          $voters = get_post_meta($_POST['post'], 'thevoters', true);     if(!$voters) $voters = $_POST['user']; else $voters = $voters.",".$_POST['user'];          update_post_meta($_POST['post'], 'votes', $currentvotes);     update_post_meta($_POST['post'], 'thevoters', $voters);          echo $currentvotes;     ?>      > Once the information is posted to vote.php two custom fields are created. > One to count the vote and one to add the voter to a list so that they can’t > vote again. **functions.php:**               // voting function     function voting($id) {     global $user_ID;     $currentvotes = get_post_meta($id, 'votes', true);     $voters = get_post_meta($id, 'thevoters', true);     $voters = explode(",", $voters);     foreach($voters as $voter) {         if($voter == $user_ID) $alreadyVoted = true;     }          if(!$currentvotes) $currentvotes = 0;     echo '
'.$currentvotes.'';     if($user_ID && !$alreadyVoted) echo '
'.__("Vote").'';     if($user_ID && $alreadyVoted) echo '
'.__("Voted").'';     echo '
';     if(!$user_ID) echo '

'.__('Register').' '.__('to vote').'.

';     }      any suggestions?


Retrieving list of Custom Post Types

I'm using the following two strips of code to retrieve a list of categories (1st code) then displaying them in a select menu (2nd code), for my theme options page. I was wondering how I could change this code to do the same, but, retrieve custom post types instead?? _Code used to retrieve categories_               $tp_categories[0] = array(     'value' => 0,     'label' => ''     );     $tp_cats = get_categories(); $i = 1;     foreach( $tp_cats as $tp_cat ) :     $tp_categories[$tp_cat->cat_ID] = array(         'value' => $tp_cat->cat_ID,         'label' => $tp_cat->cat_name     );     $i++;     endforeach;      _Code used to display categories in a dropdown select menu_
Choose Category	          <select id="choose_cat" name="tp_options[choose_cat]">     <?php     foreach ( $tp_categories as $category ) :         $label = $category['label'];         $selected = '';         if ( $category['value'] == $settings['choose_cat'] )             $selected = 'selected="selected"';         echo '<option style="padding-right: 10px;" value="' . esc_attr( $category['value'] ) . '" ' . $selected . '>' . $label . '</option>';     endforeach;     ?>     </select>


Modify Post Status Arguments

Is it possible to edit existing registered post statuses? I am using the Edit Flow plugin to create custom statuses, however, the plugin does not offer the option to set whether the statuses are 'public' or not. I went in to the code and was able to insert that in, but obviously that will get overwritten with any updates. Essentially, I am looking for a complimentary function to add_post_type_support() for post statuses. So something like               add_action('init', 'my_custom_init');     function my_custom_init() {                add_post_status_support( 'custom_status', array('public'=>true) );          }


Advanced Custom Fields functionality without plugin

I am always looking to minimise my reliance on plugins. I currently use Advanced Custom Fields plugin for pretty much every site I build. I can't help but feel that the functionality this plugin brings should be (and probably is) something the WP supports, i.e. multiple WYSIWYG blocks per template/specific pages. Could anyone suggest a way of having multiple editable content sections (specifically WYSIWYG) on a page without using plugins? I am aware of the capability of adding meta boxes for single text fields, etc, but that's not what I am actually after.


How do I remove all traces of a plugin?

I am busy writing a plugin (called _supermail_ ), so I install, activate, deactivate, and delete the plugin fairly often. However, quite often one or more of these operations doesn't go smoothly, and I just manually delete the files. When I install the plugin again by uploading a zip file, called _supermail.zip_ , I find the plugin installed under a directory called _plugins/supermail1_. I assume this is because WP still has a record of the plugin, somewhere in the DB, or even maybe just in session. Short of restarting Apache, is there anything I can do, both in my plugin code to help ensure this doesn't happen, and as administrator, to result the issue when it does happen?


Adding schema itemprop image to the_post_thumbnail with filters

I have tried to apply filters to the_post_thumbnail() function using               apply_filters( 'post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr );      Here's the code I have come up with but doesn't seem to work completely                   function red_adjust_image_schema($html, $id, $caption, $title, $align, $url, $size, $alt)      {         $html = '
'. $html . '
';              return $html;     }     add_filter('post_thumbnail_html', 'red_adjust_image_schema', 20, 8);      How can I add itemprop="image" to the actual image element so it registers properly? Right now it seem like I can only do a container and wrap around $html? Thanks


Notify users whenever a new post is published based on their preference

I have put together a custom registration form on my WordPress site and one of the items on the registration form is an ability to select an interest. Essentially I have the following code from the registration form...                update_usermeta( $user_id, 'interests', $_POST['interests'] );      I would need a code that does something like, if "interestes" matches "tag" of a new post, then send an email to the user. Anything like that possible? Thank you in advance!


Set Wordpress settings programmatically

Is it possible to set certain settings from the theme functions file for example the setting `Enable threaded (nested) comments` ca I set it to allow `2` as the answer without having the user go into the admin panel and setting it for there wordpress comment settings?


How to access variables from Functions file in theme files

I just noticed, in a theme file, I can access custom functions I add to my functions file, however I can NOT access variables I set in my functions file. I have a few variables I set inside my functions.php file for example...               $feedburnerUsername = 'username';      Now in my sidebar.php file If I try to access this variable, it is not available, how can I make it available?


Adding Gallery to Footer of Homepage

I wanted to add gallery with Thickbox effect(Pop up), i achieved this easily on the posts page by using WordPress gallery and the lightbox plugin.But the theme is custom made there is a footer.php.I don't know how to add this gallery to the footer pro grammatically please help EDIT:Code on Posts Page               <a href="http://mysite.com/wp-content/uploads/2012/10/image.png">[gallery]


How to pass username into form that sends data to database

I am trying to pass username to database through form:               [insert_php]     $current_user= wp_get_current_user();     $id= $current_user->user_login;      [/insert_php]               <input type="hidden" name="id" value="[insert_php]$id[/insert_php]">      But it doesn't get through, the rest of visible inputs do go through though.


template_redirect not working, apparently for no reason

Well I made a plugin that uses `template_redirect` for the custom post type `squeezepages` and it works all fine and dandy, but I copied the exact same code, put it in a new plugin, activated it (with a few minor adjustments, for example I changed the custom post type to `newpages` and the `template_redirect` is taking the template from a different source) and suddenly it doesn't work? I can have both plugins active at the same time, the squeeze pages work, the new pages don't. It puzzles me so much. I even disabled the squeeze pages plugin and it still doesn't work. I've tried all combinations (there's only a couple) and still nothing. It seems like it's not working for NO reason. I've been staring at the same code for 2 hours and I'm not able to figure it out. Here's the code for my custom post types:               add_action( 'init', 'ifp_create_post_type' );     function ifp_create_post_type() {     register_post_type( 'newpages',         array(             'labels' => array(                 'name' => __( 'New Pages' ),                 'singular_name' => __( 'New Page' )             ),         'public' => true,         'menu_position' => 5,         'rewrite' => true,         'rewrite' => array('slug' => 'newpage', 'with_front' => FALSE),         'supports' => array('title', 'editor', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'thumbnail', 'author', 'page-attributes')         )     );     }      And my `template_redirect`:               function ifp_default_template() {         if(get_post_type() == 'newpages') : global $wp_query, $post, $posts;         include(PLUGINDIR . '/newpage/themes/default.php');         exit; endif;     }     add_action('template_redirect', 'ifp_default_template');


How to show content without excerpt?

Post contains: `excerpt`, `read more`, `content`. When browsing category page we see post's `excerpt` with `read more` link. When clicking `read more` we see post's `excerpt` + `content`. How to avoid showing excerpt (everything before read more link) on post's page?


Is there a plugin that let you edit Posts and Comments in a front-end page?

Basically, I need a plugin that let you edit posts and comments the same way you do in StackExchange sites (questions and replies)? Because by default Wordpress sends you to the back-end.


Infinite scroll / lazy loading with NextGen Gallery

I'm working on a project for a friend that involves a massive page with 3,000+ photos. See: http://www.thepurplepixie.com/projects/purple-pixies-people- project/ Currently, I have pagination set to 50 thumbnails per page in order to try and get the Infinite Scroll (Wordpress Plugin) (Infinite Scroll Homepage) to work, and to illustrate how I have the galleries set up in NextGen. Before, I had pagination off so it was one massive wall of photos, which, while accomplishing more or less what I was wanting, ultimately was brutal to load -- both in terms of memory and bandwidth. I can't seem to get the plugin version of Infinite Scroll to work, I'm guessing because it's more structured towards post content than big bunches of images. Also, I have multiple instances of the pagination system per page, due to multiple galleries per page. **Does anyone have any idea how I would go about lazy loading these images?** Thank you!


Can I apply a WP theme to a specific custom page template?

One section of my website is going to be completely different visually than the rest of the pages, is there a way to apply a WP Theme to specific page templates ?


Scripts external to WordPress cause 404 errors

I installed WordPress in the root of my web site. Everything went well. But now, other scripts and files, totally unrelated to WordPress, in other folders, cause WordPress 404 errors. For instance, I copied Docuwiki to a folder called example.com/docuwiki and when I try to run the install.php file from there, I get a 404 error. Is there any way to work around this, other than moving Wordpress to a different directory?


conditional (theme) language selection at 'runtime'

I have two issues to change the language for the theme at 'runtime'. I'm not sure about my question title, hope my description helps. I already use a plugin Polylang and there nice features: link pages with equal content but different languages AND configure primary menu for each language AND a language switcher which will be added into the primary menu. (I also tried xLanguage and xili-language, but they were not confortable for me) Polylang has very nice features, but I need some more:   * a guestbook, its a page which acts like a guestbook, no content only comments. I need the form, etc. (theme) in two languages, but is only one page   * I have second menu in the footer, there I also want to use different menu elements (names and links) for each language Is there a possibility to change the language by passing some HTTP GET params (and redirect) and then check the params and change/reload the page with needed language? I already tried to change the `wordpress_polylang` value in the cookie, but no effect. I found the reference for load_theme_textdomain but there is no parameter to pass an language. I use Starkers theme, based on twentyten. //edit: I found this snippet in the core.php of the polylang plugin, perhaps it would help.               // NOTE: I believe there are two ways for a plugin to force the WP language     // as done by xili_language and here: load text domains and reinitialize wp_locale      //    with the action 'wp'     // as done by qtranslate: define the locale with the action 'plugins_loaded', but     //     in this case, the language must be specified in the url.     function load_textdomains() {         // sets the current language         if (!($this->curlang = $this->get_current_language()))             return; // something went wrong              // set a cookie to remember the language. check headers have not been sent to avoid ugly error         if (!headers_sent())             setcookie('wordpress_polylang', $this->curlang->slug, time() + 31536000 /* 1 year */, COOKIEPATH, COOKIE_DOMAIN);              // set all our language filters and actions         $this->add_language_filters();              // our override_load_textdomain filter has done its job. let's remove it before calling load_textdomain         remove_filter('override_load_textdomain', array(&$this, 'mofile'));              // now we can load text domains with the right language         $new_locale = get_locale();         foreach ($this->list_textdomains as $textdomain)             load_textdomain( $textdomain['domain'], str_replace($this->default_locale, $new_locale, $textdomain['mo']));              // and finally load user defined strings (check first that base64_decode is not disabled)         if (function_exists('base64_decode')) {             global $l10n;             $mo = new MO();             $reader = new POMO_StringReader(base64_decode(get_option('polylang_mo'.$this->curlang->term_id)));             $mo->import_from_reader($reader);             $l10n['pll_string'] = &$mo;         }              // reinitializes wp_locale for weekdays and months, as well as for text direction         global $wp_locale;         $wp_locale->init();         $wp_locale->text_direction = get_metadata('term', $this->curlang->term_id, '_rtl', true) ? 'rtl' : 'ltr';     }


Text Widget Not Working

I have 2 widgets in the right sidebar. Both use HTML code to link a graphic to another page. The first one won't link for some reason and the second one does. If I swap the order, the same thing - the first one doesn't link and the second one does. Here is the site: http://eduardosmexicankitchen.com/ Thanks!


For Example,Now I have 3 Categories Like Food,Transport,Technology.Under These Categories I have Many Posts.Now I Want To Show the Latest Post From Each Category.{How to get Recent Post From Each Category with Thumbnail?}Is This is Possible? I Think No Plugin for This One.If You have a Great Knowledge in Plugin Creation, this is the Greatest Challenge for you.Just try to Found New Things and Become a Great Founder. My Question is Not Clear Means Ask Me or Edit ... Thanks All...


Multiple Post thumbnails (at least three)

How do I attain multiple post thumbnails, and have more that three thumbnails for each post.


Default admin color scheme as "blue"

I don't like the grey one and i'd rather not change each user. Thanks.


How to list posts from a plugin taxonomy?

I would like to query posts from a taxonomy created by a plugin (WP Business Directory Manager). How would I do this? I want the query to create html listing of the posts and allow me to list a certain amount, show the associated image to the posts, and a small excerpt. Some examples on wp stack exchange seem like they would help, but might be different in my case. Thanks a lot.


Filter WP_Query for posts having a certain meta-value

How to filter WP_Query for posts having a certain meta-value, without using a Custom Select Query? I have a custom posttype with meta-key: "open", and meta-value options: "yes" or "no". I would like to show posts only with meta_value = yes, for meta_key = "open".               function filter_where($where = '') {                  $open = "yes";              //$where .= " AND post_date > '" . date('Y-m-d', strtotime('-2 days')) . "'";         return $where;     }     add_filter('posts_where', 'filter_where');


query users by role

I have a custom plugin which queries users and usermeta, but I now need to filter admins out of the results. A very simplified version of my sql query is: ` SELECT * FROM usermeta LEFT JOIN users ON users.ID = user_id WHERE meta_key = 'last_name' AND user_role != 'admin' ORDER BY meta_value ASC LIMIT 0, 25 ` user_role is not a field, and i saw how it is stored as a config string, but i don't see how to make an equivalent query to this. am i missing something? thanks.


Adding post tags without capability edit_posts

I have a custom role called Event Contributor whose capabilities are limited to the post type "events". The role does _not_ have the capability "edit_posts". The post type "events" has custom categories, but uses the regular post tags. The problem is that users with the role Event Contributor are not allowed to add tags to an event, because they don't have the capability "edit_posts". Is there a workaround for this?


Modifying Wordpress XML-RPC Built-Ins

In short, I want to be able to modify the wp.getPost response to also return additional data, like the permalink. I thought it would be as easy as just calling the same function the xml-rpc code appears to call (`wp_getPost`):               add_filter( 'xmlrpc_methods', 'nc_xmlrpc_methods' );          function nc_xmlrpc_methods( $methods ) {         $methods['wp.getPost'] = 'my_getPost';         return $methods;     }          function nc_getPost( $args ) {         global $wp_xmlrpc_server;         $post_obj = $wp_xmlrpc_server->wp_getPost( $args );         $post = $post_obj->to_array();              $post['permalink'] = get_permalink( $post_obj->ID );              return $post;     }      Regarding the permalink, I know getPost returns a link already, but it's not helpful for drafts because I need to know the future link, not the current path. I saw this post and it suggests extending `wp_xmlrpc_server`. I'm entirely new to PHP so I'm not entirely sure why that's necessary unless I'm really building out an extension to the API. Am I missing something basic with my code?


How do I use this javascript correct with wordpress?

Im using a javascript/html5 script to highlight images black and white during no mouse hover, and then back to color on hover. It sorta works, although, I have to reload my page 2-3 times before it works correctly. I'm not sure how to use it, and javascript isn't really my strong suite. Since I'm using a Google CDN API, I guess I don´t need to enqueue it? At the moment i have the CDN link in my header.php This is the script:               <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>      < script>               $(document).ready(function(){                  $(".attachment-full").fadeIn(500);              // clone image         $('.attachment-full').each(function(){             var el = $(this);             el.css({"position":"absolute"}).wrap("<div class='img_wrapper' style='display: inline-block'>").clone().addClass('img_grayscale').css({"position":"absolute","z-index":"1","opacity":"0"}).insertBefore(el).queue(function(){                 var el = $(this);                  el.parent().css({"width":this.width,"height":this.height});                 el.dequeue();             });             this.src = grayscale(this.src);         });              // Fade image          $('.attachment-full').mouseover(function(){             $(this).parent().find('img:first').stop().animate({opacity:1}, 1000);         })         $('.img_grayscale').mouseout(function(){             $(this).stop().animate({opacity:0}, 1000);         });          });          // Grayscale w canvas method     function grayscale(src){         var canvas = document.createElement('canvas');         var ctx = canvas.getContext('2d');         var imgObj = new Image();         imgObj.src = src;         canvas.width = imgObj.width;         canvas.height = imgObj.height;          ctx.drawImage(imgObj, 0, 0);          var imgPixels = ctx.getImageData(0, 0, canvas.width, canvas.height);         for(var y = 0; y < imgPixels.height; y++){             for(var x = 0; x < imgPixels.width; x++){                 var i = (y * 4) * imgPixels.width + x * 4;                 var avg = (imgPixels.data[i] + imgPixels.data[i + 1] + imgPixels.data[i + 2]) / 3;                 imgPixels.data[i] = avg;                  imgPixels.data[i + 1] = avg;                  imgPixels.data[i + 2] = avg;             }         }         ctx.putImageData(imgPixels, 0, 0, 0, 0, imgPixels.width, imgPixels.height);         return canvas.toDataURL();     }


wp_insert_post memory consumption

I'm using **wp_insert_post** in a loop to insert 500 posts in a new WP install. It works quickly, and memory usage is from 25M to 28M. The next run of a second batch of 500 posts, takes the memory from 25M to 178M. So the memory usage seems to be based on how many posts are already in the table. A third run of 500 posts exhausts the available memory. What is being stored to increase the memory that I can cleanup?


Implement plugins as part of a theme

I have a couple of pluins which I use every time I create a new WP-page. Is there a way to implement these plugins as part of my theme? I have searched for a soloution for a couple of hours now, without any luck - hope someone can help :)


Separate categories parents, childs and grandchilds in dropdowns

I'm new to wordpress and PHP Im trying to build a site that the user can select a destination so I did this by creating categories (country) subcategories (state) sub sub category (city) and I want to split them into 3 dynamic drop down menus when you select country the state automatically populates according to the parents then the same with city, then it will do a search for destinations (posts) attached to the selections. So far I have one dropdown working but is listing all (parent, children, grandchildren) categories and doing the search correctly. how can I split them?               <?php $thecategories = array(             'show_option_all'    => '',             'show_option_none'   => '',             'orderby'            => 'ID',              'order'              => 'ASC',             'show_count'         => 0,             'hide_empty'         => 1,              'child_of'           => 0,             'exclude'            => '',             'echo'               => 1,             'selected'           => 0,             'hierarchical'       => 0,              'name'               => 'cat',             'id'                 => '',             'class'              => 'postform',             'depth'              => 0,             'tab_index'          => 0,             'taxonomy'           => 'category',             'hide_if_empty'      => false         ); ?>          <form action="<?php bloginfo('url'); ?>" method="get">       <?php wp_dropdown_categories( $thecategories ); ?>       <input type="submit" name="submit" value="view" />     </form>


Changing the Woocommerce breadcrumb menu

Currently I making changes to Woocommerce's breadcrumb menu. I’m trying to get it to look like this:

                             Home

 |

About us

      I have this in my functions.php:                           add_filter( 'woocommerce_breadcrumb_defaults', 'jk_woocommerce_breadcrumbs' );                 function jk_woocommerce_breadcrumbs() {                 return array(                 'delimiter' => ' | ',                 'wrap_before' => '

',                 'wrap_after' => '

',                 'before' => '',                 'after' => '',                 'home' => _x( 'Home', 'breadcrumb', 'woocommerce' ),                 );                 }      Which unfortunately gives me:

                         Home                         |                         buzsaws                         | Animal Train

      What can I add to the filter to make it fall inline with the breadcrumb nag that I have showing on the rest of my site? Thanks,


TinyMCE Add Media drag and drop

I am trying to use TinyMCE editor in custom page in wp admin "Settings" area. I am able to load it using wp_editor() with drag_drop_upload and media_buttons enabled. It loaded well. But the problem is when I click the "Add Media" button, it shows a popup screen but I can't drag and drop files to upload in it. This feature works well in PAGES and POSTS area. Is there any workaround to this?


aMember access blocked by wp admin

I've recently changed host and was required to move my aMember folder under http://example.org/wp-content/amember - whereas before it as in http://example.org/amember. Since then I cannot login as an admin to amember unless I am first logged into the WP panel. Regular amember users do not experience that issue. When I try to login to amember it doesn't yield an error and if I then login to WP and go and reload the amember login page again it shows me as logged in. So I think perhaps some rewrite/redirect thing going on. Since it doesn't happen to regular user I think it may be finding "admin" or something in the path and locking it but not sure where WP does that. I don't seem to have anything unusual in my base .htaccess not is there one in wp-content. Anyone have an idea what is going on?


Which WordPress scripts need to be executable for a fresh installation?

For security reasons I need to block access to scripts that will not be executed on a fresh WordPress installation. Example:   * /index.php --> needs to be executable   * /wp-includes/cache.php --> should not be executed (it's included in other files) Anyone has information on which files are **included** and which actually need to be **executable**? I want to build a list of valid files that can be executed via .htaccess, like this: * * * **Update:** This is the .htaccess file I have - my actual question: Is this configuration complete, or do I need to allow more files for a fresh WordPress installation to work properly?               <IfModule mod_rewrite.c>       # ONLY ALLOW THESE SCRIPTS TO EXECUTE:            # == Login, Signup, Activate       RewriteRule ^wp-login.php - [L]       RewriteRule ^wp-activate.php - [L]       RewriteRule ^wp-signup.php - [L]       # == All admin scripts and WYSIWYG editor       RewriteRule ^wp-admin/ - [L]       RewriteRule ^wp-includes/js/tinymce/wp-tinymce.php - [L]       # == WP Cron and mail       RewriteRule ^wp-cron.php - [L]       RewriteRule ^wp-mail.php - [L]       # == WP Comments form       RewriteRule ^wp-comments-post.php - [L]            # (...) <-- I need to know which other files need to be allowed                 # BLOCK ALL OTHER SCRIPTS       RewriteCond %{REQUEST_FILENAME} -f       RewriteRule \.(php.?|pl|cgi)$ - [F,L]     </IfModule>


How to disable plugin update notification for a specific plugin in Multisite

How it is possible to **disable plugin update check and notification** for an custom **specific plugin** in WP **Multisite**. I think it is also important, the plugin is usable as single activation in each blog of network and also as network wide active plugin. The check is different on an activation on single blog in the network of WP mu. Background: I write many plugins for customers and in all plugins I deactivate the the checkup and notification with the follow solution (its als othe same from this question no 20580). But this works only on an single install of WordPress, not on a Multisite install. The filter works only a blog inside the network. If you are inside the backend of network, than run the check again about all plugins, also the plugin which this source. Maybe other people have the same requirement or/and a solutions, thanks.               add_filter( 'site_transient_update_plugins', array( $this, 'remove_update_nag' ) );     /**      * Disable plugin update notifications      *       * @param  array string $value      * @since  1.2.3      * @link   http://dd32.id.au/2011/03/01/disable-plugin-update-notification-for-a-specific-plugin-in-wordpress-3-1/             * @retrun array string $value      */     public function remove_update_nag( $value ) {              if ( isset( $value ) && is_object( $value ) )             unset( $value->response[plugin_basename(__FILE__)] );              return $value;     }


Close access to the category, only for subcategories

I have menu with categories and subcategories. How to get access only to subcategories, not to categories? Tnx


Joining confirmation email

When a super admin adds a network user to a blog via wp-admin/user-new.php where does that confirmation email come from? How do I change? It says incorrectly comes from > Wordpress@example.com Thanks


What WordPress API function lists active/inactive plugins?

After seeing thousands of useful API functions in the WordPress core, I'm surprised to discover today that there ain't a function that would list the active plug-ins. I don't know you but I'm quite surprised at that. I was wondering if there is a reason for missing that? If so, I'd like to know about it. And, if there is a quick PHP snippet you know of that could give you a list of active plugins, ( the same way that a `get_post_types('','names');` does for CPT's or `get_taxonomies('','names');` does for CTs ), I'd appreciate it if you provide the code.


function wp() does not use meta_query?

I found that the $wp_query variable is populated by wp() function. I would like to filter my results using the WP_Query options. What I want to do is               wp(array("meta_key" => "key", "meta_value" => "value"));      Although when I run the following               var_dump($wp_query)      meta_key and meta_value show up empty. Any idea how I can get it to work.


get page title, url and excerpt of a page

I have the following setup: the front-page is setup as 'static' and it uses a theme page template. On this template / front-page, I need to get the page title, URL and excerpt of the About page. I found this code that does exactly what I need, but I'm wandering if there's a different approach to this, one that would not use the page ID but the page slug or title.               <?php         $page_id = 13;         $page_data = get_page( $page_id );         $the_excerpt = $page_data->post_excerpt;         $title = $page_data->post_title;     ?>     <a href="<?php echo get_permalink(13); ?>">         <?php echo $page_data->post_title; ?>           **Later edit:** Based on the answer provided by peteroak, this is the complete working code:               <?php         $page = get_page_by_title( 'About' );         $the_excerpt = $page->post_excerpt;         $page_data = get_page( $page );         $title = $page_data->post_title;     ?>
             <a href="<?php echo esc_url( get_permalink( get_page_by_title( 'About' ) ) ); ?>">                 <?php echo $page_data->post_title; ?>

<?php echo $page->post_excerpt; ?>             <a href="<?php echo esc_url( get_permalink( get_page_by_title( 'About' ) ) ); ?>">more +


How do i display the post type title?

Hi i was wondering if there is a way that i can display the custom post type title. For example: I have a custom post type entitled "Pretty Little Liars" and it also shows on the homepage, but how do i get the POST TYPE title, not the title of the post to show up like a category. For example: Plublished in: Pretty Little Liars is this possible? Also i want it to link to the post type page


How can I have a static title on my blog page?

My blog page is not my homepage. How can I add a title to the top of the page? i.e. "My Blog". Right now there is no title on the page. The title of the first post is at the top. (Sorry it's on my local machine or I'd provide a link and I'm too new to post an image.) Things I've tried:   * Creating a "blog" template page. It didn't work because the blog always uses index.php. (Thanks to Rev. Voodoo for the code that helps you see which template is used.)   * There is a similar question on stackexchange but it's not really answered and I don't understand it. Thank you!


Add Ajax to rating button

I have a ratings button in WordPress that outputs the number of people who rated the post. Is it possible to add the Ajax functionality so it doesn't refresh the whole page just the button number? http://pastie.org/3684431 Thank You in advance :)


How to write short code with if else to get page_id?

              <?php while ( $page_loop->have_posts() ) : $page_loop->the_post(); ?>

<?php the_title(); ?>

         <?php endwhile; ?>              <?php             $page_args = array( 'page_id' => 86 );             $page_loop = new WP_Query ( $page_args );         ?>
             <?php while ( $page_loop->have_posts() ) : $page_loop->the_post(); ?>

<?php the_title(); ?>

             <?php endwhile; ?>
              <?php             $page_args = array ( 'page_id' => 88 );             $page_loop = new WP_Query ( $page_args );         ?>
             <?php while ( $page_loop->have_posts() ) : $page_loop->the_post(); ?>

<?php the_title(); ?>

             <?php endwhile; ?>


Show different sidebar on taxonomy pages when a default is set

My theme holds below code in `sidebar.php`. I want to now make sure I can show a different sidebar when someone is viewing a custom taxonomy.               //Default sidebar     $selected_sidebar_replacement = 'Sidebar Widgets';          //If is page or single     if(is_singular()){     global $wp_query;     $post = $wp_query->get_queried_object();     $selected_sidebar_replacement = get_post_meta($post->ID, 'sbg_selected_sidebar_replacement', true);          //If default selected     if($selected_sidebar_replacement == '0' || $selected_sidebar_replacement == ''){     $selected_sidebar_replacement = 'Sidebar Widgets';                         }          // Reset the global $the_post     wp_reset_query();                          }      I've already tried the below (above `//If default selected`), where "product- brand" is the slug of the custom taxonomy and where "Gear" is an existing (and working on other pages) sidebar, but it didn't work. Any suggestions would be appreciated.               if(is_tax( 'product-brand' )){ $selected_sidebar_replacement = 'Gear'; }      Full `sidebar.php` code on pastebin: http://pastebin.com/CLD9DrUz


How can I add the "Use as featured image" to a custom metabox?

I am implementing a custom Meta box that allows the user to add images via a simple file input field (based around code on this site: Meta Box Script). This code allows multiple images to be added as attachments to the page and it does it without the full upload dialogue box, you just select the image file and publish the page and the image is uploaded. This works great, however, I would like to be able to add a link on each image so that you can set an image as a featured image. Here's an image showing what this looks like: ![Image thumbnails with links](http://i.stack.imgur.com/7XqUV.png) I snooped around the standard image uploader and can see that there is a JS file (/wp-admin/js/set-post-thumbnail.js) that is triggered as an AJAX call and this sets the image as a featured image. I'm using the following code (echo'd by PHP hence the escaping) to add the 'Use as featured image' link:                    ID}", "{$nonce}");return false;\">Use as featured image      I figured this much out with a bit of trial and error but it doesn't work as I get an error `Uncaught ReferenceError: setPostThumbnailL10n is not defined`, this is because I don't have JS loaded that provides the `setPostThumbnailL10n` and probably other problems too! Basically I'm trying to figure out if it's feasible to tap into this inbuilt functionality easily. My other option is to roll my own JS which saves an image as featured instead. I will also require being able to unset an images as featured too. Any ideas greatly welcome as this seems kind of uncharted territory as Googling this hasn't come up with anything!


How do I Show ALL posts for Catagories and Tags?

How can I get Wordpress to ignore "Blog pages show at most" when a user clicks on a "Catagory" or "Tag" link ? THANKS


How to add a new thumbnail size only to a certain custom post type?

I know how to add a new thumbnail size to my custom plugin. But i want to know if is possible to restrict de new size only to a certain custom post type? Thanks in advance.


Last article Widget with text preview and more button

I tried to use the last article widget from Wordpress and from my theme (deCanto last article). The first one only shows me a link with the heading, the last one shows me the complete article! But both cannot provide me the function I would like. The five last articles should be displayed on the start page. There should be a heading, date and an excerpt (e.g. first 200 words) from the article. Below there should be a "More" button with which the user comes to the full article. > **Heading** > > 28th March 2012 > > Lorem Ipsum Dolor Sit Amet .... > > More Which widget can provide me such functionality? In the plugin directory there are too much results ..


Is there a plugin that allows a user of your site to get an email from you with an attachment?

I was wondering if there was a plugin that could do the following:   1. user goes to page on wordpress site   2. user fills out their email address   3. Clicks Email Form button   4. user gets an email from my preconfigured email address via the plug with an attachment I have on my wordpress server somewhere, and some text explaining how to fill out the form or something.


Wordpress "Loop" with large set of results

I'm not sure the appropriate terminology but I have a wordpress "loop" for a custom post type that has roughly 300 results that all get displayed on a single page (no paging). The causes an enormous load on the DB server because for every "post" in the "loop" there are like N database calls (the_title, has_post_thumbnail, get_post_thumbnail_id, the_content, get_post_meta, etc..). What is the wordpress way of optimizing this? For something like this do most developers just drop to doing queries with $wpdb or is the wordpress way to cache the page and move on? I looked at doing straight $wpdb sql queries but grabbing the relevant data (especially images associated with the post) is less then intuitive.


Is it possible to pass a date from one Advance Custom Fields options page to another?

I have been trying for a week now to figure this out. I have a site that has numerous ACF options pages. On one options page (Trade Show Details) the start and end dates for a trade show are entered. On a second options page show attendees are entered along with their arrival date. Is it possible to pass the show start date from the first details options page to the date field in the attendee options page and auto populate it so if it needs to be adjusted it’s relative to the actual show date. Not today’s date. I’ve tried using acf/load_field, acf/load_value and acf/update_value with no success. My thinking was when a new repeater row is added for a new attendee the value of the date isn’t set, so if that’s empty set it to the date of the show, but if it’s an existing entry leave it as it was. Here’s the avenue I’ve been going down with no success. Is it even possible?               //set default date     function my_acf_load_start_date( $value, $field, $post_id ) {          if(get_field('btg_active_show_dates', 'option')):         while(has_sub_field('btg_active_show_dates', 'option')):         $defaut_show_start_date = get_sub_field('btg_show_opens');         $defaut_show_end_date = get_sub_field('brt_show_closes');          endwhile;          endif;          //echo $defaut_show_start_date;          if($value == '') {       $value = $defaut_show_start_date;     }           return $value;     }     add_filter('acf/update_value/key=field_526996739171c', 'my_acf_load_start_date', 10, 3);      Am I going down the right road? Is this possible?


How to flush rewrite rules on the activation of any plugin

I created a function in functions.php that adds some rewrite rules:               function add_rewrite_rules() {          add_rewrite_rule('events/page/([0-9])*/?', 'index.php?pagename=events&paged=$matches[1]', 'top');         [...]            global $wp_rewrite;         $wp_rewrite->flush_rules();     }      I would like to execute it every time _any_ plugin is activated, so if the new rules get overwritten I can restore them automatically. Is it possible? Thank you.


show author image in posts

I need to display author image along with posts. I used the following code to display posts with author image.               $the_query = new WP_Query("post_type=post&paged=".get_query_var('paged'));     while ( $the_query->have_posts() ) : $the_query->the_post();          <?php the_excerpt(); ?>
<?php the_author_image(); ?>
          <?php endwhile; ?>      But the author image didn't display. I couldn't track the error. How can i do this?


Paginate Custom Post Type Page

I created a page for my custom post types. The code can be viewed on Snippi: http://snippi.com/s/e8852rx I'm trying to insert paginate_links, but for whatever reason it's simply not showing up. Here is the paginate_links code (this code works on normal archive.php files):               <?php     global $wp_query;          $big = 999999999; // need an unlikely integer          echo paginate_links( array(         'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),         'format' => '?paged=%#%',         'current' => max( 1, get_query_var('paged') ),         'total' => $wp_query->max_num_pages     ) );     ?>


Different layout on second page

My homepage has 1 featured post, followed by 4 posts stacked 2 on 2, like this: ![enter image description here](http://i.stack.imgur.com/3XOkv.png) The featured post is only shown on the first page so the second page shows the older posts stacked 2 by 2 as above. However, I'd like to be able to change the layout on the second page, showing the posts in full width and length. Any way to do this? tl;dr = How can I make the second page look different from the first page?


Shift-Enter in tinyMCE (wp 3.3.1) not working

With wordpress version 3.3.1, shift-enter to insert linebreaks in pages and posts is not working anymore. Has anybody observed this as well? Is there a fix for that? Thanks!


Back to the basics: What's so great about a framework?

I'm brand new here and I'd like to start off by asking about WP frameworks. I've seen quite a bit out there, so I'm confused about what to choose for my site. So here are a few questions:   1. What is the advantage of a framework in the first place? Specifically, what are the advantages of installing frameworks such as Woo, Thesis, Genesis over designing something for a Wordpress base install directly?   2. Are there are any frameworks that are not recommended? I've seen a lot of Genesis bashing in other forums, but I don't understand why this is the case. So I'd like to know what you use and why. Thanks, Ray


plugin-list-category-post Instructions

A basic question from a very humble and intimidated newbie. The List-Category-Post plugin looks like it will let me do exactly what I want to do, which is what the Wordpress codex calls "A page of posts." I downloaded the plugin instead of changing any templates myself. As per instructions, I went to the admin menu and activated it. I even found the widget under the appearance menu. I know absolutely nothing about coding, so I want to avoid editing files on templates and instead "use the default [file] included in the plugin's code." How do I connect this to a page so that I can actually see the categorized posts appearing? I feel like there must be something very simple that I'm missing--a box to check or some custom menu to activate. I hope this is not too basic a question for this forum. I came here because the plugin download page said that Fernando had chosen this forum for support. Many thanks for your help!


Grab YouTube Thumbnail AFTER Post?

I'm using a feed to receive special YouTube feeds organized via playlists. Unfortunately, the URL is not included in the description field, but I can get the videos to display by including the source URL on post. This works fine except since the URL is not in the post area in the editor, the YouTube thumbnail grabbers I have tried don't retrieve these thumbnails. Does anyone know a way I can fetch the featured image through the published version of the post? It needs to be automated because I have way to many post items to adjust them manually.


Memory usage issue in WordPress 3.x

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate ... bytes) in wp-includes/pomo/streams.php on line ...        1. Plugins like Super-cashe & Total-cashe don't help.   2. Reducing the number of wordpress plugins and widgets used gives minimal effect. Can anyone offer solution (except asking my hoster for more memory) ?


Missing HTML comment tags

I've this WP installation that I'm currently modifying. And the craziest thing is that the HTML comments are not displayed anywhere in the source. That is if you right click on the page and "View Source". However if you are to open the page with a tool like this -> http://www.iwebtool.com/code_viewer?domain=w3lol.com you can clearly see that the comments are there. The website url is http://w3lol.com The sad part is that there is no info anywhere on the matter and as a bonus I've no idea on how to determine if this is caused by the code itself, the Apache, WordPress or whatever... (By the way, I've 5 other sites on this server, 4 of which are running WordPress and none of them has this problem. I'm also running an offline version of w3lol that does't show the problem either.) Have anyone had an error like this? And do you have any suggestions on how to fix it?


Should i use _n for pronouns in translation?

**I use _x() now! I accepted the answer just because he understood right and was first. So don't get confused!**               $like_me_on = __('Like me on %s', 'my-plugin');     $like_us_on = __('Like us on %s', 'my-plugin');          $follow_me_on = __('Follow me on %s', 'my-plugin');     $follow_us_on = __('Follow us on %s', 'my-plugin');          $my_x_profile = __('My %s profile', 'my-plugin');     $our_x_profile = __('Our %s profile', 'my-plugin');      I have this code and i read about _n() and saw only examples with $count on wordpress codex. The text is for a bunch of social services that will later be %s, if i would use _n then i would have this variables combined, but the translation string would be more complicated to read. So what is best practice and is this intended for pronouns or just for numbers?


Experiences with compiling WordPress using Hip Hop?

What are you experiences compiling Wordpress using Hip Hop? ( > https://github.com/facebook/hiphop-php/wiki/running-hiphop ) Specific:   * is this maintainable with upgrades?   * is the performance increase bigger than using alternatives? update: also interesting: http://www.phpclasses.org/blog/post/168-Can-NET- make-PHP-run-faster-than-the-official-PHP-implementation.html


Can Not Redirect from Plugin-Registered Admin Page

I am doing the following in my plugin:   1. Register a custom admin page and in the callback function (the last parameter of `add_submenu_page`)   2. Redirect to another page However, when I open the custom admin page I get the following error:               Warning: Cannot modify header information - headers already sent by (output started at ..\wp-admin\includes\template.php:1637) in ..\wp-includes\pluggable.php on line 878      Here's the callback function:               function myplugin_callback(){        wp_redirect('http://google.com');        exit;     }


What params are available with the_content filter?

I am looking for what params are passed to my filter function. Where can I find such info in the codex? http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content didn't provide much info I wanted to know if the post is a child of another


Execute a plugin only on post pages

I am building a plugin that is only useful and should only run on pages where posts are featured. Is there a way to only run the plugin on pages that display posts?


Missing argument for the function

do you know why i am missing argument 2 for this function?               add_action( 'admin_notices', 'notice_handler', 10, 2);          function notice_handler($error_token, $error_tag) {              ...         }     }      but when i activate the plugin wp says: `Warning: Missing argument 2 for notice_handler()....`


Where to get information about array fields in $_REQUEST?

I just started to learn PHP and doing things with WordPress and I am a bit confused about information in Codex. Was told that Codex got all info I required but I got stuck with it. **What array fields are in`$_REQUEST` in WordPress?** Can not find it in Codex. E.g.: people use `$my_contact = $_REQUEST['contact'];`   How do they know `$_REQUEST` has `'contact'` field? Is there any workflow to find informations about variables which are not described in Codex? Should I print off all the array to see what fields are inside? Google does not help me.. about $_REQUEST.


How can I get multisite primary blog (url or path) for current user?

In a multisite setup, when users are visiting a blog/site that there are not a member, I would like to display a link to "HOME" that takes them to their "primary" blog. I know how to determine if a user is or is not a member of a site with the is_current_blog_user() function. The part I am having a problem with is correctly setting the url/path of the "HOME" link to the current users "primary" blog. Hypothetical Example:               <a href="<?php this_is_the_path_to_users_primary_blog();?>">HOME      I have found the get_active_blog_for_user (http://codex.wordpress.org/Function_Reference/get_active_blog_for_user) function, and this seems to be a good place to start. But I feel as though I must be missing something, and this must be easier than I am making it.


Search results when none found - stay on page they were on

I currently have a sidebar with a search-form at the top. When the user types in a keyword, when submitted the user is took to a page with search results with posts relating to them words in each article. At the moment, when a keyword is not found, they are sent to a page which shows the title 'nothing found' and a message saying 'Sorry nothing found, Please try again'. What i would like is whatever page the user is on (Main page, Category page, single page and so forth) the user to stay on that page and just display at the top of the nav this title and information of 'no results found'. Is this possible at all in some way? I am not the expert when it comes to Wordpress so apologies if the answer is simple and i have not sussed it out! Thanks.               <?php get_header(); ?>     <?php if ( have_posts() ) : ?>     <?php get_template_part( 'nav', 'above' ); ?>
     <?php printf( __( 'Search Results for: %s', 'blankslate' ), '' . get_search_query()  . '' ); ?>
     <?php while ( have_posts() ) : the_post() ?>     <?php get_template_part( 'entry' ); ?>     <?php get_sidebar(); ?>     <?php endwhile; ?>          <?php else : ?>     <?php get_template_part( 'nav', 'above' ); ?>
     <?php _e( 'Nothing Found', 'blankslate' ) ?>

<?php _e( 'Sorry, nothing matched your search. Please try again.', 'blankslate' ); ?>
     <?php get_sidebar(); ?>     <?php get_template_part( 'nav', 'below' ); ?>     <?php get_footer(); ?>     <?php endif; ?>


Hide specific parent categories from post edit

I have many custom post types and they all take advantage of wordpress categories. I therefore have several parent categories for each custom post type. Is there a way to hide the other parent categories when editing a certain custom post type? In this screenshot for example I'd only like "Download Categories" to show while I'm in my custom post type "downloads". ![enter image description here](http://i.stack.imgur.com/SsNaI.png)


Create meta boxes that don't show in custom fields

I used the code below to create a metabox for posts. These meta boxes are also seen in the custom fields. I do not want these meta boxes to show in custom fields. Is there any way to not show meta boxes in custom fields?               $meta_boxes_video =      array(     "hotel name1" => array(     "name" => "hotel_name1",     "type" => "input",     "title" => "Hotel Name (Required)",     "description" => ""),     "price1" => array(     "name" => "price1",     "type" => "input",     "title" => "Price",     "description" => ""),     "hotel name2" => array(     "name" => "hotel_name2",     "type" => "input",     "title" => "Hotel Name (Required)",     "description" => ""),     "price2" => array(     "name" => "price2",     "type" => "input",     "title" => "Price",     "description" => ""),     "hotel name3" => array(     "name" => "hotel_name3",     "type" => "input",     "title" => "Hotel Name (Required)",     "description" => ""),     "price3" => array(     "name" => "price3",     "type" => "input",     "title" => "Price",     "description" => ""),     "hotel name4" => array(     "name" => "hotel_name4",     "type" => "input",     "title" => "Hotel Name (Required)",     "description" => ""),     "price4" => array(     "name" => "price4",     "type" => "input",     "title" => "Price",     "description" => ""),     "hotel name5" => array(     "name" => "hotel_name5",     "type" => "input",     "title" => "Hotel Name (Required)",     "description" => ""),     "price5" => array(     "name" => "price5",     "type" => "input",     "title" => "Price",     "description" => ""),     "hotel name6" => array(     "name" => "hotel_name6",     "type" => "input",     "title" => "Hotel Name (Required)",     "description" => ""),     "price6" => array(     "name" => "price6",     "type" => "input",     "title" => "Price",     "description" => ""),     "img_name1" => array(     "name" => "img_name1",     "type" => "input",     "title" => "Img1 (Required)",     "description" => ""),     "img_name2" => array(     "name" => "img_name2",     "type" => "input",     "title" => "img2 (Required)",     "description" => ""),     );               function display_video_meta_boxes() {     global $post, $meta_boxes_video;         foreach($meta_boxes_video as $meta_box) {                  echo'<input type="hidden" name="'.$meta_box['name'].'_noncename" id="'.$meta_box['name'].'_noncename" value="'.wp_create_nonce( plugin_basename(__FILE__) ).'" />';                  echo'
'.$meta_box['title'].'
';                  if( $meta_box['type'] == "input" ) {                       $meta_box_value = get_post_meta($post->ID, $meta_box['name'].'_value', true);                      if($meta_box_value == "")                     $meta_box_value = $meta_box['std'];                 $meta_box_value = str_replace("\"","'",$meta_box_value);                      echo'<input type="text" name="'.$meta_box['name'].'_value" value="'.$meta_box_value.'" size="55" />
';                  } elseif( $meta_box['type'] == "textarea" ) {                       $meta_box_value = get_post_meta($post->ID, $meta_box['name'].'_value', true);                      if($meta_box_value == "")                     $meta_box_value = $meta_box['std'];                 $meta_box_value = str_replace("\"","'",$meta_box_value);                      echo'<textarea name="'.$meta_box['name'].'_value" value="'.$meta_box_value.'" style="width:100%" cols="20" rows="1">'.$meta_box_value.'</textarea>
';                  } elseif( $meta_box['type'] == "button" ) {                       $meta_box_value = "Add New Source";                      if($meta_box_value == "")                     $meta_box_value = $meta_box['std'];                 $meta_box_value = str_replace("\"","'",$meta_box_value);                 echo '';                 echo '
';                 echo'<input type="button" name="'.$meta_box['name'].'" value="'.$meta_box_value.'" onclick="test();"  />

';                  }             elseif ( $meta_box['type'] == "select" ) {                      echo'<select name="'.$meta_box['name'].'_value">';                      foreach ($meta_box['options'] as $option) {                          echo'<option';                     if ( get_post_meta($post->ID, $meta_box['name'].'_value', true) == $option ) {                          echo ' selected="selected"';                      } elseif ( $option == $meta_box['std'] ) {                          echo ' selected="selected"';                      }                      echo'>'. $option .'</option>';                      }                      echo'</select>';                  } elseif ($meta_box['type'] == "info") {                           echo '
Add your property images using the "Upload/Insert" button above the content textbox..
';             }                  echo'
'.$meta_box['description'].'
';         }          }          function create_video_meta_box()      {         if (function_exists('add_meta_box'))          {             add_meta_box( 'ameta_boxes', 'Extra Information', 'display_video_meta_boxes', 'post', 'normal', 'high' );         }     }          function save_video_postdata( $post_id ) {         global $post, $meta_boxes_video;                if( get_post_type() == 'post' ) {         foreach($meta_boxes_video as $meta_box) {                    // Verify               if ( !wp_verify_nonce( $_POST[$meta_box['name'].'_noncename'], plugin_basename(__FILE__) )) {               return $post_id;               }                    if ( 'page' == $_POST['post_type'] ) {               if ( !current_user_can( 'edit_page', $post_id ))               return $post_id;               } else {               if ( !current_user_can( 'edit_post', $post_id ))               return $post_id;               }                    $data = stripslashes($_POST[$meta_box['name'].'_value']);                    if(get_post_meta($post_id, $meta_box['name'].'_value') == "")               add_post_meta($post_id, $meta_box['name'].'_value', $data, true);               elseif($data != get_post_meta($post_id, $meta_box['name'].'_value', true))               update_post_meta($post_id, $meta_box['name'].'_value', $data);               elseif($data == "")               delete_post_meta($post_id, $meta_box['name'].'_value', get_post_meta($post_id, $meta_box['name'].'_value', true));               }         }          }               add_action('admin_menu', 'create_video_meta_box');     add_action('save_post', 'save_video_postdata');


Native gallery sorting is ignored

On my website, I recently got a quite strange problem. I used to upload images via the nextGen Plugin. But since with this plugin google doesn't seem to index my pictures, I wanted to switch back to the native gallery. So, naturally, I started to recreate the galleries step by step. A week ago, this worked just fine. Today suddenly all the sorting settings are ignored. Sort by menu, sort by title etc. are not visible. I emptied my cache a few times, but the problem doens't seem to be cache related. Any help would be nice. The website in question is http://www.dreadfactory.de **Update:** Plugins that may effect the images are: "Lightbox 2", "NextGEN Gallery". The cache plugin used is "W3 Total Cache". If I deactivate all of them, the error persists. Apart from that, the only script I installed manually is "TJK_ToggleDL.js", to toggle list elements. The rest of my plugins should not effect the gallery: "Qtranslate", "Redirection", "Post Type order", "Wp-beautifier", "WP google+", "Ultimate Security Checker", "Google XML Sitemaps", "Exclude Pages from Navigation", "Contact Form 7", "Captcha", "Broken Link Checker", "Block Bad Queries", "Better WordPress Minify", "All in One SEO Pack **Update 2** The Shortcode is [gallery link="file" orderby="title"]


Want to exclude slider from page.php in header

I know this is a dumb question, but for the love of my life, I can't get the code to work. I have three page templates: home, page and another page-by category. I have a slider that I want to excluded from the default page.php file but to show everywhere else. I have tried to do this with `is_page_template` , but that isn't working. any help will be much appreciated. I'm not sure if you need my header code. If you do then leave a comment please and I'll paste in in pastebin. Thanks a lot in advance.


Adding wp_editor to custom metabox

I am adding fields to a custom post type. How can I have editing options in my meta data just as they are in the editor box?                add_action('add_meta_boxes', 'add_property');           function add_property(){      add_meta_box("description-meta", "Property Description", "desc_options", "property", "normal");      }              function desc_options(){         global $post;         $values = get_post_custom($post->ID);         $description = isset( $values['description'] ) ? esc_attr( $values['description'][0] ) : '';              wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );     ?>
         Description:
<textarea name="description" cols="100" rows="20"><?php echo $description; ?></textarea>


Get category ID from category slug (not working)

I found this code, which apparently gets the category ID from the category slug:                 $category = get_category_by_slug('category-name');        $id = $category->term_id;      But when I try to implement it into the following code, it doesn't work:               <?php     //list terms in a custom taxonomy using wp_list_categories           $category = get_category_by_slug( 'military' );          $args = array(       'taxonomy'     => 'product_cat',       'orderby'      => 'name',       'show_count'   => 0,       'pad_counts'   => 0,       'hierarchical' => 1,       'title_li'     => '',       'depth'        => 2,       'child_of'     => $category->term_id     );          ?>          <ul class="test">     <?php wp_list_categories( $args ); ?>     </ul>      I'm attempting to show only the child categories of a specific parent category. If I just type the category ID for "child_of" then it works perfectly. But using the above code, it continues to show all categories. Unfortunately I need to do it via slug, not via ID. Any ideas?


What is the recommended way to create plugin administration forms?

I have seen and been using the following technique for adding php scripts to my plugin for handling custom forms in a wordpress plugin. from the quizzin plugin:               $code_pages = array('quiz_form.php','quiz_action.php', 'question_form.php', 'question.php');             foreach($code_pages as $code_page) {                 $hookname = get_plugin_page_hookname("quizzin/$code_page", '' );                 $_registered_pages[$hookname] = true;      For example, the 'quiz_action.php' is later used as the target for an administration form (these forms are used only in wp-admin)                 <form name="post" action="<?php echo $GLOBALS['my_plugin_folder'] ?>/quiz_action.php" method="post" id="post">      **UPDATE:** This method is discussed here - Admin config screen without menu The final comment below by a Wordpress core dev seems to discourage this: http://wordpress.org/support/topic/how-can-i-execute-php-scripts-in-my-plugin- folder So what is best practice here? Should administration forms be posting to wp- admin/admin.php?action=foo or wp-admin/edit.php?action=bar. How does one register these actions? Is this documented anywhere? To be clear, these files should not be linked from an admin menu. I'm using Wordpress 3.0.4 Thanks!


TinyMCE: adding CSS to format dropdown

I successfully added a TinyMCE stylesheet using add_editor_style() so that I can preview the styles in the body of the TinyMCE editor. However, am I right in assuming that the add_editor_style() function can only access style for the body of the editor? If so, is there another method or function that I can use to access the styling of the TinyMCE Format dropdown as well? ![enter image description here](http://i.stack.imgur.com/1BfRL.png)


How can I have different groups of editors only allowed to edit certain parent+subpages?

I've tried a bunch of different plugins, including Role Scoper, Advanced Access Manager, User Account Manager and more, to accomplish this but can't seem to get it working right. Basically, the company has multiple departments and each department has a parent page + sub pages off the 'Main Page'. For example, the 'conference services' department has a page called 'conference services' and several child pages. I need to be able to create a group of users who are 'conference services editors' and when they go to pages they should only see the parent page 'conference services' and any subpages. (as well, they should only see posts under the category 'conference services') Is this possible with one install? Thanks, Thomas


orderby not working for query_posts using array of IDs

I have an array of IDs that i send to query_posts to get the posts (which works fine) but it seems to always put the attachment(562) last even though it is the newest. Also tried title and ASC vs DESC but its always last?               $slide_args = array(          'post_type'   => 'attachment',          'post_status' => 'inherit',         'fields'      => 'ids',         'tax_query' => array(             array(                 'taxonomy' => 'media_tag',                 'terms'    => 'new-work',                 'field'    => 'slug',             )         )     );          $slide_attachments = new WP_Query($slide_args);          $sticky_ids = get_option('sticky_posts');          $slideshow_posts = array_merge($slide_attachments->posts,$sticky_ids) ;          // creates Array ( [0] => 562 [1] => 479 [2] => 598 [3] => 686 )      // 562 is an attachment, the others are posts          $postsargs = array(                      'orderby'       => 'date',         'order'         => 'DESC',           'post_status'   => 'published',         'post_type'     => array( 'attachment', 'post' ),         'post__in'      => $slideshow_posts,     );          query_posts( $postsargs );      anyone know what might be going on? Best, Dc.


Changing date query from month

I have been perfecting this bit of code below and ran into an issue. I was wondering how I can change the following code so that it will so the anniversary of any user in the next 30 days, not just by month (i.e, an anniversary on Jan. 15 would appear on my list on Dec. 15, not just once it was January) Any suggestions (I'm running into such trouble because if I change the date sorting, I am not able to collect the correct user anniversary dates)                $args = array(           'meta_key' => 'anniversary_date',          'meta_value' => 0,        );        $user_query = new WP_User_Query( $args );        $users = $user_query->get_results();              foreach( $users as $user ):          echo $user->display_name;         echo ' will be celebrating their anniversary on ';           echo get_user_meta( $user->ID, 'anniversary_date', true );          endforeach;        * * *               function anniversary_user_query( $query ){              if( $query->query_vars['meta_key'] == 'anniversary_date' && $query->query_vars['meta_value'] === 0 ):               global $wpdb;                   $thismonth = date('m');                 $query->query_where = "WHERE 1=1 AND ( $wpdb->usermeta.meta_key = 'anniversary_date' AND ( MONTH( $wpdb->usermeta.meta_value ) = $thismonth ) )";          endif;         return $query;       }       add_action( 'pre_user_query', 'anniversary_user_query' );