Custom Metabox Not Saving

I've simplified a problem of saving custom metaboxes on update and still can't get the box to save the custom-field input to the database. This is the call from `functions.php` to an external file `/metaboxes/home- meta-new.php`:                   // Loading Home Page Meta Box Code from External .php file         add_action( 'add_meta_boxes_page','load_home_meta' );         function load_home_meta() {             $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];             if($post_id == '104'){                 include( get_template_directory() . '/metaboxes/home-meta-new.php' );             }         }      That part works as it shows the one meta box from the `home-meta-new.php` file. Unfortunately, once values are input for the custom-fields and the user clicks update, the post refreshes without saving the values. Here is the `home-meta- new.php` code:                   <?php              /**          * Home Page Custom Meta Content          *         **/          add_meta_box(           'home_meta_box', // $id           'Home Page Content', // $title            'show_home_meta_box', // $callback           'page', // $page           'normal', // $context           'high'); // $priority                     // Creating Array for Fields         $prefix = '_home_';         global $home_meta_fields;         $home_meta_fields = array(             array(                 'label' => 'Caption Title',                 'desc' => 'Upper section H2 caption title.',                 'id' => $prefix.'title',                 'type' => 'text'             ),             array(                 'label' => 'Caption Sub Title',                 'desc' => 'Upper section H3 caption title.',                 'id' => $prefix.'sub_title',                 'type' => 'text'             ),           array(                 'label'=> 'Caption',                 'desc'  => 'Caption text block.',                 'id'    => $prefix.'caption',                 'type'  => 'textarea'             ),             array(                   'label'  => 'Caption Image',                   'desc'  => 'Upload a pre-cropped 1140px wide x 530px tall web-optimized image.',                   'id'    => $prefix.'image',                   'type'  => 'image'               )         );// end home_meta array              //The Callback         function show_home_meta_box() {         global $home_meta_fields, $post;         // Using nonce for verification         echo '<input type="hidden" name="home_meta_box_nonce" value="'.wp_create_nonce('home_upper_nonce').'" />';         //wp_nonce_field( 'home_upper_nonce', 'home_upper_nonce' );                  //Begin field table and loop             echo '
';             foreach ($home_meta_fields as $field) {                 // get value of this field if it exists for this page                 $meta = get_post_meta($post->ID, $field['id'], true);                 // begin a table row with                 echo '
                                 '.$field['label'].'	                                 ';                                 switch($field['type']) {                                     // case items will go here                                     // text                                       case 'text':                                           echo '<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="30" />
'.$field['desc'].'';                                       break;                                     // textarea                                       case 'textarea':                                           echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'" cols="60" rows="4">'.$meta.'</textarea>
'.$field['desc'].'';                                       break;                                     case 'image':                                           $image = get_template_directory_uri().'/library/images/img-preview-blank.png';                                             echo ''.$image.'';                                           if ($meta) { $image = wp_get_attachment_image_src($meta, 'medium'); $image = $image[0]; }                                                          echo    '<input name="'.$field['id'].'" type="hidden" class="custom_upload_image" value="'.$meta.'" />
                                                          <input class="custom_upload_image_button button" type="button" value="Choose Image" />                                                           Remove Image
'.$field['desc'].'';                                       break;                                   } // end switch                 echo '
';             } // end foreach             echo '
'; // end table         }// end build metabox callback              // Save the Data         function save_home_meta($post_id) {               global $home_meta_fields;                    // verify nonce                   //option one              //if (!wp_verify_nonce($_POST['home_meta_box_nonce'], basename(__FILE__)))                    //return $post_id;                        //option two                 if (isset($_POST['home_meta_box_nonce'])){                     if ( !wp_verify_nonce( $_POST['home_meta_box_nonce'], 'home_upper_nonce' ) )                         return;                 }else{return;}                  // check autosave               if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)                   return $post_id;               // check permissions               if ('page' == $_POST['post_type']) {                   if (!current_user_can('edit_page', $post_id))                       return $post_id;                   } elseif (!current_user_can('edit_post', $post_id)) {                       return $post_id;               }                    // loop through fields and save the data               foreach ($home_meta_fields as $field) {                   $old = get_post_meta($post_id, $field['id'], true);                   $new = $_POST[$field['id']];                   //if ($new && $new != $old) {                           if ($new && ($new != $old)) {                     update_post_meta($post_id, $field['id'], $new);                   } elseif ('' == $new && $old) {                       delete_post_meta($post_id, $field['id'], $old);                   }               } // end foreach           }           add_action('save_post', 'save_home_meta');         // end save_home_meta              ?>      Anyone able to identify where it's choking on the save? Thanks!


Trying to alter the post_content through the_post

I already posted the same exact thing on stackoverflow without any comments or answer, i hope to get something going here: * * * I'm trying to change the post content of a page by hooking into "the_post" action, but the problem is that wathever i modify in there doesn't really get applied correctly. The problem seems to come from the fact that "query->setup_postdata" creates a $pages variable and sets the content into it before calling the "the_post" hoook. So whatever changes i do to the $post object doesn't reflect in the page. Further down the road, it seems that the "get_the_content" function which calls the "the_content" filter uses the content from $pages instead of the $post->post_content. Thus if i change the content of the post, it will not output it correctly because wordpress bases itself off something else to print out the content. Now if i hook unto "the_content" filter and replace the text using a simple hook mechanism such as:               public function wordpress_hooks_the_title($title){         if(get_the_ID() == 4){ return 'test title'; }         return $title;     }          public function wordpress_hooks_the_content($content){         if(get_the_ID() == 4){ return 'test content'; }         return $content;     }      It works fine for the content, but the title overrides many other titles in the page such as in the menu, even if i call "get_the_ID()" which is fine because the current $post is ok... So i'm stuck trying to find the right way and not a half and half way. I'd like to use "the_post" only or "the_content/the_title" only but only half of them work fine in each context. What would be the right approach? Thanks


WordPress.org how to force expire Cached Banner-772x250 from my Plugin page

I created and added a banner to my plugin page http://wordpress.org/extend/plugins/dbc-backup-2/ but there was a spelling mistake so I deleted & committed a new verison. After I added the new image back in the SVN - it's still showing the old one. So I know that the CDN has cached the image for a very long time. I checked via anonymouse.org just now and the correct banner is showing. **EDIT** It's been three days so far since I uploaded the image and for me I'm still seeing the same broken banner. I guess the CDN is serving out the old cached image to my IP :( So my questions ...   * is there a way for _developers_ to expire the old image? or force it from the cache?    * does anyone know how long these banner images are cached for?  and ...   * Let me know if you are not seeing this image as I've got an update ready but not going to change /trunk until the correct banner is showing for everyone. (![enter image description here](http://i.stack.imgur.com/dnrlS.png)


Featured Image Thumbnail Sizing

![http://i.stack.imgur.com/W2NI1.jpg](http://i.stack.imgur.com/W2NI1.jpg) The image on the left is what it is currently looking like. I used developer tools to change the width & height of all the image fields for the image on the right, however I would like some sort of cropping to get a similar effect without the scaling issues. My code is below.                <div class="thumb">                   <?php the_post_thumbnail(153, 115, true); ?>       </div>     .inner .thumb {          width: 153px;          height: 115px;          overflow: hidden;     }


blank white page in admin, white space hunting?

Upon logging into the dashboard, I am presented with a blank white page, tho the front end of the site works fine. I am pretty sure its due to a white space oposed to a plugin issue, but not sure where the white space could be hiding, I have checked wp-config and functions to no avail, any way to sniff them out? Thanks!


Custom Field values not Showing in Edit Page of  Custom Post Type

Custom Field values not are not showing in respective fields while i click the "edit" button .. they just show blank as we are creating a new post.I am able to save the values in custom field while editing too ... but still the saved values are not being shown in the fields(here the "id" text and the "membership" radio button) while "editing" the post, the id field shows blank and the radio button shows the default selected one Can somebody point out what i did wrong here?   Here is the code:               add_action( 'init', 'codex_custom_init' );     add_action( 'admin_menu','member_manager_add_meta' );     add_action( 'save_post', 'member_manager_save_extras' );     add_filter( "manage_edit-member_columns", "change_columns" );     add_action( "manage_member_posts_custom_column", "custom_columns", 10, 2 );          function codex_custom_init() {         $labels = array(             'name' => _x('Members', 'post type general name'),             'singular_name' => _x('Member', 'post type singular name'),             'add_new' => _x('Add New', 'Member'),             'add_new_item' => __('Add New Member'),             'edit_item' => __('Edit Member'),             'new_item' => __('New Member'),             'all_items' => __('All Members'),             'view_item' => __('View Member'),             'search_items' => __('Search Members'),             'not_found' =>  __('No members found'),             'not_found_in_trash' => __('No members found in Trash'),              'parent_item_colon' => '',             'menu_name' => __('Members')         );         $args = array(             'labels' => $labels,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,              'show_in_menu' => true,              'query_var' => true,             'rewrite' => true,             'capability_type' => 'post',             'has_archive' => true,              'hierarchical' => false,             'menu_position' => null,             'supports' => array( 'title')         );          register_post_type('Member',$args);     }               function member_manager_add_meta(){         add_meta_box("members-meta", "Member Details","member_manager_meta_options",'member','normal','high');     }               function member_manager_meta_options(){         global $post;              $values =get_post_custom($post->ID);         $id = isset( $values["isprp_id" ]) ? $values["isprp_id" ] : ' ';         $membership = isset( $values["isprp_member" ]) ? esc_attr(  $values["isprp_member" ]): '';              wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );         ?>

ISPRP ID<input type="text" name="isprp_id" id="isprp_id"  value ="<?php echo $id; ?>" />

Membership Category             <input type="radio" name="isprp_member"  value="Life Member" <?php selected($membership,'Life Member'); ?>checked />Life Member<input type="radio" name="isprp_member"  value="Associate Member" <?php selected($membership,'Associate Member'); ?> />Associate  Member
         <?php      }           // Save the Data               function member_manager_save_extras($post_id){         if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )              return;               else if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) )              return;               else if( !current_user_can( 'edit_post' ) )              return $post_id;               else{             update_post_meta($post_id, "isprpid",$_POST["isprp_id"]);             update_post_meta($post_id, "isprpmember",$_POST["isprp_member"]);         }     }               function change_columns($cols){         $cols =array(                    'cb' => '<input type="checkbox" />',             'title'=>('Name'),             'isprpid' => __('ID','trans'),             'isprpmember' =>__('Membership','trans')                 );              return $cols;     }          function custom_columns($column,$post_id){         switch ($column){         case 'isprpid':             $isprpid = get_post_meta( $post_id, 'isprpid', true);            echo '' . $isprpid. '';            break;         case 'isprpmember':             $isprpmember = get_post_meta( $post_id, 'isprpmember', true);            echo '' . $isprpmember. '';            break;         }     }


wp_enqueue_script before wp_head

If this works (and it's the way people do in a bunch of themes around the web):               <html>     <head>         <!-- stuff -->         <?php wp_enqueue_script('jquery'); ?>         <?php wp_head(); ?>     </head>     <!-- more stuff -->      Why is it recommended to use a hook to enqueue scripts?               add_action('wp_enqueue_scripts', 'my_enqueue_scripts');     function my_enqueue_scripts() {         wp_enqueue_script('jquery');     }


previous_post_link() next_post_link() arrow position

How can I make the arrow as part of the link please?               <?php next_post_link('%link →'); ?>      The output of above will be | `<a href="nextPostLink">NextPostTitle<a> arrow` |


Remove specific items from Quick Edit menu of a Custom Post Type?

I would like to remove some items from the quick edit screen on a custom post type. I would like to remove "slug", "date" and "password", as they will never not be used by end users. ![quick edit cpt](http://i.stack.imgur.com/XQUc5.png) I'm open to any suggestions!


What is appropriate flow for custom data from URL in WP_Query?

I have multiple stage process that integrates complex faceting into WP queries. Problem is - the deeper I get the more fuzzy I become on how it is _supposed_ to work and I could use a guideline rather than being inventive (and digging myself a hole). General stages I have (pseudo-code, but close to real):   1. retrieve value from URL (something simple like `person=1` )   2. process value and append custom query instructions ( `$relationship_query[] = array('relationship' => 'person_to_cat', 'object' => 1 );` )   3. retrieve final custom query instructions and generate appropriate SQL directives By now I have **a lot** of such going on (relationships, taxonomies, dates) and it's becoming fragile (one corner of code doesn't put value where other corner of code expects it to find and everything comes apart). So large question is - what is proper protocol to **pass, receive, store and process custom data to WP via URL**? Smaller parts:   * how to ensure I don't collide with WP internals?   * where and how I store intermediary data?      * difference between `query` and `query_vars` properties? They seem to be used almost same in code, yet they tend to hold different values and methods favor `query_vars` one.


Display posts starting from today date

How to display a list of posts from today date to future? I am actually using this code:
     <?php if (have_posts()) : ?>                     <?php query_posts('cat=4&showposts=6&orderby=date&order=DESC&post_status=future&post_status=published'); while (have_posts()) : the_post(); ?>
<?php the_time('j F, Y') ?>

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

                 <?php endwhile; ?>             <?php else : ?>        <?php endif; ?>      This is showing correctly all the posts and future posts for that category. An additional problem is: since I'm using "post_status=future&post_status=published" I have to trash the old posts to avoid them being displayed. Thanks for your help!


PHPStorm variable warnings

I code in PHPStorm and include wp-admin and wp-include in my path, but get code inspection warnings related to undefined / unused variables. Should I be concerned about these? How would I go about satisfying a resolution to resolve the error (without just turning inspection off) ![enter image description here](http://i.stack.imgur.com/pzxIZ.jpg)


Dynamically display font icons in widget

All, have a movie review site that I assign a score to. Currently I'm using a widget which works fine...but I changed all of my scores to a 5 star rating system (3.5/5, 5/5, etc.) so the widget that was using it based on percentages to fill the progress bar (a score of 70 would fill 70% of the bar and so forth) now only displays 3.5% of that bar. What I want to do is use the stars in font awesome, which I do have working on my site, instead. But I'm having trouble modifying the widget code to suit my new needs. I'm wondering if I need to make a case for each one or if there's an easier way? What I mean by "case" is by saying (and I'm saying this in English as opposed to code) "If the movie has a score of 1/5 then display one full star followed by four empty ones." And so forth. Or is there a way I can display the font awesome stars based on my dynamically-generated scores? My widget code is below if that helps:               <?php     global $wp_query;     $postid = $wp_query->post->ID;     if( get_post_meta($postid, 'RankVideo', true))  {     echo '

';     } elseif( get_post_meta($postid, 'ecpt_rankvideo', true)) {     echo '

';     }      ?>      So basically I'm looking for the necessary edits to the above widget code to get it to display the star font awesome icons based on a 5 star rating system as opposed to the base 100 system I had before. Make sense?


nested divs, classes for a grid in loop

php rookie here. as grids are popular right now, I wonder if this is even possible. I have three posts and have no idea how to get this working; this is my basic loop                                   // WP_Query arguments                         $args = array ( 'posts_per_page' => 3, 'category__in' => array(4,5)                         );                              // The Query                         $querytest = new WP_Query( $args );                              // The Loop                         if ( $querytest->have_posts() ) {                             while ( $querytest->have_posts() ) {                             $querytest->the_post();                                  // do something                             get_template_part( 'content', 'front', get_post_format());                                  }                              } else {                         // no posts found                         }      html output should be something like this:

      is there any chance this might work somehow?? I tried counting posts, but all I get was errors or totally wrong html output. thank you, A.


debugging register_activation_hook()

I'm curious if there is a known issue with WordPress or PHP where the environment may degrade to a point where WordPress simply ignores calls to register_activation_hook(). I was pulling my hair out for an hour on my local environment running MAMP when I had a coworker test the code on her machine; exact same code works on one machine but not the other. In this case I simply wanted to append messages to the log file which I'm tailing in real-time.               error_log("Plugin code is being processed");          register_activation_hook( __FILE__, 'myplugin_activate' );          function myplugin_activate()     {         error_log("Attempting to activate");         die("Should not activate");     }      The output on my machine running MAMP and clicking on the "Activate" link under my plugin:               [22-Sep-2011 22:37:16] Plugin code is being processed     [22-Sep-2011 22:37:16] Plugin code is being processed


How to add categories using mysql

I have an excel sheet with 423 categories consisting of US States > Military Bases. Is there a way I can reformat the excel sheet and import the categories into the wordpress database? I know how to use PHPMyAdmin but am unsure how to structure the SQL query.


Troubles about insering a POST with a SQL query, post_status

I 'm using wordpress 3.0.5 I have to use sql for create post, here is my SQL query:               $req = $bdd->prepare('INSERT INTO wp_posts (post_title,post_content,post_name,post_date,post_date_gmt,post_modified,post_modified_gmt,post_author,post_status,post_type)                           VALUES (:post_title, :content, :post_name, now(), now(), now(), now(), 1 ,\'publish\', :post_type)');      Everything is fine, my post is created as I want, BUT when I edit my post in admin, for exemple adding a new term, post_status is no more "Publish", but "Scheduled" an my only solution is to `('UPDATE wp_posts SET post_status = \'publish\' WHERE id = :id_post')` When I creat a post directly in admin, everything is fine even if I edit my post. I think I missed up the scheduled time ! Can you help me ? Thank you for your interest.


Website bookmarks as a custom post type

## Let me first explain what I am wanting to do... I am wanting to add all my hundreds of website bookmarks that I have now in my browser, into wordpress for the following reasons.   * Can search my bookmarks by category   * Can search my bookmarks by tags   * Can search my bookmarks by description and/or name   * Can access my bookmarks from anywhere   * Can add a description to all my bookmarks   * Can add a screenshot image if I choose to (least important idea)   * Will have a custom template for viewing the bookmarks which will look different from a regular blog post/list ## And what I have done so far...   * Created a new post type **"Website Bookmarks"** with the code below functions.php               <?php     /*     *  Add custom post type     *  name: website_bookmarks     */          function bookmark_post_type()     {         // Set some labels for our bookmarks post type         $bookmark_labels = array(             'name' => _x('Website Bookmark', 'post type general name'),             'singular_name' => _x('Websiteite Bookmark', 'post type singular name'),             'add_new' => _x('Add New', 'Websiteite Bookmark'),             'add_new_item' => __('Add New Website Bookmark'),             'edit_item' => __('Edit Website Bookmark'),             'new_item' => __('New Website Bookmark'),             'all_items' => __('All Website Bookmarks'),             'view_item' => __('View Website Bookmark'),             'search_items' => __('Search Website Bookmarks'),'not_found' => __('No website Bookmarks found'),             'not_found_in_trash' => __('No Website Bookmarks found in Trash'),             'parent_item_colon' => '',             'menu_name' => 'Website Bookmarks'             );              $bookmark_args = array(             'labels' => $bookmark_labels,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,             'show_in_menu' => true,             'query_var' => true,             'rewrite' => array(                 'slug' => 'bookmark',                 'with_front' => false),             'taxonomies' => array('post_tag', 'category'),             'capability_type' => 'post',             'has_archive' => true,             'hierarchical' => false,             'menu_position' => null,             'can_export' => true,             'supports' => array(                 'post-thumbnails',                 'thumbnail',                 'excerpt',                 'custom-fields',                 'editor',                 'title'             )         );              register_post_type('website_bookmarks', $bookmark_args);     }          add_action('init', 'bookmark_post_type');      * * * ## And then what I need help/ideas with... This gives me a custom post type, so I can add my bookmarks as a post, and search them and all that good stuff, also lets me easily keep them out of my main blog loop, so I can keep them more private if I choose to. Also let's me easily create a template page just for the bookmarks. ## Questions   1. I would really like to be able to tag my bookmarks, many bookmarks will have more then 1 tag, example a site about PHP and MySQL and javascript, would be tagged with all 3 of those terms/tags. I know wordpress has tags built in already and I utilize it a lot on my current blog posts, should I add a **NEW taxonomy** ie. **"bookmark_tags"** because when a user views a tag page right now, it shows all my blog posts for that tag and I do not want a PHP tag page to show all my post's tageed with PHP and all my bookmarks tagged with PHP on the same page, so is the best method to create a new taxonomy called bookmark_tags?   2. Same exact question as question number one (1), except in regards to **Categories** instead of **tags**?   3. Any other Ideas or suggestions to improve my bookmarks section? * * * ## Thank you for any help


Cannot unapprove a WordPress comment

My client approved a comment in WordPress that she shouldn't have. I cannot for the life of me find a way to get rid of the approved comment, and it appears that there really isn't a way. I can sort the approved comments, but nowhere is there a checkbox by a specific comment to delete, unaprove, edit, spam or access/modify the comment in any way. Does anyone have a workaround for this? As you can see by the screenshot, I can narrow down the list to just the one comment, but that is it. Checking the boxes and using the drop-down menu doesn't actually affect the comment. ![enter image description here](http://i.stack.imgur.com/i4Ylv.png)


Child pages don't become submenus (as in the twenty-ten theme)?

I'm using the theme Starkers which is based on twentyten. My twenty ten theme do place child pages below its parent page. But the new theme (based on Starkers) I'm developing doesn't (it just place it in the first level). My theme header.php:
             <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>

                     <?php if (get_option(THEME_PREFIX . "logo_image_enabled")) { ?>                          <a href="<?php bloginfo('url'); ?>" title="<?php bloginfo('name'); ?>"><img src="<?php bloginfo('template_directory'); ?>/images/<?php echo get_option(THEME_PREFIX . 'logo_image'); ?>" />                     <?php } else { ?>                         <a href="<?php bloginfo('url'); ?>"><?php echo get_option(THEME_PREFIX . "logo_text"); ?>                     <?php } ?>

      twentyten's:
               <?php /*  Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff */ ?>
<a href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentyten' ); ?>"><?php _e( 'Skip to content', 'twentyten' ); ?>
                 <?php /* Our navigation menu.  If one isn't filled out, wp_nav_menu falls back to wp_page_menu.  The menu assiged to the primary position is the one used.  If none is assigned, the menu with the lowest ID is used.  */ ?>                 <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>
      My theme's output:

Home

Blog

Home sub

      twenty-ten's:

Skip to content

Blog

Home

Home sub

      (Twenty-ten adds a unordered list with the class `.sub-menu`). (My functions.php was directly taken from twentyten's). Does anybody know which file and section makes the child pages sub-menus in the `wp_nav_menu` part of the header?


How to Prevent Wordpress to encode html in post?

As as title, how to prevent wp not to encode html in a post? currently i just need to prevent **' &'** changed to `&` The result need to be looks like on editor with html tab mode selected.               $content = $wpdb->get_row("SELECT post_content FROM $wpdb->posts WHERE ID=xxx");     $content = str_replace('amp;','',$content->post_content);//remove amp;          $wpdb->query("UPDATE $wpdb->posts SET post_content = $content WHERE ID = xxx;");      and also how to implement content filter(prevent to encode some text) in collaboration with `wp_insert_post()` function but that code still encode the html.


I need a SQL command to delete specific authors and all posts connected with them

I unfortunately have authors with a lot of unreadable/spam posts published (thousands some of them) I have tried deleting through admin,but its a slow painful process-does anyone have a specific SQL command i can use that can be edited for each authors name,and delete all posts associated with that author? Thanks in advance


Output loop to function return?

I'm working on a shortcode function that returns a category image, a link to the category, the last three posts in that category, and another link to the category. See my code below:                   add_shortcode('caticons_listing','bm_caticons_listing');         function bm_caticons_listing($atts) {             extract( shortcode_atts( array(                 'include' => '',                 'exclude' => '',                 'small' => 'true'             ), $atts ) );             if ($atts['include']) $include = "&include=".$atts['include'];             if ($atts['exclude']) $exclude = "&exclude=".$atts['exclude'];             if ($atts['small'] == 'false') $small = "&small=false";             $listing_code .= '
';             foreach(get_categories("orderby=name&order=ASC&hide_empty=0".$include.$exclude) as $category) {                 if (category_description($category->cat_ID)) { $desc = category_description($category->cat_ID); } else { $desc = "Coming soon!";}                 if ($category->count > 0) {                     $seemore = '
term_id ).'">See more.';}                      else {$seemore = '';}                query_posts('cat='.$category->term_id.'&showposts=3');                $listing_code .= '
'.get_cat_icon("echo=false".$small."&class=caticon&cat=".$category->cat_ID).'	term_id ).'">
'.$category->cat_name.'
'.category_description($category->cat_ID).'
';     //$listing_code .= "I think I need a loop here.";     $listing_code .= $seemore.'
';             }             $listing_code .= '
';             return $listing_code;         }      My issue is, with the way the WP loop examples are written, I can't figure out a good way to output the three latest posts as links in a manner that can be stored as a variable (to be returned as the shortcode output). Any help would be appreciated. Thanks!


Run second query on page based on author of the first query

I have my single-property.php showing custom post type 'property', within this page I want to also show the custom post type 'agent' that belongs to the author of property, each author only has one post of custom post type 'agent'. I imagine it needs to go something like this, single-property.php with the query to show custom post type 'property', get author from first query and run second query showing all posts of custom post type 'author' by the same author. Thanks


Nivo slider not working

I have added nivo slider plugin to wordpress however it doesn't move past the git loading file.I believe the problem is in the way i am loading the jquery. I have included the javascript jquery.nivo.slider.js file in the js folder inside my theme folder. In the header.php i am using this inside the head tags:                                   <?php wp_enqueue_script("jquery"); ?>             <?php wp_head(); ?>      And in the index.php i am using this:

      I am not using anything inside the functions.php file.And am using this inside the style.css:               @import url("bootstrap/css/nivo-slider.css");     @import url("bootstrap/css/slider.css");     @import url("bootstrap/css/bootstrap.css");     @import url("bootstrap/themes/default/default.css");      Could you please tell me where i go wrong due to which the git file is appearing and not the images slideshow. When used as index.html it worked as a charm.


Ajax in a settings page (update_option is undefined)

I'm making a request to my plugin's php file via ajax and it's supposed to save some data with update_option(), but php throws an error:               Call to undefined function update_option()      I'm guessing that when I call my php file with ajax WP doesn't load it's functions... or something? Cheers


Restrict user role Author from viewing comments in admin interface

I want to add an user as an Author to my blog, so that he can publish posts. But i don't want him to be able to view all the (unapproved) comments in the _admin interface_. Is there any code snippet / plugin that can do what i want ? I tried plugins like _Role Scoper_ and _Members_. Role Scoper is too complicated i don't even know where to start. Members can only edit the basic wordpress access for roles.


How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?

I added the following to my functions.php:               add_action('pre_get_posts', 'keyl_get_emp_posts');     function keyl_get_emp_posts($query) {         if ($query->is_main_query())             $query->set('post_type', 'employee');     }      and so far it's effectively filtering out the search results. The default widgets Recent Posts and Recent Comments aren't budging, though. What gives?


Text Disappearing from Blog Posts

On my Wordpress blog the text seemingly disappears at random times, try refreshing the page a few times and the text will all appear to be gone. You can highlight the text so it is still there however it seems to be somehow altered so it is always the exact same color as the background it is displayed on. This is causing problems for my users and I am looking for a quick solution. I would appreciate any help :) An example post on my blog (http://www.blurrygames.com/archives/650) EDIT: OK I FOUND WHAT THE PROBLEM WAS. IT WAS A MALFUNCTIONING PLUGIN. I SIMPLY WENT THROUGH MY PLUGINS ONE BY ONE AND FOUND IT. THE PLUGIN THAT CAUSED THE ISSUE WAS ADDTOANY SOCIAL BOOKMARKING. IT IS NOW TEMPORARILY DISABLED ON MY BLOG UNTIL THE DEVELOPER FIXES THIS PROBLEM. THANKS FOR THE HELP EVERYONE.


What is the relationship between cURL, WordPress and cacert.pem?

I've run into a problem concerning wp_remote_get() and the underlying cURL call. On some WordPress installations I see the following SSL error: **httprequest_failed: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GETSERVER_CERTIFICATE:certificate verify failed** From my research it looks as if the following should resolve my problem: curl_setopt ($handle , CURLOPT_CAINFO, dirname( **FILE** )."/cacert.pem"); I'm uncertain what I need to configure on my server so that this error doesn't occur. I found the above line of code set in a different plugin but I'm unsure of the reason why. Thoughts? Shepherd


get query's query string

By the time index.php runs, it seems as though there is already a query populated. How can I find out what that query's query string is? eg. `new WP_Query([query string is here])`


Convert hyphen to underscore in permalinks

I would like to use underscore in my permalinks instead of hyphen. Current permalink:               www.example.com/2013/01/hello-this-is-a-test-post/      Desired permalink               www.example.com/2013/01/hello_this_is_a_test_post/      I have tried some solutions mentioned here in stacexchange. But they were not working.


How do i change the search permanent links

I have 3 custom searches created using different templates. The search results page loads different results depending on the referrer:               <?     /* Template Name: Search Results */     $search_refer = $_GET["post_type"];          if ($search_refer == 'post') {          load_template(TEMPLATEPATH . '/search/filme.php');      }     elseif ($search_refer == 'persoane') {          load_template(TEMPLATEPATH . '/search/actori.php');      }     elseif ($search_refer == 'trailers') {          load_template(TEMPLATEPATH . '/search/trailers.php');      }     ?>      I'd like to make the url of this page prettier. Right now it looks like this:               /?s=After+Earth&post_type=post      but I'd like it to look like this:               /search/After+Earth/post_type/post      How do I make the url more beautiful?


Twenty Fourteen theme and the page-templates folder

I have to confess I'm struggling to see how the Wordpress Twenty Fourteen theme picks up templates put in the theme's `page-templates` folder. Previously I'd create new templates named `page-<slug>.php` in the theme's root folder, but not now. I've searched the code for mentions of `page-templates` and not found any where files are included; searched the WP source code too and found none. Can you explain how they're detected and picked up please?


resolve /author/ to a page or archive (of all authors) template

I know how to query the users and create a list of authors and can accomplish this in a page template, much like is described here: Authors Page : A page of authors my question is then.... is there a way so that i can have www.site.com/author resolve to the page where I am displaying a list of all authors? I just attempted to create a static page w/ an 'author' slug and it unsurprisingly 404s, I presume b/c WP is expecting something to follow 'author' and nothing is. Do I create an endpoint (rewrite stuff is still complex for me) or can I intercept the template_redirection and send it to my custom page? Any push in the right direction would be most appreciated.


wp_nav_menu show 1 item only

I was reading Wordpress documentation and also trying to find some clear example of how to do this but I couldn't, sorry if this is posted elsewhere but I did my best trying to find an answer before posting. My question is simple, if I use the wp_nav_menu function of wp, what should I do in the array or any other place to show one specific element and it's childs. So for example, I have a menu Home, About, Services. My question would be how to show only Services for example with it's childs. Is that even possible? Thanks in advance.


I Cannot Create New Category

For some reason I can't add new category. I changed the browser and even tried on my iPod Touch but it still did not do anything. It did not show any error message, No Nothing. It's like the new category wasn't even there. What should I do?


wordpress extremely slow on NAS

i did a fresh wordpress install on my NAS and on my local machine (notebook). on my notebook anything is running perfect (takes ~3 secs to load) but from my NAS it is really extremely slow :( (taking ~12 secs) it's the same setup and i couldn't find out the reason .. :( it seems like that the problem is the internal siteurl (the nas' ip-address) and that wordpress is using it for all paths .. any ideas? thanks


Subcategories with the same name

The wordpress codex says that a category and subcategory cannot have the same name, even if the subcategory has a different parent. I'm going to run into this exact situation and am trying to think of a solution. My categories will be US States > Military Bases > Neighborhoods. The problem is that neighborhoods from different bases may have the same name. Like a subdivision called "Stonebridge" near Shaw AFB and Travis AFB. Apparently this will not work in wordpress. Can anybody think of a way to structure my categories to get around this limitation? Thanks, Casey


How to remove the HOME menu item

I am using wordpress 3.4.1.   I am mainly creating a static site and for that have created and arrnaged the pages, and wordpress has nicely created the pages in proper nav-menu format for me, which is good.   But, it has also added a link to 'Home' in the nav-menu. How can i remove that? NOTE: I prefer any other answer than using the menu section and creating a new menu and assigning it as primary menu.


Using custom/dynamic "slug" for a page

I have a custom page which uses a template called "Stores" `http://example.com/stores/`. This page will have a list of states and/or companies as categories. For this system I have a custom post type "store" which can be assigned to a single category (either state or company), Each store is not a specific page, but contact information which is displayed in a sort of phone-book style layout for states/companies. The problem I have now is, how can I allow my "Stores" template accept URL requests from `http://example.com/stores/california/` (without throwing 404 error)? `California` in this sense is not a page, but a query. I also do not want to manually create a page for each of these categories (As it is pulled from database, and automatic). I could use `?state=california` for this purpose, but I would like to learn the proper way to allow this URL within wordpress. Is the correct way to edit htaccess file manually? Wouldn't that be overwritten if you edit the permalink structure? How would I format the htaccess?


get_the_tags with separator control?

I'm building a function in theme options to give the site owner more control over the post's "Tags" collection that I display at the bottom of each post page. Specifically, whether to add anchor text to them or not. However, since none of the available functions: the_tags(), get_the_tags(), etc will create an unanchored list with separators, I'm left to roll my own method (unless, as I'm hoping, I'm missing something) In the 1st part of the code branch below, once we determine the post has tags and the user has chosen to display them without links, I'm manually creating the tag list and adding a comma separator. How can I remove the separator from the last tag or from a single tag when that condition exists? (or better, is there a core method that will do it for me?)               function my_get_tags(){         $unlinkTags = get_option('my_unlinkTags');         $gotTags = get_the_tags();         if(!$gotTags) return;              //we got tags, lets create a wrapper         echo '
';              //no anchors and a separator? have to roll our own         if($unlinkTags)             {             foreach($gotTags as $tag) {echo $tag->name . ', ';}             }         //they want anchors, easy peasy, use get tags         else             {             echo the_tags('', ', ', '');             }         echo '
';     }


Integrate BuddyPress & Facebook

Any idea on what would be the easiest way to integrate BuddyPress with Facebook? I'm looking for a solution that would enable a BP custom profile that easily gets pre-filled with values from Facebook after the user does a "Connect with Facebook". Some way of mapping FB graph objects to BP profile. If it's not available I will probably start the work on creating one so if you have any ideas or tips then that would also be useful.


Check for file extension or mime type fails

I need to check if a uploaded file has `.csv` or `.txt` as extension and I'm doing as follow:               $uploadfiles = $_FILES['uploadfiles'];          echo '
';     var_dump($uploadfiles);     echo '
';          if (is_array($uploadfiles)) {         foreach ($uploadfiles['name'] as $key => $value) {             if ($uploadfiles['error'][$key] == 0) {                      $filetmp = $uploadfiles['tmp_name'][$key];                 $filename = $uploadfiles['name'][$key];                      $filetype = wp_check_filetype(basename($filename), null);                 $filetitle = preg_replace('/\.[^.]+$/', '', basename($filename));                 $filename = $filetitle . '.' . $filetype['ext'];                 $upload_dir = wp_upload_dir();                      if ($uploadfiles['type'] != "text/csv" || $uploadfiles['type'] != "text/plain") {                     echo "Error, the file $filename has not a valid extension: " . $filetype["ext"];                     continue;                 }                      echo "entre";die();                      $i = 0;                 while (file_exists($upload_dir['path'] . '/' . $filename)) {                     $filename = $filetitle . '_' . $i . '.' . $filetype['ext'];                     $i++;                 }                      $filedest = $upload_dir['path'] . '/' . $filename;                      if (!is_writeable($upload_dir['path'])) {                     $this->msg_e('Unable to write to directory %s. Is this directory writable by the server?');                     return;                 }                      if (!move_uploaded_file($filetmp, $filedest)) {                     $this->msg_e("Error, the file $filetmp could not moved to : $filedest ");                     continue;                 }             }         }     }      But I'm getting this error all the time: > Error, the file Aruba Airlines tickets-coupons (through 27-Apr-2014) - Aruba > Airlines tickets-coupons .csv has not a valid extension: csv I also test with this code:               if ($filetype['type'] != "text/csv" || $filetype['type'] != "text/plain") {         echo "Error, the file $filename has not a valid extension: " . $filetype["ext"];         continue;     }      And result is the same. If I do this:               echo '
';     var_dump($uploadfiles);     echo '
';      I get this as result:               array (size=5)       'name' =>          array (size=1)           0 => string 'Aruba Airlines tickets-coupons (through 27-Apr-2014) - Aruba Airlines tickets-coupons .csv' (length=90)       'type' =>          array (size=1)           0 => string 'text/csv' (length=8)       'tmp_name' =>          array (size=1)           0 => string '/tmp/php53tzhZ' (length=14)       'error' =>          array (size=1)           0 => int 0       'size' =>          array (size=1)           0 => int 14084526      So where is the error? **Checking for compared values types** So following the suggestion from a member here I did this:               echo '
';     print_r($uploadfiles);     echo '
';          // this is the only key since I'm uploading      // just one file for that I check in [0]          echo gettype($uploadfiles['type'][0]);           // output: string      Then:               echo gettype($filetype['type']);          // output: string      Then:               if ($filetype['type'] != $fileCSV || $filetype['type'] != $fileText) {         echo "Error, the file $filename has not a valid extension: " . $filetype["ext"];         continue;     }      Still getting the same error, this is driving me crazy!


Find and replace domain name on the fly?

Please read this carefully as it is not what you might be expecting. I'm building my site in a development sub domain. I don't want to have to go through the complications of running find and replace plugins after moving the site to the live area (as this can often go wrong on some serialized data). I want to enter the urls into pages as they're going to be on the live site (they need to be absolute URLs for the RSS feeds. So I need a method with PHP or Javascript to find and replace http://mysite.com with http://dev.mysite.com on the output pages. This way I can still test and preview the site and when it comes to going live I just have to uncomment that code. I'm not worried about the URL in the settings as that is always easy to change. I hope that makes sense. Thanks.


store custom WP table names in a global variable

I was being creative and put this in one of the files loaded with my plugin. Are there implications with storing the table names this way?               global $wpdb;          if(!defined('DB_ARTISTS'))         define('DB_ARTISTS', $wpdb->prefix . "artists");          if(!defined('DB_RELEASES'))         define('DB_RELEASES', $wpdb->prefix . "releases");      EDIT: I had originally not included all of the information I had meant to. Tables and variables are prefixed with ABC ( `ABC_DB_ARTISTS` & `$wpdb->prefix . 'abc_artists'` ).


Royalty-Free Sliders used in theme development

I am wanting to develop a premium Wordpress theme, and would like to know what is the best way to go on choosing a slider. I'm not skilled enough yet to write one from scratch. The ideal situation for me would be to use a Royalty-free slider (slides.js?) and then create different designs from that single slider. Is that okay? Any help would be appreciated. Thanks!


User description only displayed for logged user

In my "About" page I list all WP users of the site. Then in author.php I display the description of the selected user with this code: `<?php the_author_meta( 'description' );?>`. Problem: this code only display user description if this user is logged, otherwise it displays nothing. Why? Code of the "About" page:               <ul>         <?php         $blogusers = get_users('orderby=nicename&who=authors');         foreach ($blogusers as $user) {             $user_info = get_userdata( $user->ID );             ?>             <li>                 <a href="<?php echo get_author_posts_url($user_info->ID); ?>">                     <?php echo $user_info->nickname; ?>                 </a>             </li>             <?php         }         ?>     </ul>


get_the_post_thumbnail() - Invalid argument supplied for foreach() in /wp-includes/post-thumbnail-template.php on line 64

The past couple of hours I am trying to find out what is the problem with this...               <?php $related_posts = get_field('related_posts'); ?>     <?php if ($related_posts) : ?>

<?php _e('Related Articles', wpgrade::textdomain()); ?>

             <?php             foreach ($related_posts as $post_object) {                 $the_post_ID = $post_object->ID;                 $the_permalink = get_permalink( $post_object->ID );                 $the_title = get_the_title( $post_object->ID );                 $the_thumbnail = get_the_post_thumbnail( $post_object->ID, array(200,150) );                 $the_post_author = $post_object->post_author;                 ?>

                         <a href="<?php echo $the_permalink; ?>">
                                 <?php if (has_post_thumbnail( $the_post_ID )) echo $the_thumbnail; ?>

                                     <?php echo $the_title; ?>
                                                                      <?php $author_url = get_author_posts_url( $the_post_author ); ?>                                     <?php $author_name = get_the_author_meta( 'display_name', $the_post_author ); ?>                                     <?php echo $author_name; ?> - <?php echo get_post_time('d.m.Y', false, $the_post_ID, false); ?>                                                                  <?php _e('Read More', wpgrade::textdomain()); ?>+

             <?php } ?>

     <?php endif; ?>      I get this...               Warning: Invalid argument supplied for foreach() in /wp-includes/post-thumbnail-template.php on line 64      The problem is this line...               $the_thumbnail = get_the_post_thumbnail( $post_object->ID, array(200,150) );      I can't understand why! Can someone please help? I am using **WordPress v.3.9.1**


Why is the Walker_Nav_Menu self closing tags added in start_lvl

I'm creating a custom Walker based on Walker_Nav_Menu for a megamenu I'm working on and the issue I'm having is that it seems the tags I open on `start_lvl` are being automatically closed. Here's my code:               public function start_lvl( &$output, $depth = 0, $args = array() ) {         $indent = str_repeat( "\t", $depth );         $output .= "\n$indent
\n";                      // Add specific tags only on first submenu         if (0 == $depth) {                  $output .= "\n$indent
\n";             $output .= "\n$indent
\n";              }     }      And on my `end_lvl` I've got this:               public function end_lvl( &$output, $depth = 0, $args = array() ) {              $indent = str_repeat("\t", $depth);         $output .= "$indent
\n";              if (0 == $depth) {                  $output .= "$indent
\n";             $output .= "$indent
\n";              }     }      However with or without `end_lvl` I get this output:

Menu item 1

Menu item 2
 // These items should be inside the above div     ...      I'm new to Walker but I thought that whatever I add to `start_lvl` would wrap the `<li>` tags. What am I missing? PS: I have tried without the conditional `if (0 == $depth)` and the difference was only the above code was in every level rather than just on the first.


Keep Pagination in Tabs

Is there a way to have pagination on multiple tabs? I have a page the has 5 tabs, each tab has filtered content from the same posts. For example: Tab 1 - All Posts. Tab 2 - Posts with Keyword One. Tab 3 - Posts with Keyword Two. etc... My problem is that I can't figure out how to use pagination on each tab and have the user be able to select the page on that tab and stay on that tab - it wants to go back to the first tab.


Plugin: How to make links in admin page open up inside of the admin panel

In writing my plugin, I have added my menus and submenus to the admin page. The pages load and function as intended. What I am trying to do is create some links inside of these pages that will pass a parameter to a new page. I am close to accomplishing this but _the page always opens up outside of the admin screen_. I am quite new at this and completely stuck. Here is a screenshot. ![How can I get a link from an admin page to open inside of the admin panel?](http://i.stack.imgur.com/AV70l.jpg) Here is the function I am calling to get the post data which will pass the id to the page that handles the database edit.               add_action( 'admin_post_add_recid', 'prefix_admin_add_recid' );     function prefix_admin_add_recid() {                 include( plugin_dir_path( __FILE__ ) . '/management_tools/edit.php' );     }      and the link that calls it, where 1 is the id that i need to pass to the edit page.               href="admin-post.php?action=add_recid&data=1"      Here is background on what/why I am doing this if you want to be bored. I am migrating content from a non-wordpress site. The only thing wordpress can't accommodate right out of the box is some old php database stuff that has been around for awhile. I want to put this database code into a plugin so that it can be managed within wordpress, backed up and migrated if that need ever arises. It is a specific use plugin that is not going to be distributed. The existing code hasn't been modified since it was created and probably won't need modified again once it is in wordpress. All of the database read and insert code is working inside of the plugin. Basically I am really close to completing the task without having to rewrite it from scratch which I don't have the budget to do. I just can't find a way to open the edit/delete admin pages inside of the admin panel. Thanks for reading and for any help you can offer.


What does the class look like that is returned from WP_User_Query?

$wp_user_search = new WP_User_Query( array( 'role' => 'author' ) );     $author_list = $wp_user_search->get_results();          foreach($author_list as $author)     {       // author properties?     }      Can you point me in the direction of the documentation of what properties `$author` has?


Fields in User Profile Page

I have a question and would like help from friends. I want to add two fields on the page of users registered on my blog. I added some pictures to brighten my explanation.   1. When we register a user manually, following User> Add User, I would add this field: ![enter image description here](http://i.stack.imgur.com/OE6TU.png)   2. When a user is already registered and following User> Users> (select the user and click edit), I would add this field: ![enter image description here](http://i.stack.imgur.com/6owJZ.jpg) I saw several blogs / forum that show how to add input on the contact and how to create a new block, but found nothing that could be the way I like. thanks


Prettified page URL w/ query var redirects to prettified page URL w/o query var

I have a page created (page ID `235`) with a page template that will need to be passed a variable. I would like to pass this variable through the URL. My first attempt was to pass this with a GET variable, and that worked just fine.               URL: http://example.com/sok/events/?kategori=variablehere      Now, I thought I'd spice this up a bit and prettify it. This is what I am aiming to achieve:               URL: http://example.com/sok/events/variablehere      The code I have been using in my attempt looks like the following:               function setup_filter_rewrites()     {         add_rewrite_tag('%kategori%','([^&]+)');         add_rewrite_rule('^sok/events/([^/]*)/?', 'index.php?p=235&kategori;=$matches[1]', 'top');     }     add_action( 'init', 'setup_filter_rewrites' ); Now, when accessing the URL above, I am redirected to `http://example.com/sok/events/` - i.e. the URL but without the query variable. Obviously, as you may guess, the query variable is not accessible inside the page. I heard of the `redirect_canonical` function potentially causing problems with rewrite rules, so I disabled it. After having done so, accessing the above URL instead yields a 404.php request. As you can see, I've really tried to cut back on the code to make it as simple as possible as well as using the correct API functions. I have checked the rule with A tool to analyze rewrite rules? and it reports the variable as being public and accessible. I tried cutting the page down to a simple `echo $wp_query->query_vars['kategori']` but that did not output anything nor did it prevent the redirection. I suspect the redirection is the problem here - if I could stop it, I'm confident I'd be able to grab the query variable. This problem is similar to URL Rewrite + Page + Custom Post Type = Unusual Redirect and Querystring parameter getting lost in rewrite rule insofar that it is also a redirection error. However, in my case, I am not dealing with custom post types of any kind.


Custom post type child of custom post type

I am trying to make a custom post type as child of another CPT. or Add a taxonomy for ID of parent post (then how to make it required). **Why I am doin this ?** Actually I have two custom post type `user_projects` and `user_child_projects`, both are post not page. `user_child_projects` are child of `user_projects`, `user_child_projects` must have a valid `user_projects` ID. Please help me, I am trying to do this from past five days


Is there a way to change the backround color of the native video player in wordpress?

I love the ease of adding a video to WordPress 3.9.1, however The background that shows befor the video fully loadsw is black and I would like it white. what is the name of the video player and where would I alter the styling to do this please, many thanks Mark


WP_Query and name__in

Is it possible to have something like `name__in` array() for WP_Query? I am trying to get a list of (custom) posts from an array of the post's slugs. Looking at http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters there doesn't seem to be a way...


Make the customiser show all Background Image settings all of the time

How can I make it so that in the Background Image section of the customiser, all options are always shown, regardless of whether or not a background image is selected? The options I mean are Background Scroll, Background Attachment and Background Position. The reason for this is that I have added an option that allows for the site to pick a random background image (providing at least one has been uploaded), and so because of that all options should always be shown so that they can be changed/previewed even if a background image is not set. Thanks.


Custom PT, Taxonomys and wordpress query

Ok so I have an issue with wordpress that has been driving me mad the last few days. I have a custom post type called "help-line" this post type then has 13 categories and some of these categories have sub categories. I also have 5 custom fields. When I create a post under help-line I assign it to whichever category it relates to (which can be multiple) This is where I'm getting seriously confused. I have a page called "page-help" which is using               <?php wp_list_categories('depth=1&title_li='); ?>      to display the top level categories. When you click on one of the categories I'm assuming it is loading category.php which has the following code to display the children of the parent category that I have just clicked on.                                           <?php                                       $categories = get_categories('hide_empty=0');                                       foreach ($categories as $category) :                                          query_posts('post_type=help-line&showposts=2&cat='.$category->cat_ID);                                          while(have_posts()){                                             the_post();                                              ?>

<?php the_field('helpline_name'); ?>

<?php the_field('helpline_address'); ?>

<?php the_field('helpline_phone_number'); ?>

<a href="" class="tiptip web" title="<?php the_field('helpline_name'); ?>" target="_blank"><?php the_field('helpline_name'); ?>

<?php the_field('helpline_comments'); ?>

<a href="mailto:<?php the_field('helpline_email'); ?>" class="tiptip email" title="email us your problem"><?php the_field('helpline_email'); ?>

                                      <?php     }                                 endforeach; ?>       But no matter what parent category I click on it just keeps showing the same posts. The entire thing needs to be completely dynamic show that when I add a new category it will display automatically. Can someone please help me, I would be so greatful!!! :( Thanks in advance.


Facebook OAuth, WP_Http::request() vs wp_remote_request()

Running WordPress 3.3.2 and PHP Version 5.2.17 I'm trying to get the access_token from Facebook using wp_remote_request() and Facebook OAuth API (btw, working example at the end of this entry). Is there any reason why this doesn't work (should according to doc and source code)?:               $response = wp_remote_request('https://graph.facebook.com/oauth/access_token', array(                        'timeout' => 60,             'sslverify' => false,             'method' => 'GET',             'body' =>  array(                      'client_id' => FACEBOOK_APPID,                      'client_secret' => FACEBOOK_APPSECRET,                     'redirect_uri' => REDIRECTURI,                     'code' => $_GET['code']             )     ));      When this does?:               $http = new WP_Http;          $api_url = sprintf("https://graph.facebook.com/oauth/access_token?client_id=%s&redirect_uri=%s&client_secret=%s&code=%s",         urlencode(FACEBOOK_APPID),         urlencode(REDIRECTURI),         urlencode(FACEBOOK_APPSECRET),         urlencode($_GET['code'])     );     $response = $http->request($api_url, array('timeout' => 60, 'sslverify' => false));      Working example:               <?php     /* Short and sweet */     define('WP_USE_THEMES', false);     require('../wp-blog-header.php');     ?>     <?php     define('FACEBOOK_APPID','123'); // replace 123 with your app id     define('FACEBOOK_APPSECRET','abc'); // replace abc with your app secret          define('REDIRECTURI','http://your.redirect.url');          if ($_GET['code'] != '') {         if ($_GET['state'] != '' && wp_verify_nonce($_GET['state'], 'my-nonce')) {                   $http = new WP_Http;                  $api_url = sprintf("https://graph.facebook.com/oauth/access_token?client_id=%s&redirect_uri=%s&client_secret=%s&code=%s",                 urlencode(FACEBOOK_APPID),                 urlencode(REDIRECTURI),                 urlencode(FACEBOOK_APPSECRET),                 urlencode($_GET['code'])             );             $response = $http->request($api_url, array('timeout' => 60, 'sslverify' => false));                  if( is_wp_error( $response ) ) {                echo 'ERROR';             } else {                 $args = wp_parse_args( wp_remote_retrieve_body($response), array() );                 echo $args['access_token'];              }         }        } else {          $facebook_dialog_url = sprintf("https://www.facebook.com/dialog/oauth?client_id=%s&redirect_uri=%s&state=%s",              FACEBOOK_APPID,              urlencode(REDIRECTURI),             wp_create_nonce ('my-nonce')          );                    echo 'LOGIN TO FACEBOOK
';     }     ?>


Deactivate plugin for a specific user group

I would like to deactivate a plugin for a specific user. I'm using the following code inside a the `wp-content/plugin-mu` plugin file:               add_filter( 'option_active_plugins', 'bo_disable_apm_plugin' );                   function bo_disable_apm_plugin( $plugins ) {              global $current_user;              // Not use advanced page manager for media manager         if ( is_admin() && in_array( 'media_manager', $current_user->roles ) ) {           $key = array_search( 'advanced-page-manager/advanced_page_manager.php' , $plugins );           if ( false !== $key ) {             unset( $plugins[$key] );           }         }         return $plugins;     }      Of course, it's not working. I don't understand the way `option_active_plugins`. By dumping data, I find out the code is executed 7 times. On the first loop, the user is not know, so the condition is not met. The plugin is still activated. I have added a more complicated code with three conditionnal : unset the plugin if the user is not set, so the plugin is inactivated each time on the first loop. IF the user is set (next loops), check him to set/unset the plugin accordingly. Wasn't working either. I didn't manage to find the right formula, so maybe I'm wrong somewhere and it can't be done. Each time, the plugin is either activated or deactivated for all users. It looks like the first iteration is the one that counts. Is there a way to inactivate a plugin for specific user/group ?


Banner editable from backend

Im trying to create a widget area. Ive added this to the theme.               <?php if ( dynamic_sidebar('myWidgetName') ) : else : endif; ?>      And then i register the area with                  function arphabet_widgets_init() {              register_sidebar( array(             'name' => 'myWidgetName',             'id' => 'home_right_1',             'before_widget' => '
',             'after_widget' => '
',             'before_title' => '
',             'after_title' => '
',         ) );     }              add_action( 'widgets_init', 'arphabet_widgets_init' );      And it seems to work. I can see my widget area in the panel and i can drag widgets there. What i am actually trying to do is to create an area where the webmaster can display HTML tex, and another area that displays an image and the webmaster chooses what image that is displayed in that area. Som from the backend i would like there to be an HTML editor for the first widget area, and just a image picker for the second. Is there perhaps an easier solution than programming it all myself?


WP_user_query throws a 404 error

I'm trying to get Wordpress (3.9.2) to search meta_key's in usermeta. I have tried every example provided on every site I've searched but I keep getting redirected to the 404 error page. I've tried the simplest check yet and it still throws an error - can someone please help me understand what I'm doing wrong? This works:               add_action('pre_user_query','my_pre_user_search');     function my_pre_user_search($user_query) {        print_r($user_query);     }      Which outputs this:               WP_User_Query Object     (         [query_vars] => Array             (                 [blog_id] => 1                 [role] =>                  [meta_key] =>                  [meta_value] =>                  [meta_compare] =>                  [include] => Array                     (                     )                      [exclude] => Array                     (                     )                      [search] =>                  [search_columns] => Array                     (                     )                      [orderby] => login                 [order] => ASC                 [offset] => 0                 [number] => 20                 [count_total] => 1                 [fields] => all_with_meta                 [who] =>              )              [results] =>          [total_users] => 0         [query_fields] => SQL_CALC_FOUND_ROWS wp_users.ID         [query_from] => FROM wp_users         [query_where] => WHERE 1=1         [query_orderby] => ORDER BY user_login ASC         [query_limit] => LIMIT 20     )      However, when I try to modify the query to: (taken exactly from http://codex.wordpress.org/Class_Reference/WP_User_Query)               add_action('pre_user_query','my_pre_user_search');     function my_pre_user_search($user_query) {        $user_query = new WP_User_Query( array( 'meta_key' => 'country', 'meta_value' => 'Israel' ) );     }      The page redirects to a 404 Error Page As does this: (which is modified to search a valid metakey and value               add_action('pre_user_query','my_pre_user_search');     function my_pre_user_search($user_query) {        $user_query = new WP_User_Query( array( 'meta_key' => 'member_id', 'meta_value' => '2349' ) );     }      I'm copying the code character for character from WP but it is not working... Any ideas?


Display Thumbnail, category title and category description

I am trying to create a shortcode that would display woocommerce category title, thumbnail and description so far I can only display the thumbnail                       $prod_categories = get_terms( 'product_cat', array(             'orderby'    => 'name',             'order'      => 'ASC',             'hide_empty' => 1         ));         foreach( $prod_categories as $prod_cat ) :             $cat_thumb_id = get_woocommerce_term_meta( $prod_cat->term_id, 'thumbnail_id', true );             $cat_thumb_url = wp_get_attachment_thumb_url( $cat_thumb_id );             $term_link = get_term_link( $prod_cat, 'product_cat' );               ?>     <a href="<?php echo $term_link; ?>"><img src="<?php echo $cat_thumb_url; ?>" alt="<?php echo $prod_cat->name; ?>" />     <a href="<?php echo $term_link; ?>"><?php  echo $prod_cat->name;  ?>     <?php  echo $term->description ;               endforeach; wp_reset_query();


Is it possible to link to the same page from wordpress page menu?

I have a big one page wordpress site and a menu created from wordpress admin pages panel. I added everywhere in my main page such links like `<A NAME="gohere">` and similar. Now I need to add href's to the page menu name's like `<a href="#gohere">` Actually I do not know is it possible to do this from the wordpress admin page's menu or maybe anybody know where these pages are stored so that I could add the links manually in the file's. Thanks! Tried plugin "Page Links to" and added something like `<A NAME="gohere">` as a link in where, but unfortunately plugin do not understand this, Regards,


Add jQuery function to media button

I have added a custom button to the media actions in a custom theme,               function wp_myplugin_media_button($context) {         $wp_myplugin_media_button_image = '../wp-content/themes/datamine/images/icon_create_table.gif';         $wp_myplugin_media_button = ' %s' . '  '; // table.php?type=tabletool&TB_iframe=true" class="thickbox"         return sprintf($context, $wp_myplugin_media_button);     }          add_filter('media_buttons_context', 'wp_myplugin_media_button');      but how can I attach event listeners?               $('#fluffyRabbit').live('click',function() { alert('o hai!'); });      If I use add_action, do I have to include a new `script.js` file? If someone can step by step me on this that would be awesome. I just started really tinkering with WP. Cheers! Bo


Hide php Notices in Dashboard

When I program a theme, I put WP-DEBUG on. Which ensure a proper PHP code. Sadly most Plugin developers keeps using non existing vars :               echo $args['title'];          Notice: Undefined index: title in /wp-content/plugins/easy-fancybox/easy-fancybox.php on line 301      Instead of               echo ( isset($args['title']) ? $args['title'] : '' );      So I permanently get tens of Notice errors with some plugins (even MU gets one !) Thanks to a Debugbar I don't see them on my websites, not in the middle, they are all deported to the bottom. But how could I hide them in the Dashboard the same way? I would like to push them to the bottom of the page. **UPDATE: Actually, Debugbar hides them in Admin and Website the same way, I just didn't notice that it didn't work for this particular plugin for once. Notices errors were between`<script>` tags**


google +1 like polling system

I have a photography blog - and in a monthly post i feature different images for different photographers - around 50+ pic and I ask the users to vote for their favorite picture. It is turning out hard - since it is really hard to make up mind about one picture - so instead, i'd like to implement a polling system that is pretty much like google's +1 Each image will have a +1 button near it - if you like the pic, you click +1 - you can like many pics. There is no social media interactions going in the background - like no real submission of photos to google+1 to avoid spamming users.. but it is just the idea. I do not want to use regular poll with a checkbox. Is there any plugin that does something close to this? any feedback or idea on how to go around coding it? Thanks in advance for the help


How to style the RSS wordpress?

I am using the default rss feed widget but want to style it. My question is -where to add my piece of code to style the default wordpress rss widget?


Limit Loop to One Category

I am trying to limit my loop to one category. This is the loop:               <?php     $counter = 1; //start counter          $grids = 3; //Grids per row          global $query_string; //Need this to make pagination work               /*Setting up our custom query (In here we are setting it to show 12 posts per page and eliminate all sticky posts) */     query_posts($query_string . '&caller_get_posts=1&posts_per_page=9&category=5');                    if(have_posts()) :  while(have_posts()) :  the_post();      ?>     <?php     //Show the left hand side column     if($counter == 1) :     ?>

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

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

<?php the_excerpt(); ?>

     <?php     //Show the middle column     elseif($counter == $grids) :     ?>

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

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

<?php the_excerpt(); ?>

     <?php     //Show the right hand side column     elseif($counter == $grids) :     ?>

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

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

<?php the_excerpt(); ?>

     <?php     endif;     ?>          <?php     endwhile;     //Pagination can go here if you want it.     endif;     ?>      This is the page temp.               <?php     /*     Template Name: Web Design     */      get_header(); ?>

                  <?php get_template_part('loop', 'web'); ?>
          <?php get_footer(); ?>      It is not working. Please help. Thanks.


Assign an icon to a category post

Is there a way to assign an icon to a category post as well as the posts original image that's set in the featured images? So if had a post about grapes I would have an image of some grapes in the thumbnail but I'd also have a grape icon from the grapes category attached to the preview post. This is an example of what I mean http://wordpress.thebebel.com/showcase/bloggaexport/ Thanks


create gallery page for specific post id

I have several custom post types similar to (place, person,etc.) refer this and under each of these custom post type there are several posts inserted. (ex.http://www.firstpost.com/topic/person/amitabh-bachchan-profile-5605.html) Each post will be having the image attachments out of which I want to create a gallery page similar to this. Currently I have progressed to generate a single page for each custom post type. can anyone please advise me for the further process? **EDIT** You can consider the following link: www.newsmirror.agstechnologies.com/topic/place/new-delhi see the link "View All" on the top right part of the gallery. For the time I have created a normal page and I am passing the ID of the post as the parameter to that page and using that ID I am fetching the attachment images for that post. but that crates URL something like www.newsmirror.agstechnologies.com/gallery?id=322 but I want the link like: www.newsmirror.agstechnologies.com/topic/place/new- delhi/gallery can anybody help me on this? Sorry but I cannot post the direct links so you have to copy paste the URLS.


How do I block a subdirectory from WordPress theming?

I have a WordPress site. It works great. But I have a subdirectory on my server where I work on client websites. It's a development space and most of those sites are NOT WordPress. Sometimes (but not all the time?) my site's WordPress theme will takeover a page and mess up all my styles. I don't care so much about WHY this is happening... but how do I prevent it? I assume I need to edit my .htaccess with some extra line of code. Alright, here's a page that's being corrupted by WP styles:   * See my current WP site at fowlertown.com   * Here's a non-WP page on a new site I'm building: http://fowlertown.com/projects/fowler6/case-studies/dancefx.html   * Here's how that page SHOULD look: http://fowlertown.com/projects/fowler6/industry-experience/higher-education.html Notice the header and footer; the middle section is broken right now anyway.


apache cpu over 70% on localhost

i'm running a number of WP sites on my localhost WAMP on w8. I started to work on a new site, using Sass and Zurb Foundation using this template: http://jointswp.com/. the problem: During my work, suddenly every time I'm querying from the index page, the apache server takes up to 70% from my cpu and the page doesn't load. It happens only on this site, only on this specipic page. This is the code from the index.php:               <?php get_header(); ?>

             <?php $caruselq = new WP_Query( array( 'post_type' => 'action') );?>                 <?php if ( $caruselq->have_posts() ) : while ( $caruselq->have_posts() ) :?>                     <?php include get_stylesheet_directory().'/tryout.php';//carusel?>                 <?php endwhile; ?>             <?php else: ?>                  <?php endif;?>
                         <?php get_sidebar(); ?>

      <?php get_footer(); ?>      and the code from tryout.php:               <?php if (have_posts()) :?>
       <?php while (have_posts()) : the_post(); ?>
           <?php the_post_thumbnail(); ?>
           <?php the_excerpt();?>

           <?php endwhile;?>
     <?php endif;?>      Here is the log from apache during the problem:               1 - - [19/Apr/2014:18:05:38 +0300] "GET /favicon.ico HTTP/1.1" 404 209     ::1 - - [19/Apr/2014:18:05:40 +0300] "GET /egood/wp-admin/plugins.php HTTP/1.1" 200 43845     ::1 - - [19/Apr/2014:18:05:44 +0300] "GET /egood/wp-admin/load-scripts.php?c=1&load%5B%5D=hoverIntent,common,admin-bar,thickbox,plugin-install,svg-painter,heartbeat,wp-auth-check,underscore,shortcode,media-upload&ver=3.9 HTTP/1.1" 200 21434     ::1 - - [19/Apr/2014:18:05:49 +0300] "GET /egood/wp-admin/plugins.php?action=delete-selected&checked%5B0%5D=akismet%2Fakismet.php&plugin_status=all&paged=1&s&_wpnonce=8adc278390 HTTP/1.1" 200 29629     ::1 - - [19/Apr/2014:18:05:51 +0300] "GET /egood/wp-admin/load-scripts.php?c=1&load%5B%5D=hoverIntent,common,admin-bar,svg-painter,heartbeat,wp-auth-check,thickbox,underscore,shortcode,media-upload&ver=3.9 HTTP/1.1" 200 21188     ::1 - - [19/Apr/2014:18:05:53 +0300] "POST /egood/wp-admin/plugins.php?action=delete-selected&checked%5B0%5D=akismet%2Fakismet.php&plugin_status=all&paged=1&s&_wpnonce=8adc278390 HTTP/1.1" 302 -     ::1 - - [19/Apr/2014:18:05:53 +0300] "GET /egood/wp-admin/plugins.php?deleted=true&plugin_status=all&paged=1&s= HTTP/1.1" 200 42329     ::1 - - [19/Apr/2014:18:05:54 +0300] "GET /egood/wp-content/plugins/kk-star-ratings/bhittani-framework/admin/js/colorpicker/js/colorpicker.js HTTP/1.1" 304 -     ::1 - - [19/Apr/2014:18:05:54 +0300] "GET /egood/wp-content/plugins/kk-star-ratings/bhittani-framework/admin/js/lightbox.js HTTP/1.1" 304 -     ::1 - - [19/Apr/2014:18:05:54 +0300] "GET /egood/wp-content/plugins/kk-star-ratings/bhittani-framework/admin/js/admin.js HTTP/1.1" 304 -     ::1 - - [19/Apr/2014:18:05:54 +0300] "GET /egood/wp-content/plugins/kk-star-ratings/bhittani-framework/admin/js/script.js HTTP/1.1" 304 -     ::1 - - [19/Apr/2014:18:05:54 +0300] "GET /egood/wp-admin/load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,utils&ver=3.9 HTTP/1.1" 200 40221     ::1 - - [19/Apr/2014:18:05:54 +0300] "GET /egood/wp-admin/load-scripts.php?c=1&load%5B%5D=hoverIntent,common,admin-bar,thickbox,plugin-install,svg-painter,heartbeat,wp-auth-check,underscore,shortcode,media-upload&ver=3.9 HTTP/1.1" 200 21434     ::1 - - [19/Apr/2014:18:06:55 +0300] "POST /egood/wp-admin/admin-ajax.php HTTP/1.1" 200 47     ::1 - - [19/Apr/2014:18:07:27 +0300] "GET /egood/wp-admin/plugins.php?action=deactivate&plugin=jetpack%2Fjetpack.php&plugin_status=all&paged=1&s&_wpnonce=0cc932eb63 HTTP/1.1" 302 -     ::1 - - [19/Apr/2014:18:07:28 +0300] "GET /egood/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s= HTTP/1.1" 200 41519     ::1 - - [19/Apr/2014:18:07:46 +0300] "GET /egood/wp-admin/plugins.php?action=deactivate&plugin=kk-star-ratings%2Findex.php&plugin_status=all&paged=1&s&_wpnonce=5d232328de HTTP/1.1" 302 -     ::1 - - [19/Apr/2014:18:07:47 +0300] "GET /egood/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s= HTTP/1.1" 200 38436     ::1 - - [19/Apr/2014:18:07:47 +0300] "GET /egood/wp-admin/load-scripts.php?c=1&load%5B%5D=hoverIntent,common,admin-bar,thickbox,plugin-install,svg-painter,heartbeat,wp-auth-check&ver=3.9 HTTP/1.1" 200 14928     ::1 - - [19/Apr/2014:18:08:48 +0300] "POST /egood/wp-admin/admin-ajax.php HTTP/1.1" 200 47     ::1 - - [19/Apr/2014:18:09:48 +0300] "POST /egood/wp-admin/admin-ajax.php HTTP/1.1" 200 47      Ive been trying to generate log file from WP by changing the WP_DEBUG and WP_DEBUG_LOG but it does not generate... Here is MYSQL log file from today:               2014-04-19 16:43:50 7000 [Note] Plugin 'FEDERATED' is disabled.     2014-04-19 16:43:50 7000 [Note] InnoDB: The InnoDB memory heap is disabled     2014-04-19 16:43:50 7000 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions     2014-04-19 16:43:50 7000 [Note] InnoDB: Compressed tables use zlib 1.2.3     2014-04-19 16:43:50 7000 [Note] InnoDB: Not using CPU crc32 instructions     2014-04-19 16:43:50 7000 [Note] InnoDB: Initializing buffer pool, size = 128.0M     2014-04-19 16:43:50 7000 [Note] InnoDB: Completed initialization of buffer pool     2014-04-19 16:43:50 7000 [Note] InnoDB: Highest supported file format is Barracuda.     2014-04-19 16:43:50 7000 [Note] InnoDB: 128 rollback segment(s) are active.     2014-04-19 16:43:50 7000 [Note] InnoDB: Waiting for purge to start     2014-04-19 16:43:50 7000 [Note] InnoDB: 5.6.12 started; log sequence number 105484389     2014-04-19 16:43:50 7000 [Note] Server hostname (bind-address): '*'; port: 3306     2014-04-19 16:43:50 7000 [Note] IPv6 is available.     2014-04-19 16:43:50 7000 [Note]   - '::' resolves to '::';     2014-04-19 16:43:50 7000 [Note] Server socket created on IP: '::'.     2014-04-19 16:43:51 7000 [Note] Event Scheduler: Loaded 0 events     2014-04-19 16:43:51 7000 [Note] wampmysqld: ready for connections.     Version: '5.6.12-log'  socket: ''  port: 3306  MySQL Community Server (GPL)


Need to manually regsiter user, send the password and retreive their user ID

I'm writing a custom signup script for users to register with on my MU-setup. One problem I'm having is that `wpmu_signup_user()` sends the password activation email but it doesn't return the user ID which I need for the rest of the script. - It's my understanding that this doesn't create the user account, just an entry in the "signup" table. The other way I've tried is using `wp_create_user()` which returns the user ID I need (as it creates the user properly) but no email for the user.


What's the difference between Role and Meta capabilities; When to use map_meta_cap() filter

I'm getting very confused about the following things:   1. difference between Role and Meta capabilities,   2. difference between Meta and Primitive capabilities,   3. when to use `map_meta_cap()` filter. There were lots of situations, where I add WP existing or custom capabilities to either WP existing or custom roles, expecting it to work out of the box and most of the times it doesn't. I see that people mention about `map_meta_cap()` filter, but I can't find a good explanation what it actually does and when do I have to use it and when capabilities will work out of the box. I hope that makes sense. I would hugely appreciate explanations or links to resources that explain this well. Thanks, Dasha


Editorial Process

Now I've never really used Wordpress with more than one author and it's usually been myself so I've followed no editorial process, but with my new site, I'm looking to add a handful of users to the Author role. I understand there's many roles with different permissions within Wordpress already, but I can't seem to find whether or not there's an option or any documentation about setting WP up so that when Authors submit an article it should go to the Editor group for approval before anything gets published (editors are notified of new pending items via e-mail). Is this possible? Or does it work like this by default? As I don't know, I thought I'd ask here. Thanks for any help in advance


Custom Slug for a custom post type and default post

It's now several hours that I am trying to get this done without finding a proper solution. **WHAT I WANT TO ACHIEVE** I'd like WP to use the following URL structure:               1) Posts -> /%category%/articles/%postname%/     2) CPT   -> /%category%/CPT/%postname%/      Where the %category% bit is the default categories taxonomy used in the Posts **WHAT I DID SO FAR** To add the default categories taxonomy to the CPT, this bit has been added while registering the CPT               'taxonomies'         => array('category'),      whereas the followings are the rewrite args               $rewrite_args = array( 'slug' => '%category%/test', 'with_front' => false, 'feeds' => false, 'pages' => false );      **CHANGING THE DEFAULT POST** I know the most obvious solution is to change the permalink structure in the setting panel. And this need to be done in any case otherwise anything I will describe will work. So my Permalink structure has been set as               /%category%/articles/%postname%/      **WHAT'S HAPPENING** If I leave the basic configuration, no hooks, anything. Posts works as expected. At the time I hook on the post_type_link to make my CPT replacing the %category%, the default configuration stops working. I tried to re-register the Posts type; this seems to give better results (though there is the inconvenience to see the "posts" item twice in the admin bar), but for some reason when I do this, the CPT custom slug stops working. Do you have any specific hint? Thanks Andrea


Email post content

I have this function in functions.php to send an email when a new post is published. How can I add the content of the post as the message in the email.               function authorNotification($post_id) {             $to = 'email@hotmail.co.uk';             $subject = 'New Post';             $message = $post_id->post_content;             $headers = 'Content-type: text/html';             wp_mail($to, $subject, $message, $headers);     }     add_action('publish_post', 'authorNotification');


add_query_vars does not work

I have added this code in the TwentyFourteen theme's functions.php file.               function add_query_vars($aVars) {         $aVars[] = "msds_pif_cat";         return $aVars;     }     add_filter('query_vars', 'add_query_vars');      Then on the index.php file, I have added this:               $sMsdsCat = urldecode($wp_query->query_vars['msds_pif_cat']);     var_dump($sMsdsCat);      It does not return anything. I have tried to print the `$wp_query` and it does not include that variable either. What I'm doing wrong?


How to enable thumbnails in RSS dashboard widget

I'm successfully using fetch_feed() to display an RSS feed inside a dashboard widget. However, I'm unable to load the thumbnail image from the items in the feed. I'm attempting to do it with the get_image_url() method, however, WordPress errors out on that method as an undefined method. Code is below...               function example_dashboard_widget_function() {         // Display whatever it is you want to show            $rss = fetch_feed( "http://localhost/testsite/wp-content/test.rss" );               if ( is_wp_error($rss) ) {               if ( is_admin() || current_user_can('manage_options') ) {                    echo '
';                    printf(__('RSS Error: %s'), $rss->get_error_message());                    echo '
';               }          return;     }          if ( !$rss->get_item_quantity() ) {          echo '
No RSS items to show!
';          $rss->__destruct();          unset($rss);          return;     }          echo "
\n";          if ( !isset($items) )          $items = 10;               foreach ( $rss->get_items(0, $items) as $item ) {               $publisher = '';               $site_link = '';               $link = '';               $content = '';               $date = '';               $image = '';                    $image = $item->get_image_url();     //        $image = esc_url( strip_tags( $item->get_thumbnail() ) );                    $link = esc_url( strip_tags( $item->get_link() ) );                    $content = $item->get_content();               $content = wp_html_excerpt($content, 250) . ' ...';                   echo "
$link - $content
\n";     }          echo "
\n";     $rss->__destruct();     unset($rss);          }


Resizing Uploading Images in Bulk?

I have been running a blog for a friend and over the last months she has been adding insane amounts of images taken directly from a DSLR. Each takes up around 5-6 MB so the site is now slow to load and is consuming large amounts of bandwidth and disk size. I was looking on the smush.it plugin, but it doesn't seem to do it ad-hock and also, doesn't do bulk resize. Is there some easy way to fix this on the server with a plugin? Would prefer that instead of download all images and do bulk resize. Big thanks.


Add custom text color WordPress 3.9 TinyMCE 4 Visual editor

I had a code snippet which would help me to add some custom color to the visual editor text color dropdown along with the default colors. I'm pasting the snippet below.               function change_mce_options( $init ) {       $default_colours = '000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF';       $custom_colours = 'e14d43,d83131,ed1c24,f99b1c,50b848,00a859,00aae7,282828';       $init['theme_advanced_text_colors'] = $default_colours . ',' . $custom_colours;       $init['theme_advanced_more_colors'] = true;       return $init;     }     add_filter('tiny_mce_before_init', 'change_mce_options');      After wordpress 3.9 update it stopped working, I've tried a lot to fix it, but I am unable to do it, can you please help me out?


Disable Specific Widgets on Selected Pages of a WordPress Website?

I would like to give a CMS look to some of my pages. I want to customize them by removing the default widgets and adding other widgets as my wish (I will use plugins like **My Custom Widget** to add custom codes if I need) . Is there any possibility to customize the specific pages like this?


PHP "Inception" - PHP within string

Posting this in Wordpress as my limited PHP knowledge leaves me thinking this might be WP-specific. I'm using WP's do_shortcode to call a shortcode into a post               echo do_shortcode('[mycred_video id="iYgPznBrjiA" amount="5" logic="interval" interval="15"]');      This embeds a Youtube video + extra code. So in order to have the content be dynamic I want to call on the content of a custom field I added to my posts, which I've used another plugin for. This is how I call it:               echo the_field( 'video_id' );      So I have to figure out how to call the content of that before the do_shortcode and then insert it in the string - right? Or is there language I can use in the string all by itself to call the content of video_id? The ultimate dream is to allow registered users be able to publish posts from the frontend. It seems I'll have to code that side of things myself, but do any of y'all know a good plugin that will give me a frontend editor I could include my custom field in? Much appreciated


How do I reply to comments from admin panel on a tablet PC?

For certain reasons I prefer to reply to readers' comments from the admin panel (edit-comments.php). It's not a problem with a mouse. When I place the cursor over a comment, the comment management links pop-up, including the reply option. It's shown below, albeit with the Russian UI. ![comment management](http://i.stack.imgur.com/KKGhN.png) The Reply link opens the reply form right below the comment. It doesn't work that way for me on a tablet PC. I can place a finger on the comment and the links appear, but when I try to press any link they all disappear. FWIW, I have an HP tablet and use IE10 (metro/desktop) on Windows 8, and have no desire to change the browser. Basically, there are two questions:   1. Is there an obvious option I'm missing that enables me to accomplish the goal?    2. If not, how can I modify WP behavior to display these links permanently? Thanks for your attention to my questions :)


How to Add Tags to Custom Post Type?

I have a custom post type called `portfolio` and I'm trying to add the tags taxonomy to it, how do I do this?


Wordpress Hacks/Defacing

Im trying to figure out how Wordpress sites become defaced/hacked. I know development very well. I know how to secure code, etc. But I am finding recently, that tons of Wordpress sites are becoming defaced. Both sites I developed, and others. Is it simply outdated Wordpress installs? Even when Wordpress is running version 3.1, sites are still being defaced. All user input is validated, both on the front-end and back-end. WP nonces are used wherever possible. Servers are fairly secure (not 777). ???? I'm loosing faith in Wordpress. If it is my fault, I will gladly admit and fix, but the only answer seems to be outdated Wordpress sites, and I find that hard to believe.


Quickest Way Besides FTP to Upload WordPress Files to a Web Server?

Assume I have SSH from a shared/managed-VPS hosting, and FTP access, but no fantastico. Thanks.


Membership Plugin

I'm looking for a good plugin for premium blog content. My client wants to offer 30 trial that's free as well as a paid monthly/6 months/yearly plan. It should display an except of the post for everyone even when they're on the site as a guest without any membership, trial or premium. It also needs to receive payments through PayPal and automatically turn on the subscription after payment. I want to be able to customize the register page to add additional fields like address and phone number.


Customizing Default Categories Widget

I am trying to hack the default categories widget from wordpress. I have the categories displaying the way I want but I am having trouble editing the output. The widget shows the number of posts in each post which is what I want, but it also displays the number in parenthesis. I don't want that. I know how to get rid of them but I can't seem to make it work. I tried like so               $cat_args['title_li'] = '';     $list = wp_list_categories(apply_filters('widget_categories_args', $cat_args));     $list .= str_replace('(', '', $list);     $list .= str_replace(')', '', $list);     echo $list;      It just continues to display the categories the same way. I don't understand why it's not echoing the list. I am using the code for the categories from the default-widgets.php file in the wp-includes folder.