title: Custom post type not saving

text:
I've recently created a custom post type, however each time an update is saved the contents of the meta field disappears after a few minutes. Is this a bug?               <?php          //      CUSTOM POST TYPE 1     add_action('init', 'ootb_tenant_register');          function ootb_tenant_register() {         $args = array(             'label' => __('Tenant'),             'singular_label' => __('Tenant'),             'public' => true,             'show_ui' => true,             'capability_type' => 'post',             'hierarchical' => false,             'rewrite' => true,             'supports' => array('title', 'editor', 'thumbnail')         );              register_taxonomy("business", array("tenant"), array(             "hierarchical" => true,              "label" => "Business Type",              "singular_label" => "Business",              "rewrite" => true)         );              register_post_type( 'tenant' , $args );     }               add_action("ootb_admin_init", "ootb_admin_init");     add_action('wp_insert_post_data', 'ootb_save_tenant_options');          function ootb_admin_init(){         add_meta_box("gallerymeta", "Tenant Directory Data", "ootb_tenant_meta_options", "tenant", "normal", "low");     }          function ootb_tenant_meta_options(){         global $post;         $custom = get_post_custom($post->ID);         $location = $custom["location"][0];         $shortdesc = $custom["shortdesc"][0];         $website = $custom["website"][0];         $email = $custom["email"][0];         $twitter = $custom["twitter"][0];         $facebook = $custom["facebook"][0];         $smallpictureurl = $custom["smallpictureurl"][0];         $contactname = $custom["contactname"][0];         $landlinephone = $custom["landlinephone"][0];         $mobilephone = $custom["mobilephone"][0];         $largepictureurl = $custom["largepictureurl"][0];         $picturealttag = $custom["picturealttag"][0];     ?>

                 Location :             <select name="location" style="width: 200px;">                 <option <?php if($location == "Please select...") echo "selected"; ?> value="Please select...">Please select...</option>                 <option <?php if($location == "Out of the Blue Drill Hall") echo "selected"; ?> value="Out of the Blue Drill Hall">Out of the Blue Drill Hall</option>                 <option <?php if($location == "Portobello Powerhouse") echo "selected"; ?> value="Portobello Powerhouse">Portobello Powerhouse</option>             </select>
Location of Business

             Short Description :             <textarea name="shortdesc"><?php echo $shortdesc; ?></textarea>
Short description of the business which will appear on the directory homepage.

             Website Address :             <input name="website" value="<?php echo $website; ?>" />
Website address including http://www.

             E-mail Address :             <input name="email" value="<?php echo $email; ?>" />
Business contact address.

             Twitter URL :             <input name="twitter" value="<?php echo $twitter; ?>" />
Twitter URL including http://www.

             Facebook URL :             <input name="facebook" value="<?php echo $facebook; ?>" />
Facebook URL including http://www.

             Small Picture URL :             <input name="smallpictureurl" value="<?php echo $smallpictureurl; ?>" />
250 x 250 Picture URL

             Large Picture URL :             <input name="largepictureurl" value="<?php echo $largepictureurl; ?>" />
500 x 500 Picture URL

             Picture Alt Tag :             <input name="picturealttag" value="<?php echo $picturealttag; ?>" />
Alt tag for both images.

             Business contact name :             <input name="contactname" value="<?php echo $contactname; ?>" />
Business contact name.

             Landline Telephone Number :             <input name="landlinephone" value="<?php echo $landlinephone; ?>" />
Landline telephone number.

             Mobile Telephone Number :             <input name="mobilephone" value="<?php echo $mobilephone; ?>" />
Mobile telephone number.

          <?php     }          function ootb_save_tenant_options( $post_id ) {         global $post;            //skip auto save         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {             return $post_id;         }         //check for you post type only         if( $post->post_type == "tenant" ) {                 if( isset($_POST['location']) ) { update_post_meta( $post->ID, 'location', $_POST['location'] );}                 if( isset($_POST['shortdesc']) ) { update_post_meta( $post->ID, 'shortdesc', $_POST['shortdesc'] );}                 if( isset($_POST['website']) ) { update_post_meta( $post->ID, 'website', $_POST['website'] );}                 if( isset($_POST['email']) ) { update_post_meta( $post->ID, 'email', $_POST['email'] );}                 if( isset($_POST['twitter']) ) { update_post_meta( $post->ID, 'twitter', $_POST['twitter'] );}                 if( isset($_POST['facebook']) ) { update_post_meta( $post->ID, 'facebook', $_POST['facebook'] );}                 if( isset($_POST['contactname']) ) { update_post_meta( $post->ID, 'contactname', $_POST['contactname'] );}                 if( isset($_POST['smallpictureurl']) ) { update_post_meta( $post->ID, 'smallpictureurl', $_POST['smallpictureurl'] );}                 if( isset($_POST['landlinephone']) ) { update_post_meta( $post->ID, 'landlinephone', $_POST['landlinephone'] );}                 if( isset($_POST['mobilephone']) ) { update_post_meta( $post->ID, 'mobilephone', $_POST['mobilephone'] );}                 if( isset($_POST['largepictureurl']) ) { update_post_meta( $post->ID, 'largepictureurl', $_POST['largepictureurl'] );}                 if( isset($_POST['picturealttag']) ) { update_post_meta( $post->ID, 'picturealttag', $_POST['picturealttag'] );}         }     }          ?>


title: Is there a way to use the Wordpress users but without loading the entire Wordpress core?

text: I have a Wordpress site and a web application that can be used only by the registered (Wordpress) users. Now I'm loading `wp-blog-header.php` to check if the user is logged in. Everything is working fine but because on every request (including AJAX) I have to load the Wordpress core also, it slows down my application visibly (more than 70% from the total loading time). Is there any simple way to use the Wordpress users but without loading the entire Wordpress core? Update: I need to know which user is logged in and also security is important. Thank you!


title: rename attachments based on parent-post-title on upload

text: I know there a some functions already avaible here for this task, but none of them seem to work as needed. The best way seems to me adding a filter to **wp_handle_upload_prefilter** like kaiser does in this example. Unfortunately the file only gets the parent- post-title if the post is already saved to the database. * * * Another approach is to add a function to **add_attachment** like Ijaas does here. Then the file gets the parent-post-title as name, but no thumbnails are created. And my attempt in using wp_generate_attachment_metadata(); to create the missing image sizes, ended in an endless loop (propably cause I'm using it the wrong way, but now I'm a bit scared by this function). * * * Would be great if there was a way to pass the title to **wp_handle_upload_prefilter** even if the post isn't saved yet. Oh by the way, this is my endless function, maybe somebody can tell me what's wrong with it. **DON'T USE THIS FUNCTION !!!**               add_action('add_attachment', 'fkp_rename_attacment');     function fkp_rename_attacment($post_ID){            $post = get_post($post_ID);       $file = get_attached_file($post_ID);       $path = pathinfo($file);       $parent = get_post($post->post_parent);       $p_author = get_the_author_meta( 'display_name', $parent->post_author );       $p_author_san = sanitize_title($p_author);            $newfilename = $parent->post_name . '-' . $p_author_san . '-' . $post_ID;       $newfile = $path['dirname']."/".$newfilename.".".$path['extension'];            rename($file, $newfile);                $wp_filetype = wp_check_filetype(basename($newfile), null );       $wp_upload_dir = wp_upload_dir();       $attachment = array(         'guid' => $wp_upload_dir['url'] . '/' . basename( $newfile ),          'post_mime_type' => $wp_filetype['type'],         'post_title' => preg_replace('/\.[^.]+$/', '', basename($newfile)),         'post_content' => '',         'post_status' => 'inherit'        );       $attach_id = wp_insert_attachment( $attachment, $newfile, $parent->ID );       require_once(ABSPATH . 'wp-admin/includes/image.php');       $attach_data = wp_generate_attachment_metadata( $attach_id, $newfile );       wp_update_attachment_metadata( $attach_id, $attach_data );     }      **DON'T USE THIS FUNCTION !!!**


title: How to reorder categories for Custom Post Type

text: Is there a plugin available that will allow the drag and drop reordering of categories for a custom post type? Or suggestions on how to achieve reordering categories?


title: Extract 1st word of blogname/insert in middle of new string

text: Wordpress Website Name (say) = "German Philosophy Politics & Economics" I want to return "My German Site" I have tried the following :               <?php     $myvalue = bloginfo('name');     $arr = explode(' ',trim($myvalue));     $var = $arr[0];     echo "My ".$var." Site";     ?>      but it returns "German My Site" not "My German Site" Any ideas ?


title: Emailing only the users of a MultiSites Sub-Sites

text: Context: Creating a MultiSite in which each Sub-Site will have it's own set of users that they belong to. These users are only able to view their own site. I was wondering what the easiest way to mass-email the users of each Sub-Site would be? For instance, when a new News post is put in the blog, it will send a notification to the members of that Sub-Site, but noone else. I have found Plug-ins that would mass-email the whole network, but it seems to be hard to find one that can separate from the network and the Sub-Sites. It would be the admins/owners of the Sub-Sites that will be sending the email, not the Super- admin.


title: Listing only custom post types with two required categories?

text:
I use the following custom loop to display a custom post type with the custom taxonomy:               <?php // Create and run custom loop         $custom_posts = new WP_Query();         $custom_posts->query('post_type=page_content&page_sections=Apps');         while ($custom_posts->have_posts()) : $custom_posts->the_post();     ?>
             <?php the_post_thumbnail('large'); ?>
     <?php endwhile; ?>      Right now it reads: retrieve ONLY posts with the **page_content** custom post type and the **App** custom taxonomy. Is it possible to make it read: retrieve ONLY posts with the **page_content** custom post type, the **Front Page** custom taxonomy, and the **Apps** custom taxonomy? **EDIT:** This didn't work:               <?php // Create and run custom loop             $custom_posts = new WP_Query();             $custom_posts->query('post_type=page_content&page_sections=Front Page, Apps');             while ($custom_posts->have_posts()) : $custom_posts->the_post();         ?>
                 <?php the_post_thumbnail('large'); ?>
         <?php endwhile; ?>


title: WooCommerce Tabs

text: In my theme, I have the _WooCommerce_ plugin installed and would like to rename the " _Catalog_ " tab, located under the _WooCommerce_ > _Settings_ submenu page. Am I able to do this from my `functions.php` file so that I'm not directly modifying the plugin itself and if so, how? ![enter image description here](http://i.stack.imgur.com/A2W3I.png) Thanks.


title: Is it possible to block subscriber users to changing its password?

text: I want to disable changing password option for all my subscriber users. Is it possible by doing any code tweak or something using any plugin? ![Disable password changing option for subscriber users](http://i.stack.imgur.com/Q3Des.jpg) If someone has any idea or plugin knowledge to do this then appreciated.


title: Media library to list images only user uploaded

text: I want to list images for only user uploaded image. Here is the scenario:   1. Using the image uploader on front end using iframe.   2. I have added `upload_files` cap to subscriber level users and want them to see only images they uploaded.   3. I've found this Q Restricting Users to View Only Media Library Items They Have Uploaded? but the accepted answer not working for me.              // Code originally by @t31os     add_action('pre_get_posts','users_own_attachments');          function users_own_attachments( $wp_query_obj )      {         global $current_user, $pagenow;              if( !is_a( $current_user, 'WP_User') )             return;              if( 'upload.php' != $pagenow )             return;              if( !current_user_can('delete_pages') )             $wp_query_obj->set('author', $current_user->id );              return;     }        4. The frontend page i am using the image uploader is named "Entry".   5. If i remove this part of the code `if( 'upload.php' != $pagenow ) return;` the code works. I i think i have to improve that part of the conditional code but could not figure it out. The conditional is important because i don't want the code to apply on other pages where it not required. So, i need help to improve the conditional part as i mentioned. Thanks!


title: Showing different posts on category pages

text:
I'm using the following code to display posts on my category page but would like to carry the same format through on to the second page of the category as at the moment it moves to the second page but doesn't show the older posts.                      <?php query_posts('showposts=3&cat=1461');                 while (have_posts()) : the_post();                 echo "
";                 echo "
";                 the_post_thumbnail(array (185,152));                 echo "
";                 echo "
";                 the_title();                  echo "
";                 echo "
";                 the_excerpt();                 echo "
";                 echo "
";                 echo "";                 echo "
";                 echo "
";                 endwhile;?>

         <?php query_posts('showposts=3&offset=3&cat=1461');                 while (have_posts()) : the_post();                 echo "
";                 echo "
";                 the_post_thumbnail(array (185,152));                 echo "
";                 echo "
";                 the_title();                  echo "
";                 echo "
";                 the_excerpt();                 echo "
";                 echo "
";                 echo "";                 echo "
";                 echo "
";                 endwhile;?>


title: Adding a second custom taxonomy to a custom post type (both shown in its table)?

text: The following code provided by Mike Schinkel, creates a custom post type and a custom taxonomy. It makes the taxonomy to show up in the custom post type's column. Finally, it inserts some default terms. I would like to insert a second taxonomy for the custom post type (Page Content) called: **Locations**. (this second custom taxonomy should also show up in the column of the custom post type) How can I modify the code to archive that?               <?php          /**      * Create the Page Content custom post type and the Page Section custom taxonomy      */     add_action('init', 'my_init_method');          if (!class_exists('YourSite_PageContent')) {      class YourSite_PageContent {        static function on_load() {          add_action('init',array(__CLASS__,'init'));          add_filter('manage_page_content_posts_columns',              array(__CLASS__,'manage_page_content_posts_columns'));          add_filter('manage_posts_custom_column',              array(__CLASS__,'manage_posts_custom_column'),10,2);          add_action('restrict_manage_posts',              array(__CLASS__,'restrict_manage_posts'));          add_filter('parse_query',              array(__CLASS__,'parse_query'));        }        static function init() {          register_post_type('page_content',array(            'labels' => array(              'name' => __( 'Page Content' ),              'singular_name' => __( 'Page Content' ),              'add_new_item' => 'Add New Page Content',              'edit_item' => 'Edit Page Content',              'new_item' => 'New Page Content',              'search_items' => 'Search Page Content',              'not_found' => 'No Page Content found',              'not_found_in_trash' => 'No Page Content found in trash',            ),            'public' => true,            'hierarchical' => false,            'taxonomies' => array( 'page_sections'),            'supports' => array('title','editor','thumbnail','custom-fields'),            'rewrite' => array('slug'=>'page_content','with_front'=>false),          ));          register_taxonomy('page_sections','page_content',array(            'hierarchical' => true,            'labels' => array(              'name' => __( 'Page Sections' ),              'singular_name' => __( 'Page Section' ),              'add_new_item' => 'Add New Page Section',              'edit_item' => 'Edit Page Section',              'new_item' => 'New Page Section',              'search_items' => 'Search Page Section',              'not_found' => 'No Page Sections found',              'not_found_in_trash' => 'No Page Sections found in trash',              'all_items' => __( 'All Page Sections' ),            ),            'query_var' => true,            'rewrite' => array( 'slug' => 'page_sections' ),            ));          if (!get_option('yoursite-page-content-initialized')) {            $terms = array(              'Footer',              'Header',              'Front Page Intro',              'Front Page Content',              );            foreach($terms as $term) {              if (!get_term_by('name',$term,'page_sections')) {                wp_insert_term($term, 'page_sections');              }            }            update_option('yoursite-page-content-initialized',true);          }        }        function manage_page_content_posts_columns($columns){          $new = array();          foreach($columns as $key => $title) {            if ($key=='author') // Put the Page Sections column before the Author column              $new['page_sections_column'] = 'Page Sections';            $new[$key] = $title;          }          return $new;        }        function manage_posts_custom_column( $column,$post_id ) {          global $typenow;          if ($typenow=='page_content') {            $taxonomy = 'page_sections';            switch ($column) {            case 'page_sections_column':              $page_sections_column = get_the_terms($post_id,$taxonomy);              if (is_array($page_sections_column)) {                foreach($page_sections_column as $key => $page_sections) {                  $edit_link = get_term_link($page_sections,$taxonomy);                  $page_sections_column[$key] = '' . $page_sections->name . '';                }                echo implode(' | ',$page_sections_column);              }              break;            }          }        }        function parse_query($query) {          global $pagenow;          $qv = &$query->query_vars;          if ($pagenow=='edit.php' &&              isset($qv['taxonomy']) && $qv['taxonomy']=='page_sections' &&              isset($qv['term']) && is_numeric($qv['term'])) {            $term = get_term_by('id',$qv['term'],'page_sections');            $qv['term'] = $term->slug;          }        }        function restrict_manage_posts() {          global $typenow;          global $wp_query;          if ($typenow=='page_content') {            $taxonomy = 'page_sections';            $page_sections = get_taxonomy($taxonomy);            wp_dropdown_categories(array(              'show_option_all' =>  __("Show All {$page_sections->label}"),              'taxonomy'        =>  $taxonomy,              'name'            =>  $taxonomy,              'orderby'         =>  'name',              'selected'        =>  $wp_query->query['term'],              'hierarchical'    =>  true,              'depth'           =>  3,              'show_count'      =>  true,  // This will give a view              'hide_empty'      =>  true,   // This will give false positives, i.e. one's not empty related to the other terms. TODO: Fix that            ));          }        }      }      YourSite_PageContent::on_load();     }      ![enter image description here](http://i.stack.imgur.com/TKTCB.png) **EDIT (What I've done so far with no PHP skills):** By modyfing the code this is what I've done so far:               <?php          /**      * Create the Page Content custom post type and the Page Section custom taxonomy      */     add_action('init', 'my_init_method');          if (!class_exists('YourSite_PageContent')) {      class YourSite_PageContent {        static function on_load() {          add_action('init',array(__CLASS__,'init'));          add_filter('manage_page_content_posts_columns',              array(__CLASS__,'manage_page_content_posts_columns'));          add_filter('manage_posts_custom_column',              array(__CLASS__,'manage_posts_custom_column'),10,2);          add_action('restrict_manage_posts',              array(__CLASS__,'restrict_manage_posts'));          add_filter('parse_query',              array(__CLASS__,'parse_query'));        }        static function init() {          register_post_type('page_content',array(            'labels' => array(              'name' => __( 'Page Content' ),              'singular_name' => __( 'Page Content' ),              'add_new_item' => 'Add New Page Content',              'edit_item' => 'Edit Page Content',              'new_item' => 'New Page Content',              'search_items' => 'Search Page Content',              'not_found' => 'No Page Content found',              'not_found_in_trash' => 'No Page Content found in trash',            ),            'public' => true,            'hierarchical' => false,            'taxonomies' => array( 'page_sections'),            'supports' => array('title','editor','thumbnail','custom-fields'),            'rewrite' => array('slug'=>'page_content','with_front'=>false),          ));          register_taxonomy('locations','page_content',array(            'hierarchical' => true,            'labels' => array(              'name' => __( 'Locations' ),              'singular_name' => __( 'Page Section' ),              'add_new_item' => 'Add New Page Section',              'edit_item' => 'Edit Page Section',              'new_item' => 'New Page Section',              'search_items' => 'Search Page Section',              'not_found' => 'No Page Sections found',              'not_found_in_trash' => 'No Page Sections found in trash',              'all_items' => __( 'All Page Sections' ),            ),            'query_var' => true,            'rewrite' => array( 'slug' => 'locations' ),            ));          register_taxonomy('page_sections','page_content',array(            'hierarchical' => true,            'labels' => array(              'name' => __( 'Page Sections' ),              'singular_name' => __( 'Page Section' ),              'add_new_item' => 'Add New Page Section',              'edit_item' => 'Edit Page Section',              'new_item' => 'New Page Section',              'search_items' => 'Search Page Section',              'not_found' => 'No Page Sections found',              'not_found_in_trash' => 'No Page Sections found in trash',              'all_items' => __( 'All Page Sections' ),            ),            'query_var' => true,            'rewrite' => array( 'slug' => 'page_sections' ),            ));          if (!get_option('yoursite-page-content-initialized')) {            $terms = array(              'Footer',              'Header',              'Front Page Intro',              'Front Page Content',              );            foreach($terms as $term) {              if (!get_term_by('name',$term,'page_sections')) {                wp_insert_term($term, 'page_sections');              }            }            update_option('yoursite-page-content-initialized',true);          }        }        function manage_page_content_posts_columns($columns){          $new = array();          foreach($columns as $key => $title) {            if ($key=='author') // Put the Page Sections column before the Author column              $new['page_sections_column'] = 'Page Sections';            $new[$key] = $title;          }          return $new;        }        function manage_posts_custom_column( $column,$post_id ) {          global $typenow;          if ($typenow=='page_content') {            $locations_taxonomy = 'locations';            $page_sections_taxonomy = 'page_sections';            switch ($column) {            case 'locations_column':              $locations_column = get_the_terms($post_id,$locations_taxonomy);              if (is_array($locations_column)) {                foreach($locations_column as $key => $locations) {                  $edit_link = get_term_link($locations,$locations_taxonomy);                  $locations_column[$key] = '' . $locations->name . '';                }                echo implode(' | ',$locations_column);              }              break;            case 'page_sections_column':              $page_sections_column = get_the_terms($post_id,$page_sections_taxonomy);              if (is_array($page_sections_column)) {                foreach($page_sections_column as $key => $page_sections) {                  $edit_link = get_term_link($page_sections,$page_sections_taxonomy);                  $page_sections_column[$key] = '' . $page_sections->name . '';                }                echo implode(' | ',$page_sections_column);              }              break;            }          }        }        function parse_query($query) {          global $pagenow;          $qv = &$query->query_vars;          if ($pagenow=='edit.php' &&              isset($qv['taxonomy']) && $qv['taxonomy']=='page_sections' &&              isset($qv['term']) && is_numeric($qv['term'])) {            $term = get_term_by('id',$qv['term'],'page_sections');            $qv['term'] = $term->slug;          }        }        function restrict_manage_posts() {          global $typenow;          global $wp_query;          if ($typenow=='page_content') {            $taxonomy = 'page_sections';            $page_sections = get_taxonomy($taxonomy);            wp_dropdown_categories(array(              'show_option_all' =>  __("Show All {$page_sections->label}"),              'taxonomy'        =>  $taxonomy,              'name'            =>  $taxonomy,              'orderby'         =>  'name',              'selected'        =>  $wp_query->query['term'],              'hierarchical'    =>  true,              'depth'           =>  3,              'show_count'      =>  true,  // This will give a view              'hide_empty'      =>  true,   // This will give false positives, i.e. one's not empty related to the other terms. TODO: Fix that            ));          }        }      }      YourSite_PageContent::on_load();     }      ![enter image description here](http://i.stack.imgur.com/jKRVH.png) **I'm still struggling with this line:**                  function manage_page_content_posts_columns($columns){          $new = array();          foreach($columns as $key => $title) {            if ($key=='author') // Put the Page Sections column before the Author column              $new['locations_column'] = 'Locations';              $new['cb'] = '<input type="checkbox">';              $new['title'] = 'Title';              $new['page_sections_column'] = 'Page Sections';            $new[$key] = $title;          }          return $new;        }      **I can't manage to place Page Sections before Locations.** How to solve this?


title: Removing "Website" Field from the contact info

text: I want to remove the website field from the user contact info. I use the following to remove the AIM,Jabber and Yahoo IM . But I am not able to use this to remove the website. Someone please help.               function remove_contactmethods( $contactmethods ) {         unset($contactmethods['aim']);         unset($contactmethods['yim']);         unset($contactmethods['jabber']);         return $contactmethods;     }     add_filter('user_contactmethods','remove_contactmethods',10,1);


title: Retrieving only custom post types with two required terms (from diferente custom taxonomies each)?

text:
I created one custom post type and two custom taxonomies.               register_post_type('blocks',array(            'labels' => array(              'name' => __( 'Blocks' ),              'singular_name' => __( 'Block' ),              'add_new_item' => 'Add New Block',              'edit_item' => 'Edit Block',              'new_item' => 'New Block',              'search_items' => 'Search Block',              'not_found' => 'No Block found',              'not_found_in_trash' => 'No Blocks found in trash',            ),            'public' => true,            'hierarchical' => false,            'taxonomies' => array( 'section'),            'supports' => array('title','editor','thumbnail','custom-fields'),            'rewrite' => array('slug'=>'blocks','with_front'=>false),          ));              register_taxonomy('location','blocks',array(            'hierarchical' => true,            'labels' => array(              'name' => __( 'Location' ),              'singular_name' => __( 'Location' ),              'add_new_item' => 'Add New Location',              'edit_item' => 'Edit Location',              'new_item' => 'New Location',              'search_items' => 'Search Location',              'not_found' => 'No Locations found',              'not_found_in_trash' => 'No Locations found in trash',              'all_items' => __( 'All Sections' ),            ),            'query_var' => true,            'rewrite' => array( 'slug' => 'location' ),            ));          register_taxonomy('section','blocks',array(            'hierarchical' => true,            'labels' => array(              'name' => __( 'Section' ),              'singular_name' => __( 'Section' ),              'add_new_item' => 'Add New Section',              'edit_item' => 'Edit Section',              'new_item' => 'New Section',              'search_items' => 'Search Section',              'not_found' => 'No Sections found',              'not_found_in_trash' => 'No Sections found in trash',              'all_items' => __( 'All Sections' ),            ),            'query_var' => true,            'rewrite' => array( 'slug' => 'section' ),            ));      I'm using the following to retrieve them:               <?php // Create and run custom loop         $custom_posts = new WP_Query();         $custom_posts->query('post_type=blocks&location=Front Page&section=Profile');         while ($custom_posts->have_posts()) : $custom_posts->the_post();     ?>
             <?php the_post_thumbnail('large'); ?>
     <?php endwhile; ?>                   <?php // Create and run custom loop             $custom_posts = new WP_Query();             $custom_posts->query('post_type=blocks&location=Front Page&section=Theme Left');             while ($custom_posts->have_posts()) : $custom_posts->the_post();         ?>
                 <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail(); ?>
<?php the_excerpt(); ?>

         <?php endwhile; ?>      The problem is that any posts that has the custom taxonomy Location = Front Page appear in the first custom loop. It shouldn't. The first custom loop should ONLY retrieve custom posts which has these two terms (from different taxonomies): Location = Front Page and Section = Profile. (If only one term is missing the posts shouldn't be retrieved) Any suggestions?


title: Change theme based on window size

text: I want to send a browser info (window width) to the server via AJAX. The server doesn't need to respond with any data, however, only change the theme based on that window width. This is my attempt: **javascript**               var $ = jQuery;          $(document).ready(function() {              var windowWidth = $(window).width();         var windowHeight = $(window).height();              $.ajax( {           type: "POST",           url: ".../wp-admin/admin-ajax.php",           data: {             action: 'ajax_action',             windowWidth: windowWidth,           },           success: function(data, textStatus, XMLHttpRequest) {             alert('success ' + data); // might not be useful.           },           error: function(XMLHttpRequest, textStatus, errorThrown) {             alert(errorThrown);           }        });          });      **functions.php**               function mmf_enqueue_scripts() {       if( !is_admin() ):         wp_enqueue_script('winsize-detect');       endif;     }     add_action( 'wp_print_scripts', 'mmf_enqueue_scripts' );               function ajax_action() {            if( isset( $_POST['windowWidth'] ) ) {         return $_POST['windowWidth'];       }            return 0;          }               function mmf_change_theme($theme) {            // to make AJAX run only before this function       add_action('wp_ajax_ajax_action', 'ajax_action');       add_action('wp_ajax_nopriv_ajax_action', 'ajax_action');                 $width = ajax_action();       if( $width == 320 ) {         $theme = 'twentytwelve';         // if I echo the width here I get: 3203203203200 (if width=320)       }       else {         $theme = 'twentythirteen';         // if I echo the width here I get: 7707707707700 (if width=770)       }            return $theme;     }          add_filter('template', 'mmf_change_theme');     add_filter('option_template', 'mmf_change_theme');     add_filter('option_stylesheet', 'mmf_change_theme');      I am having hard time dealing with the fact that function `mmf_change_theme` is hooked, so it is called 3 times. Or I am analyzing wrongly. How would you do it? Or how to correct my code. Also you feedback on such a method to serve different themes based on window browser size is appreciated. I prefer not to use a plugin, which exist I know. Thanks.


I am getting the following error when I try to access my Wordpress website. It was working quite fine previously. Could anyone help me on this. > No configuration file found and no installation code available. Exiting...


title: Wordpress 3.5+ upload tool filter

text: i would like to use the brand new wp's upload tool in a personnal theme options page. I found a lot of tutorials like : wp media uploader in plugins ...and it works very fine. But i'd like to filter the file type the end user can select ( and view ). I found many examples that use this way to filter by 'image' type ( param for wp.media object ) :               library:{ type:'image' }      You can see an example here. It works, when the uploader panel appear you only see pictures BUT :   * How can i filter other file types ( documents, zips, videos... ), i tried to replace 'image' by 'video' or 'document' it doesn't work   * When the end user choose to upload a file he can upload any file type instead of an image How can i fixed that ? How to set a filter for one or more specific file types ? Thanks a lot for help.


title: Remove Categories / Tags From Admin Menu

text: I want to remove / hide Categories / Tags submenu under Posts in the Admin Menu. I know this works with themes submenus: `remove_submenu_page('themes.php', 'widgets.php');` but the same doesn't seem to work for posts: `remove_submenu_page('edit.php', 'edit-tags.php');` I'm using the admin_menu action: `add_action('admin_menu', 'function_call')` Do I need to add something else?


title: Theme Check: Could not find post_class

text: I've inherited a theme from a another developer that I've re-styled for a client. We're just about finished, but I thought I'd run it through the Theme- Check plug-in to see if there's any errors or problems. Unfortunately there's a ton. I've gotten rid of most of them, but I have one Required left:               REQUIRED: Could not find post_class. See: post_class      I've read the WP page on post_class, but as a relative newcomer I still don't understand what it is, or why it should be _required_. What should I do to fix this?


title: Getting a specific value out of array using get_attached_media

text: I'm trying to write a piece of code that fetches the url/download link of any embedded audio files in the current post. In doing this I stumbled upon get_attached_media which outputted something like this (I have removed some of the values in order to keep it short):               Array (         [172] => WP_Post Object (              [ID]             => 172              [post_author]    => 1              [guid]           => http://localhost/wp-content/uploads/2013/07/03-take_me_out_128_lame_cbr_ex.mp3              [menu_order]     => 0              [post_type]      => attachment              [post_mime_type] => audio/mpeg          )      )      As you can tell it is all wrapped in this "WP_Post Object". Now, I'm sure this is all common place and fairly simple to resolve, but I can't figure out how. Essentially, what I want to do is to fetch the "GUID" value and attach it to a variable, as it seems to contain the URL of the post's embedded audio file. Also, please correct my terminology so I can make this question more useful to others who migh seek an answer to this.


title: After changing the site root, how to reflect this for wp-admin too?

text: My website file structure is like this:               index.php     wp/wp files ...      In general in Site Address (URL) I have ...site.com In index.php I have:                   define('WP_USE_THEMES', true);         require('./wp/wp-blog-header.php');      Everything works fine but for wp-admin i have ...site.com/wp/wp-admin/ My question is: Can I change the url for wp-admin also to have ...site.com/wp- admin/?


title: Can the_category display a post count?

text: Is it possible for the_category to display a post count within a post. Looks like Posted In: Category Name (3),Category Name (2) etc etc Possible or not? I would just use wp_list_categories but it needs to appear on a post by post basis like this post is posted in category x and y not just all of them...


title: Why does this WPDB code throw an empty WPDB error?

text: I'm writing a feed reader plugin for wordpress. I'm seeing a DB error that I can't figure out. First I create a table called user_entries. Then I put a sample entry into that table. When I try to delete an entry, I get a very strange error in my debug log. There are no foreign keys yet, no indices on the db, etc. > [02-May-2012 11:21:52] WordPress database error for query DELETE FROM > wp_wprss_user_entries   >  WHERE owner_uid = 2 AND feed_id = 2; made by do_action, > call_user_func_array, wprss_unsubscribe_feed, WprssFeeds->remove So what is the error? It's just blank in there. This doesn't look like complicated SQL and it works fine in the phpmyadmin query window. I'm not sure what to do for a next step now, and I'd like folks to be able to unsubscribe from a feed!


title: Remove Slug from Custom Post Type

text: I was wondering how i can remove the prefix from the slugs of custom post types using htaccess rules or any other appropriate method. Currently my custom post types look like this:               http://www.domain.com/os_estate/5-bedroom-property-for-sale      and i would simply like this to be:               http://www.domain.com/5-bedroom-property-for-sale      I was able to achieve this via a plugin but it significantly added to the page load time.. My common settings in Permalinks is set to "Post Name"


title: How to handle multiple instance of "send_to_editor" js function

text:
Here is what I am doing: I Added wordpress media upload with iframe popup when a button or link clicked. And with click of insert into post the image url placed on a textbox. **`send_to_editor()` function handles image insertion to editor**               window.send_to_editor = function(html) {          var imgurl = jQuery('img',html).attr('src');          current_item.siblings('.upload_image').val(imgurl);          current_item.parent().prepend('

');          tb_remove();         }      So, you see the default send_to_editor is edited and changed. Now when i try to upload the image from wordpress editor image uploaded and click insert image to post. It doesn't work. **Question:** How do i multiple instance of `send_to_editor()` or parhaps creating and hook new js function to each instant of image uploader so they don't conflict? **Solution:**               var original_send_to_editor = window.send_to_editor;          window.send_to_editor = function(html) {          var imgurl = jQuery('img',html).attr('src');          current_item.siblings('.upload_image').val(imgurl);          //current_item.siblings('#logo').remove();          current_item.siblings('.image-preview').html('');              tb_remove();          window.send_to_editor = original_send_to_editor;     }


title: Does code in function.php differ from theme to theme

text: I have gone through some tutorials and I found that for every HTML to wordpress theme conversion, they write function.php file. Now I noticed that there is some common lines in that function.php.So is it common line for every theme or is it different ?


title: Woocommerce get attributes of product category

text: I have an Attributes widget that displays product attributes, as an example lets use Color. If on the Shop page the Attributes widget shows all the colors in the attribute taxonomy "pa_color" or to put it another way all the colors for all products. But if you are not on the Shop page but on a product archive page like "Men's Clothing", is there a way to only show Colors that are available to the product category "Mens"               www.yourdomain.com/product-category/mens/      Here is my code to get all the colors from the taxonomy "pa_color"               global $woocommerce, $product, $post;     $attribute_taxonomy_name = $woocommerce->attribute_taxonomy_name( 'color' );     $args = array(         'menu_order'=> 'ASC',     );     $attr_terms = get_terms($attribute_taxonomy_name, $args);      And here is my attempt to only return colors from the current product taxonomy page:               global $woocommerce, $product, $post;          $curr_term = '';     if (is_shop()) {         $curr_term = "shop";     }     else {         $curr_term = get_term_by( 'slug', get_query_var('product_cat'), 'product_cat' );     }     $attribute_taxonomy_name = $woocommerce->attribute_taxonomy_name( 'color' );     $args = array(         'menu_order'=> 'ASC',         'parent'=> $curr_term->term_id,     );     $attr_terms = get_terms($attribute_taxonomy_name, $args);      You will see that I am first getting the product term for the current product archive page and then trying to use its term_id in the 'parent' field for the $args. But this returns empty. Can anyone help point me in the right direction. thanks


title: Wordpress bug 4.0 midia - images

text: hy there, i have the same problem here: ![enter image description here](http://i.stack.imgur.com/uGXLc.jpg) Can some one help here?


title: how to add Jquery script to one page?

text: What is the best practice to apply an individual script to a particular page? When I try to apply the script of the whole page it has problems with other plug-ins. Is there a rule of thumb?


title: WP_Query() and get_posts() can't handle over a thousand posts?

text:
So I have a search function that just fetch custom posts and return them as a list.               function search() {             // post query args         $args = array(             'post_type' => 'post_type',             'posts_per_page' => -1,             'post_status' => 'publish'         );              // markup         $markup = '
';              //the loop         $loop = new WP_Query($args);         while ($loop->have_posts()) {             $loop->the_post();             $markup .= '

';         } wp_reset_postdata();              $markup .='
';              echo $markup;     }      This works with under a hundred posts but with over a thousand posts, it doesn't. It just throws an error. If I switch to get_posts(), the same thing happens. Is there another way I could this?


title: How to Display Network Post Count?

text: Is it possible to display the total post count for all blogs in a Network? `get_blog_count` and `get_user_count` do so for blogs and users, but I can't find any methods to do so for post count.


title: running function during post save and adding variable to post meta

text: I'm creating a page that is pulling info from Vimeo using oEmbed. Everything works fine but the multiple calls to vimeo are causing page load issues (obviously). I was wondering if it would be possible to make the same oEmbed call when the post is being created/saved, then populating various post meta variables with the information.


title: Rename W3 Total Cache admin menu

text: I'm developing a plugin that I'll install for all my clients to make WordPress slightly easier to use for them. One of the things it will change is name of the W3 Total Cache Admin menu from "Performance" to "Ytelse (avansert)". I know how to rename the default admin menus. The code below changes "Posts" to "Nyheter"(News in Norwegian).               function change_post_menu_label_news() {     global $menu;     $menu[5][0] = 'Nyheter';     echo '';     }          add_action( 'admin_menu', 'change_post_menu_label_news' );      I find the ID to change by temporarily using this code:               add_action('admin_init','dump_admin_menu');     function dump_admin_menu() {      if (is_admin()) {     header('Content-Type:text/plain');     var_dump($GLOBALS['menu']);     exit;     }     }      However, it's harder to rename the Performance menu since the ID increments by one when I try to rename it!. W3 Total Cache probably thinks that the ID is taken and tries a higher one. How can I change the name of the W3 Total Cache admin Menu while avoiding this issue and without editing anything related to the plugin?


title: get_the_post_thumbnail not working inside wp_get_nav_menu_items hook

text: if ( ! is_admin() ) {     add_filter( 'wp_get_nav_menu_items', 'display_last_posts_for_menu_item_ts', 10, 3 );     }          function display_last_posts_for_menu_item_ts( $items, $menu, $args ) {          $menu_order = count($items); /* Offset menu order */         $post_ids = array(250,973);         $args = array ( 'include' => $post_ids );         $child_items = array();         foreach ( $items as $item ) {                     foreach ( get_posts( $args ) as $post ) {                 // Add sub menu item                 $img = get_the_post_thumbnail ( $post->id, 'thumbnail' );                 $post_thumbnail_id = get_post_thumbnail_id( $post->id );                 $img .= '<!--' . $post_thumbnail_id . ' / ' . $post->ID . '-->';                 $post->menu_item_parent = $item->ID;                 $post->post_type = 'nav_menu_item';                 $post->object = 'custom';                 $post->type = 'custom';                 $post->menu_order = ++$menu_order;                 $post->title = $img . $post->post_title;                 $post->url = get_permalink( $post->ID );                 /* add children */                 $child_items[]= $post;             }          }         return array_merge( $items, $child_items );     }      I am using this function to add a submenu ( modified from Category menu item and its last 10 posts as sub-menu ). For a reason I cannot understand, I can't get the thumbnails of those posts - although outside this function `get_the_post_thumbnail ( 973, 'thumbnail' );` returns the expected result. Any ideas on this?


title: Embedded tweets get wrapped in <p> tags and fail to load

text: So WordPress should embed tweets in posts just by pasting the tweet url, like so https://twitter.com/cnnbrk/status/496020289277689858 This works great, if you manage to avoid having the url wrapped inside `<p>` tags. By some secret(?) magic you can get a tweet or two to not wrap in `<p>` tags once in a while, but really the post editor is keen on wrapping eveything in `<p>` tags, no matter how hard I try to avoid it: This is what the browser reads and the tweet fails to autoload, only the link is shown as plain text: `<p>https://twitter.com/cnnbrk/status/496020289277689858</p>` This used to work great in older versions, I've been embedding twets for years now, but what has gone wrong in the latest WP versions? How do you avoid having the post editor wrap everything it sees inside `<p>` tags? I am not looking to remove the `<p>` tags altogether, just don't wan't them around the embedded links. Any ideas? Thanks!


title: Non WP Rewrite Rule to Admin Screen using plugin

text: I am creating a plugin that uses the administration screen extensively (adapting a rather complex, MVC program to WordPress for Creative Collaboration). I want do use simple URLs so that when a user goes to `/studio/whatever` the URL is rewritten to the correct admin screen. There is probably a better way to do this. This is the end result that I'm looking for:               www.example.com/studio/whatever/whatever2      gets rewritten to:               www.example.com/wordpress/wp-admin/admin.php?page=_cs&uri=whatever/whatever2      I've actually gotten this to work with the following code:               add_action('generate_rewrite_rules', 'cs_rewrite_rules');            function cs_rewrite_rules() {       global $wp_rewrite;       $new_non_wp_rules = array(         'studio/(.*)'   => 'wordpress/wp-admin/admin.php?page=_cs&uri=$1',       );       $wp_rewrite->non_wp_rules += $new_non_wp_rules;     }      I've used several analyzers and the URL is being rewritten fine. However, when I run it in WordPress, I am redirected to a login screen. The loop is infinite. I never get to the admin panel. However, if I go there directly, everything works wonderfully. There is probably another way to do this. I considered using `template_redirect` or `template_include` as discussed in another thread, but neither of those give me the admin credentials or boot process. How to solve this?


title: Custom styling Insert Media window

text: I would like to alter the styling of the Insert Media window. I'm sure the styling is at wp-includes > css > media-views.min.css I can't alter the minified file. Does anyone know where or how this minified file is referenced in Wordpress. I'd like to change this reference to the non-minifed version and make the alterations. Is this possible ?


title: Wordpress and multisites, the rigth choice?

text: I'm about to start a website, for a non-profit organization, and I need it to be a multi-site platform. I do not know Worpress but I know there is a multi- site option. Thus I'm wondering if Wordpress is the right solution ... So here what I need to support : **[1 platform, 1 community]**   * a single user base, and SSO (1 login to every sites) **[several sites, several looks]**   * each site needs to have his own style (colors, font, images... basically only css imo) **[an accurate permission system]**   * each site needs to have his own administrators (could be 1, or 2 admin per site). Each admin could only manage is own site and should be considered as, more or less, a regular user in others sites.   * each site should has his own usergroups, and admins of the site should be able to manage usergroups and add / remove users. Usergroups need to have permission to view / comment / post content. I'm aware it might not fit all my needs, but I just wondering how difficult is it to achieve that using Worpress : do I need to add tons of modifications or plugins ? Is WP not the best choice to achieve that ? Thanks for your help.


title: How to store the_post_thumbnail() value in a variable

text: As you know the result of the `the_post_thumbnail()` is an image tag. I need this image tag to store at a kind of collection or Array. I'm using the following code but it doesn't help me out. And I want to use it at another place and print out as an image tag.               <?php $tmp_query = new WP_Query('showposts=6');     $counter=0;     while ( $tmp_query->have_posts() ) : $tmp_query->the_post();           $arr[$counter]=the_post_thumbnail();      $counter++;      <?php endwhile;wp_reset_query(); ?>


title: Custom taxonomy subcategories template page

text: I want to create template page on which i could list and display all child categories of my custom category parent! That's the first level, and when those child categories are displayed i would like to link them to a page template where all of the child category **posts** would be displayed! Is this doable? Thanks!


title: How to Include a common category in a custom Category Search

text: I was wondering how to solve this issue. This is my Query:               $query = new WP_Query( array(         'posts_per_page' => 6,         'orderby' => 'date',          'order' => 'DESC',          'category__not_in' => array( 7, 22 ) ) );      This is a simple query, What it does is queries all the recent posts and excludes the posts having category IDs 7 and 22. I have some posts which have two categories linked to it, like, "7 and 10" and "22 and 13". above query excludes these posts too (as it should be), but I also want the query to INCLUDE posts that have two or more categories - one of which might be 7 or 22. I was wondering is it possible? I hope I've explained it. I appreciate any help on this.


title: how to protect wordpress website

text:
i completed my website but i want to protect my site using login option.when i enter my site its goes to login page if user logged in after home page will display.how can do that if there any plugin..... But temporaly i put below code in front-page.php. login option will display overlay of my front page. but its not a correct way. if logged in .logged-in .login_page{display:none;} if i logout #loggedout .login_page{display:block;} in below code " title="Logout">Logout

         <?php if (!(current_user_can('level_0'))){ ?>         <form action="<?php echo get_option('home'); ?>/wp-login.php" method="post">
             <input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="20" />

             <input class='pwd' type="password" name="pwd" id="pwd" size="20" />

             <input type="submit" name="submit" value="Send" class="button" />

                            <input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" />               Remember me             <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>" />
         </form>         <a style="display:none" href="<?php echo get_option('home'); ?>/wp-login.php?action=lostpassword">Recover password         <?php } else { ?>         <a style="display:none" href="<?php echo wp_logout_url(urlencode($_SERVER['REQUEST_URI'])); ?>" id="logoutin">logout
       <?php }?>


title: User Answerable Multiple-Choice Question in Post

text: I am creating a plugin that adds multiple choice questions to WordPress. I wish for several to be displayed in a single post in a manner such that users may select an answer and receive instant feedback as to whether or not they chose correctly, additionally providing a "See Answer & Explanation" link to expand an accordion containing the correct answer and the reasoning behind it. For illustrative purposes, I wish to recreate the functionality that can be observed here. By using some modules I am able to achieve the "See Answer and Explanation" accordion. But when a user clicks on the choices it does not display the adjacent correct or incorrect symbol on my page. How can I achieve this effect?


title: Is this plugin being loaded before file.php, subsequently not allowing me to use certain functions?

text: I'm trying to use `get_home_path()` in my plugin, however, I get a _`call to undefined function`_ fatal error (running Wordpress 3.8). I believe this would imply that my plugin is being loaded before _wp- admin/includes/file.php_ where `get_home_path()` is located, right? Is it just me, or is that a little odd? How can I make file.php load first so I can access this function? The line of code that causes this issue (within my plugin) is:               register_theme_directory(get_home_path().'/material/views');


title: How to get the image sizes, in a function, as per the sizes mentioned in the media settings?

text: I'm making a custom function for my WordPress site.               function mediumFeaturedImage() {         if ( has_post_thumbnail() ) { ?>         <a href="<?php the_permalink(); ?>">             <?php the_post_thumbnail( 'medium' ); ?>                  <?php } else { ?>                                         <img src="<?php echo get_template_directory_uri(); ?>/images/no-image.jpg" alt="No Image Given" width="220" height="145"/>         <?php }     }      I set the `medium` size images to `220 x 145` in `Settings > Media`. But if you look at the default 'no-image' code block here, I used hard-coded numerals as `width="220" height="145"`. But I want to use this function into some other projects of mine. And I won't use the same settings for medium sized images always. It'll be different from site to site. And always I want my code to be dynamic. Therefore I want a code like this:               <img src="<?php echo get_template_directory_uri(); ?>/images/no-image.jpg" width="<?php $getimagesize('medium','width); ?>" height="<?php $getimagesize('medium','height); ?>"/>      It's not mandatory using a function like me. Is there a built-in code like this, that will grab the sizes I assigned in Media settings in WP-Admin, always? Or, by using the `wp_get_attachment_image_src()` how can I grab the width and height of medium size image only, that assigned for medium sized images in Admin panel? Possible?


title: Admin - post order by category and sub category

text: I am trying to get the list of posts ordered in the admin area when sorted by their parent category. Ideally it would sort like this:               parent category 1       -child category 1       --post 1       --post 2       --post 3       -child category 2       --post 1       --post 2       --post 3       parent category 2       -child category 1       --post 1       --post 2       etc. But unfortunately it defaults to sort by the post title when I select to filter by the parent category which makes them not sorted properly. I have looked at this WP SE link thinking it might be the right direction but not sure if that is what I am really looking for. Any suggestions for this or maybe even changing the default sorting that is occuring?


title: How to display data from db in select list

text: I wonder what it's wrong in my code. I can't get all of data in column "adres". In result I only have the lest record. Thanks for help.               global $wpdb;         $result = $wpdb->get_results ("SELECT adres FROM wp_ow_adres;");         foreach ( $result as $result )     echo '<select id="adres" type="text" name="adres">                 <option value="">Select your address</option>                 <option>'.$result->adres.'</option>                 </select>	';


title: How do I troubleshoot slow loading times caused by plugins?

text: I ran the Plugin Performance Profiler plugin and exited after 54 seconds of loading. It looks like these three plugins are the culprits responsible for my site's poor loading times:   * Woocommerce   * Onclick Show Popup   * Post Types Order ![Plugin Performance Profiler results](http://i.stack.imgur.com/xNMF0.png) What are the next steps I should take in troubleshooting this issue?


title: Image URL only for custom navigation walker (walker_nav_menu)

text: I'm attempting to build a custom navigation walker that pulls a page's Featured Image into the page's menu item. I intend to use the Featured Image as a background for the menu item (which is prettier than it sounds). I can get the image itself to be pulled in, but I can't seem to isolate its URL, which I require for the generated inline CSS. I feel as if I'm not understanding the proper way to pull attachment IDs or elements out of their arrays. I've been hitting my head for hours against this problem, even when trying out solutions from similar discussions on Wordpress Answers. But no dice. Here's the code that successfully grabs the thumbnail, but returns a blank when I try to get its URL directly.               $thumbnail_url = '';     if ( has_post_thumbnail( $item->object_id ) ) {                     $thumbnail_img = get_the_post_thumbnail ( $item->object_id );                     $thumbnail_array = wp_get_attachment_image_src( $thumbnail_img );                     $thumbnail_url = $thumbnail_array[0];             }      For reference, here's the construction of code in the start_el function before it:               function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {             $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';                  $class_names = $value = '';                  $classes = empty( $item->classes ) ? array() : (array) $item->classes;             $classes[] = 'menu-item-' . $item->ID;                  $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );             $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';                  $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );             $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';                  $output .= $indent . '';                  $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';             $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';             $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';             $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';      Thanks for anyone's help in advance.


title: Filter by post category in Media Library

text: I am trying to find a way to filter the Media Library by the Post Category that a Media item is assigned with. I can see that you can sort by "attached to" but this only get me a little of the way there. Any suggestions?


title: How to turn this HTML code into a shortcode? (adding song lyrics and giving an id to a div)

text:
STEPS:   1. Don't forget to use different id numbers in each accordion. For example: id="5" (1 to 10)   2. The title goes between the    3. The lyrics before the      4. Place 2 accordions per posts (like the example below). Or they will mess up.
                     There is one obvious advantage:

                             You've seen it coming!
                             Buy now and get nothing for free!
                                  Well, at least no free beer. Perhaps a bear,
                             if you can afford it.

                     Now that you've got...

                             your bear, you have to admit it!
                                  No, we aren't selling bears.

                     Rent one bear, ...

                             get two for three beer.

                                  And now, for something completely different.
                             And now, for something completely different.
                             And now, for something completely different.
                             And now, for something completely different.
                             And now, for something completely different.
                             And now, for something completely different.
                                  And now, for something completely different.
                             And now, for something completely different.
                             Period.

                     There is one obvious advantage:

                             You've seen it coming!
                             Buy now and get nothing for free!
                                  Well, at least no free beer. Perhaps a bear,
                             if you can afford it.

                     Now that you've got...

                             your bear, you have to admit it!
                                  No, we aren't selling bears.

                     Rent one bear, ...

                             get two for three beer.

                                  And now, for something completely different.
                             And now, for something completely different.
                             And now, for something completely different.
                             And now, for something completely different.
                             And now, for something completely different.
                             And now, for something completely different.
                                  And now, for something completely different.
                             And now, for something completely different.
                             Period.

      My client said is too complicated. How can I turn this into a shortcode? **EDIT** This is a jQuery accordion the title goes in the anchor tags and the lyrics before the break tags and the ID of the divs have to change eacdh time.


title: Where is this query?

text: This query given below appears alot in my slow-query log. Can someone please tell me where can I find this query ? that will help me try to modify it               SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND (((wp_posts.post_title LIKE '%true%') OR (wp_posts.post_content LIKE '%true%'))) AND (wp_posts.post_password = '') AND wp_posts.post_type IN ('post', 'page', 'attachment', 'slideshow') AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date DESC LIMIT 0, 10;


title: Adding pagination to a custom template that uses custom post types?

text:
I'm not very familiar with Wordpress' pagination so I'm not sure if this a stupid question. Layout: ![enter image description here](http://i.stack.imgur.com/BOcNb.png) Code:               <?php     /**      * Template Name: Pictures Page      * @package WordPress      * @subpackage Prominent      * @since Prominent 1.0      */     get_header(); ?>

             <?php // Run main loop (The Loop). ?>             <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
                 <?php the_content(); ?>
             <?php endwhile; ?>

                 <?php $custom_posts = new WP_Query(); ?>                 <?php $custom_posts->query('category_name=Pictures'); ?>                 <?php while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?>
                         <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_content(); ?>
                 <?php endwhile; ?>
             <?php get_sidebar(); ?>

     <?php get_footer(); ?>      Don't know how to add pagination, it is out of my comprehension.


title: How do I set the blog name?

text: I am new to WordPress and don't know how to set the "blog name". I need to change a current value that has been coded (or set) somewhere for the home page only. It is appearing in the title, and I don't know how to update it. Thanks.


title: Where do I change the ACTUAL title tag that is set in the header.php

text: I am new to WordPress, and have been asked to change a value in the title tag. The title tag is of the format: "site name | slogan" which is set dynamically in the header.php (seems standard code for WordPress from what I can see from other posts). It is the slogan on the home page only that I need to change. All other pages within the site are ok, I just need to change the home page, and I have no idea if this "slogan" portion of the title is coded somewhere, or set as an attribute etc. Where and how do I change it?? Thanks


title: How to automatically share posts on facebook?

text: Basically, I would like to know how to make a post appear on facebook (like when you press a facebook share button.) the right instant you click 'Publish'?


title: Multiple filter conditions for WP_Query

text: I'm having a hard time figuring out how to accomplish this (really simple) task: > Get 4 random posts, but only select from the 10 most recent posts. This works great for the random part, but obviously selects from all the posts:                   $query = array(             'posts_per_page' => 4,             'orderby' => 'rand',             'post__not_in' =>array($post->ID)         );         $wp_query = new WP_Query($query);      Basically I want to take the results of one query:                   $firstquery = array(             'posts_per_page' => 10,             'orderby' => 'date',             'post__not_in' =>array($post->ID),             'order' => 'DESC'         );      And pass the results into that first one. Any help would be super appreciated. I've looked at merging them but I think that just give me results from both? Little confused.


title: Wordpress custom admin notice still displays after wp_insert_post_data validation

text:
I am trying to validate post data before saving, specifically checking to see if an image exists within the first 750 characters of the post content. The code below works and display the admin notice when an image is present, but after removing the image and clicking "Publish" again, the notice remains (presumably because the query arg is still present). I've tried to remove the filter if no image is found, but the admin notice persists until I save the post a 2nd time.               function my_image_check( $data, $postarr ) {              $img_found = false;              // get the post content         $content = substr( $data['post_content'], 0, 750 );              // check for both image and caption strings         $image_pos = strpos( $content, '<img' );         $caption_pos = strpos( $content, '[caption' );              if( ( $image_pos !== false ) || ( $caption_pos !== false ) ) {             $img_found = true;         }              if( $img_found ) {             $data['post_status'] = 'draft';             add_filter( 'redirect_post_location', 'my_image_redirect_filter', 99 );          } else {             // this doesnt work?             remove_filter( 'redirect_post_location', 'my_image_redirect_filter', 99 );         }              return $data;     }     add_filter( 'wp_insert_post_data', 'my_image_check', '99', 2 );          function my_image_redirect_filter( $location ) {         remove_filter( 'redirect_post_location', __FILTER__, 99 );         $location = add_query_arg ( 'embedded_featured_image', 1, $location );         return $location;     }          function my_post_admin_notices() {              if( !isset( $_GET['embedded_featured_image'] ) )             return;              switch( absint( $_GET['embedded_featured_image'] ) ) {             case 1:                 $message = 'Images cannot appear within the first 750 characters of a post. Please move the image lower in the content area or delete it.';                 break;             default:                 $message = 'Unexpected error';         }              echo '

' . $message . '

';     }     add_action( 'admin_notices', 'my_post_admin_notices' );


title: I am Unable to access WP admin

text: I am unable to access my WP admin. Showing an Error message: > Strict Standards: Only variables should be passed by reference in > /home2/tosaleco/public_html/wp-content/plugins/p3-profiler/p3-profiler.php > on line 50 Here is the line 50               if ( is_admin() && 'admin-ajax.php' == end( explode( '/', $_SERVER['PHP_SELF'] ) ) ) {      I had nil knowledge about PHP. Please let me know what changes in that line will give me access to my WP admin. Will be waiting for the reply.


title: Create a list of posts with topic headdings

text: I would like to use a custom field "topic" to order Wordpress posts. This seems quite doable using               'orderby' => 'meta_value', 'meta_key' => 'topic'      But I would also like to have a title of "topic" at the start of each topic. # topic 1   * post one on topic 1   * post two on topic 1 # topic 2   * post one on topic 2   * post two on topic 2 etc... I was thinking I could have a loop that first gets the posts in order of "topic" displays the "topic" for the first post and then calls my templet to display the rest of the post using.               <?php get_template_part( 'partials/content', 'page' ); ?>      I could get it to continue to do this for all posts but add an if statement that says > "If the 'topic' is the same the topic for the last post do not add a topic > title before posting the post" This is the first time I have tried to come up with something new in Wordpress - not copying and pasting from examples, And I am finding it really hard to do, I just spent 2 day doing code academy PHP to try and figure it out for my self. But it is still causing me problems (complete confusion). Any help would be really appreciated.


title: How to use get_categories results called in header.php on the homepage as well without calling the database twice?

text: I have a Wordpress blog with multiple categories and I have to display the last two posts of certain categories(not all of them) in the header. This is so as to have this information available everywhere, regardless where the user is. But, I also have to display this information on the homepage in a grid format like many other blog themes do on the homepage. I know how to retrieve the data after reading WordPress query for most recent posts from multiple categories, hence calling get_categories, then using for each + get_posts(or wp_query) in the loop. My issue is more performance related because if I'm not wrong, for FIVE featured categories, I have to call: **2 x get_categories** (1x in header and 1x in HP)   **10 x get_posts** (5x in header and 5x in HP, one for every featured category) Can this be avoided by accessing the same data in the header.php file as well as on the homepage file without calling the database multiple times? That is, is there a way to call get_categories and get_posts ONCE in the header and then re-use the same, exact resultset later on in the homepage? As a performance maniac, if I can reduce the 12 database calls to 6, I will be a happy man. **EDIT:** Having tested out some caching techniques in the last hour or so, this is the final code I ended up with in both PHP files:               <!-- Check cache, if empty, retrieve data and cache it else use it from cache -->     <?php         $allPosts = wp_cache_get( 'allPosts' );              if ( false === $allPosts )         {             $args = array('cat' => 3);             $allPosts = new WP_Query($args);             wp_cache_set( 'allPosts', $allPosts );         }      ?>          <!-- Loop them -->     <?php         while($allPosts->have_posts()) : $allPosts->the_post();             the_title("<br />");         endwhile;     ?>                Does it make sense? Thank you.


title: How can i identify media uploaded to my website that is not being used anywhere anymore?

text: At the time of development i upload a lot of images on the site. Over the time, i may need to tweak it quality or resolution, so mostly i upload the images with same name. So by the end of the development, i have a lot of similar images, only 1 of them being in use somewhere. How can i identify the unused ones and delete them from my server?


title: Filtering WP_Query result by category

text: Using WP_Query, I need to gather a selection of posts that are **both** Category1 and Category2. I want this selection to include Category1 and all of its subcategories (Category3 and Category4), as long as they are also labeled Category2, **even if** they aren't labeled Category1.               Categories:          Name          ID     Parent     Category1     1     Category2     2     Category3     3      1     Category4     4      1          Posts:          ID     Categories     1      1,2     2      2,3     3      2,4                Now, if I were to use WP_Query to find posts in just Category1 it seems to find all three posts including Post2 and Post3 since Category3 and Category4 are subcategories of Category1 even though the posts aren't Category1.               new WP_Query(             array(                 'cat_id' => 1             )      However, if I use 'category__and' to find posts that are both Category1 and Category2               new WP_Query(             array(                 'category__and' => array(1, 2)             )      it only finds Post1 that has both Category1 and Category2, but it won't find Post2 that is Category2 and Category3 or Post3, even though Category3 and Category4 are subcategories of Category1. Is there a way I can take the result of this:               new WP_Query(             array(                 'cat_id' => 1             )      And then filter it to only include those posts that also are Category2? Thanks for any suggestions.


title: Enclosing Shortcode is acting like self-closing

text:
I'm sure I'm missing something simple, as I rarely use shortcodes, but I can't seem to get the following shortcode to work. I want it to be an "enclosing" short tag vs. a "self-closing", but its being treated as the latter.               [bio_image name="my name" title="my title"]     //image media in post content     [/bio_image]      with this functions.php code:               function bio_image_func( $atts, $content = null) {         extract( shortcode_atts( array(             'name' => 'employee',             'title' => 'mastermind',         ), $atts ) );         return '

' . $name . ' ' . $title . '
' . $content . '
';     }          add_shortcode( 'bio_image ', 'bio_image_func' );         produces:

         my name          my title

                    [/bio_image]      As you can see, the closing tag is just being printed out. Any suggestions? for reference: the shortcode codex page


title: user login and its profile

text: i want login, logout and view profile functionality. i am currently able to login the user and redirect them to home page of website. i want to show loggedin users name on menu and a logout link. for getting username of currently logged user i tried this:http://codex.wordpress.org/Function_Reference/wp_get_current_user but not able to get the username. for login/logout link i used this code in functions.php               add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);     function add_login_logout_link($items, $args) {         ob_start();         wp_loginout('index.php');         $loginoutlink = ob_get_contents();         ob_end_clean();         $items .= '<li>'.  $loginoutlink .'</li>';         return $items;      }


title: How can I get the Jetpack Image plugin to open links in a new window?

text: The Jetpack image widget does not offer a target option for links. Is there a way to open all Jetpack image widget links in a new window without hacking the plugin? Like through a hook or function?


title: Get first menu item of custom menu

text: Let's assume the client builds a custom menu with 3 menu items and I'd like to show a few posts, then the first menu item, then some more posts, the second menu item, more posts and then the third menu item. Is there any special function to retrieve only the link of the first menu item? Example menu:               - HOME     - ABOUT     - CONTACT      How can I get the link of the "HOME" menu item from a custom menu (Appearance -> Menu)?


title: How to generate and display widgets areas dynamically?

text: I want display different content in sidebar for every category, but as I create new ones I have to create the area for it. How can I have widget areas for every category and also display them on theme accordingly?


title: Need help getting this page nav working correctly

text:
For some reason the page nav doesn't work correctly. It's styled odd on the home page (http://noahsdad.com/), then if you go to a page (say page 2 for instance, http://noahsdad.com/page/2/) you'll see it really looks odd. I can't figure out what's happening. If anyone has any ideas I'd appreciate it. Thanks. Here is the code from my pagination.php               <?php if( is_single() ) { ?>
                  <?php $pagination_width = 'full_width_layout' == $options['layout'] ? 'span6' : 'span4'; ?>                  <?php previous_post_link( '%link', _x( '← %title', 'standard' ) ); ?>                  <?php if( '' == get_previous_post() ) { ?>                 <?php next_post_link( '%link', _x( '%title →', 'standard' ) ); ?>             <?php } else { ?>                 <?php next_post_link( '%link', _x( '%title →', 'standard' ) ); ?>              <?php } // end if/else ?>
          <?php } elseif ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) { ?>

                      <?php if( get_next_posts_link() ) { ?>
                         <?php wp_pagenavi(); ?>
                                    <?php } // end if ?>                      <?php if( get_previous_posts_link() ) { ?>
                         <?php wp_pagenavi(); ?>
                 <?php } // end if ?>

          <?php } // end if/else ?>


title: Trying to retrieve post meta

text: I have created a meta box that allows users to add an additional name/id to their post. From what I can tell it is adding the meta information correctly because when I edit a post that has a custom name/ID it shows up in the input box by default as it should. So my issue is that I am trying to pull the custom ID/name and use it as an additional ID tag in the code. Although it is not retrieving anything. When I use the code in my theme and check the html on the page the ID is showing ID="". So for some reason it is not pulling anything. Can anyone see an issue?               <?php $post_id = get_the_ID(); ?>         <?php $value = get_post_meta($post_id, 'newtheme_section_id'); ?>         <id="<?php $value; ?>">      If I change get_the_ID() to the_ID() then it returns a value but it is the post ID instead of the custom id the user entered into the feild. EDIT: I was able to figure it out by echoing the function instead of storing it in a variable, along with Mannys suggestion . Here is the updated code.               <?php $post_id = get_the_ID(); ?>     <id="<?php echo esc_attr( get_post_meta($post_id, 'newtheme_section_id', true) ); ?>">


title: How can I create a menu items from meta box based on users input

text: I have created a metabox that takes a name that the user can give as an additional name of their post. I am wondering how I can automatically create a menu item based on the name the user input into the metabox, and set the url to #PostName? Even if someone could guide me in the right direction on creating the menu item from a metabox on the post screen I could figure out the rest. **EDIT:** I have added some extra info since I understand it seems a little confusing to someone who has know idea of why I want this. I am creating a custom theme with the html5 boilerplate. It is a one page theme that users add sections to the page by adding posts. The theory is the user adds a custom name to the post into a meta box on the page and it will add the menu item with that name. Since the meta box I created already adds an ID in the html of each post with an additional ID tag the url for the menu will be #PostName. This is so when the user clicks the menu item it will automatically scroll right to the section. In most themes the Nav menu brings you to a different page. Since my theme is only a one page theme the nav links will bring the user to the section on the page. All I am trying to accomplish is to add some automation in the theme so the users don't need to add the menu items manually.


title: Remove comma from last item output from loop

text: (or add comma to all items but the last one...) Most of the information I have found relates to using a counter within a `foreach` loop. In this particular situation I am using Advanced Custom Fields and I am within a standard loop, not a `foreach` loop. I need to add a comma to the end of each item except the last.               <?php while( has_sub_field('images') ): ?>         <?php $image = wp_get_attachment_image_src(get_sub_field('image'), 'wsn_canvas'); ?>         <?php echo $image[0]; ?>         //echo comma here     <?php endwhile; ?>


title: Cache plugin for medium traffic news blog

text: I have a middle-low traffic blog. Server is lite speed based. And ping values 20-25 MS for my Country ( this blog not global,just for my Country ) I want to Install a light cache plugin... Which cache plugin can you suggest for me? Thanks and sorry my bad English,good days.


title: Including one page with WordPress functions into another

text:
I have two php pages, one is the main page that will hold all of my content. The second page is a whole bunch of php (that I have written as well as included wordpress functions) and js functions. Lets say the container php file is Container.php The included file is IncludedFile.php I am including IncludedFile.php into Container.php by using `include_once('IncludedFile.php');` When the Included file gets called onto my container page none of the WordPress functions that I have included work. For example, the first function on the IncludedFile.php gets the current user: `$current_user = wp_get_current_user();` The next line down pulls a meta field from the current user to display on the page, but it is returning null. `echo $current_user->favorite_color;` Is the reason the wordpress functions are not working is the way that I am including my file into the other? Or is it a larger problem all together? * * * **Edit** I've since added my `require('IncludedFile.php');` into my functions.php file so that I can include that file onto every page of my site. Sample Code: **Functions.php Function**               function display_content_on_all_pages() {         if ( is_user_logged_in() ) {             echo '
';                 require('IncludedFile.php');             echo '
';         } else {             echo 'Your not logged in....';         }            }     add_action('wp_footer','display_content_on_all_pages');      **IncludedFile.php**               <?php        $current_user = wp_get_current_user();       if ( $current_user->user_login == 'TestUser' ) {         echo 'You are TestUser';       } else {         echo 'You are not TestUser';       }     ?>


title: How to prepare SimplePie_Item's get_date() for l10n?

text: I'm trying to improve the localization of the Bones theme. On the admin side it provides an RSS widget which uses the following code:               <?php        echo $item->get_date('j F Y @ g:i a');     ?>      This uses SimplePie, here's the doc for the method. Which would be the best way to make this translatable?


title: Why is my custom post query shortcode only showing 1 post?

text:
I created a shortcode for a custom post type so I can show the posts in a page. It works, except it only shows 1 post. here the code... anyone know what's wrong?               // this is the shortcode function which includes the query      function ea_get_location($atts){        extract(shortcode_atts(array(           'destination' => null,           'posts' => '10'             ), $atts));          $ea_params = array(       'post_type'=>'itineraries',       'posts_per_page' => $posts,       'tax_query' => array(         array(           'taxonomy' => 'location',           'field' => 'slug',           'terms' => $destination           ))       );          query_posts( $ea_params );           while (have_posts()) : the_post();          $ea_var = '
';     $ea_var .= '';     $ea_var .= '';     $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'itinerary-thumb' );     $thumb_url = $thumb['0'];     $ea_var .= '';     $ea_var .= '
';     $ea_var .= '';      $ea_var .= get_the_title();     $ea_var .= '

';     $ea_var .= get_the_excerpt();     $ea_var .= '

';                 endwhile;         // Reset Query     wp_reset_query();     // return the variable for use in the shortcode     return '
'.$ea_var.'
';     }          // register the function as a shortcode     function register_shortcodes(){        add_shortcode('location', 'ea_get_location');     }     ?>      Here is the new updated code               // this is the shortcode function which includes the query      function ea_get_location($atts){        extract(shortcode_atts(array(           'destination' => '',           'posts' => -1             ), $atts));          $ea_params = array(       'post_type'=>'itineraries',       'posts_per_page' => $posts,       'tax_query' => array(         array(           'taxonomy' => 'location',           'field' => 'slug',           'terms' => $destination           ))       );          // The Query     $ea_itin_query = new WP_Query( $ea_params );          $ea_var = '';          while ($ea_itin_query->have_posts()) : $ea_itin_query->the_post();          global $post;          $ea_var .= '
';     $ea_var .= '';     $ea_var .= '';     $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'itinerary-thumb' );     $thumb_url = $thumb['0'];     $ea_var .= '';     $ea_var .= '
';     $ea_var .= '';      $ea_var .= get_the_title();     $ea_var .= '

';     $ea_var .= get_the_excerpt();     $ea_var .= '

';             endwhile;          // Reset Post Data     wp_reset_postdata();          // return the variable for use in the shortcode     return '
'.$ea_var.'
';     }          // register the function as a shortcode     function register_shortcodes(){        add_shortcode('location', 'ea_get_location');     }     ?>


title: Internationalize / translate custom post types & taxonomies

text: I've created custom post type and taxonomy via generator, but not quite sure how to make it translatable. Google doesn't help in this. I have no idea where to put text-domain here and things what I've tried made taxonomies don't work at all. Thanks in advance. The code:                   add_action( 'init', 'register_cpt_portfolio' );         function register_cpt_portfolio() {                  $labels = array(                  'name' => _x( 'Portfolios',  'portfolio'),                 'singular_name' => _x( 'single-portfolio',  'portfolio' ),                 'add_new' => _x( 'Add New', 'portfolio' ),                 'add_new_item' => _x( 'Add New Portfolio', 'portfolio' ),                 'edit_item' => _x( 'Edit Portfolio',  'portfolio' ),                 'new_item' => _x( 'New Portfolio', 'portfolio' ),                 'view_item' => _x( 'View Portfolio',  'portfolio' ),                 'search_items' => _x( 'Search Portfolios',  'portfolio' ),                 'not_found' => __( 'No portfolios found',  'portfolio' ),                 'not_found_in_trash' => _x( 'No portfolios found in Trash',  'portfolio' ),                 'parent_item_colon' => _x( 'Parent Portfolio:', 'portfolio' ),                 'menu_name' => _x( 'Portfolio',  'portfolio' ),             );                  $args = array(                  'labels' => $labels,                 'hierarchical' => false,                 'supports' => array( 'title', 'editor', 'thumbnail' ),                 'taxonomies' => array( 'portfolio_taxonomy' ),                 'public' => true,                 'show_ui' => true,                 'show_in_menu' => true,                 'show_in_nav_menus' => true,                 'publicly_queryable' => true,                 'exclude_from_search' => false,                 'has_archive' => true,                 'query_var' => true,                 'can_export' => true,                 'rewrite' => true,                 'capability_type' => 'post'             );                  register_post_type( 'portfolio', $args );         }                       add_action( 'init', 'register_taxonomy_portfolio_taxonomy' );              function register_taxonomy_portfolio_taxonomy() {                  $labels = array(                  'name' => _x( 'Portfolio Categories',  'portfolio_taxonomy' ),                 'singular_name' => _x( 'Portfolio Category', 'portfolio_taxonomy' ),                 'search_items' => _x('Search Portfolio Categories',  'portfolio_taxonomy'),                 'popular_items' => _x( 'Popular Portfolio Categories',  'portfolio_taxonomy' ),                 'all_items' => _x('All Portfolio Categories', 'portfolio_taxonomy' ),                 'parent_item' => _x('Parent Portfolio Category',  'portfolio_taxonomy' ),                 'parent_item_colon' => _x( 'Parent Portfolio Category:',  'portfolio_taxonomy' ),                 'edit_item' => _x( 'Edit Portfolio Category', 'portfolio_taxonomy' ),                 'update_item' => _x( 'Update Portfolio Category', 'portfolio_taxonomy' ),                 'add_new_item' => _x( 'Add New Portfolio Category', 'portfolio_taxonomy'),                 'new_item_name' => _x( 'New Portfolio Category',  'portfolio_taxonomy' ),                 'separate_items_with_commas' => _x( 'Separate portfolio categories with commas', 'portfolio_taxonomy'),                 'add_or_remove_items' => _x( 'Add or remove portfolio categories',  'portfolio_taxonomy' ),                 'choose_from_most_used' => _x( 'Choose from the most used portfolio categories', 'portfolio_taxonomy' ),                 'menu_name' => _x( 'Portfolio Categories','portfolio_taxonomy'),             );                  $args = array(                  'labels' => $labels,                 'public' => true,                 'show_in_nav_menus' => true,                 'show_ui' => true,                 'show_tagcloud' => true,                 'hierarchical' => true,                 'rewrite' => true,                 'query_var' => true             );                  register_taxonomy( 'portfolio_taxonomy', array('portfolio'), $args );         }


title: Looking for Hook that is fired after a plugin or wp upgrade is installed/updated

text: I'm trying to write some code to sms me whenever someone updates/installs a plugin, or updates the WP core, but I can't seem to find a hook that gets fired when this happens. Does anyone know if there are any hooks that I can plug into that will get fired when this happens? Thanks!


title: Can upload doc and pdf but not ppt - not permitted for security reasons

text: "Insert search engine here" was pretty useless for this one - I've had a look through `wp-includes/functions.php`, `wp-admin/includes/file.php` etc. but not found a reason for the behaviour I'm getting. I'm running multisite, and when I upload a .doc or .pdf I don't have a problem. When I upload a .ppt - regardless of the actual filename or mimetype (i.e. a .ppt renamed to .txt, a .txt renamed to .ppt) - I'm told "Sorry,this file type is not permitted for security reasons" with little other explanation. Do I need to modify the mimes table, add an override (and if so, what's the syntax for this), or is it something in my Apache conf? I've done some funny fiddling to try and lock things down in a few places, possibly blocking .pot files.


title: Add BuddyPress Profile Menu Item

text: In BuddyPress, when a user clicks on their username, they are presented with a page that contains a menu:               Activity     Profile     Messages     Friends     Groups     Settings      How do I add an item to this menu? How do display this menu inside my template? (The default page template only displays the main navigation.)


title: Why is wp-login redirecting to the home page when I use this function?

text: I'm perplexed; I can't see where I'm going wrong with this code. It should redirect any subscriber-level users back to the site home page if they try to access anything within /wp-admin - but _not_ if they try to go to /wp- login.php :               // REDIRECT ALL 'SUBSCRIBER' USERS TO SITE HOME PAGE IF THEY TRY TO ACCESS WP-ADMIN     add_action( 'init', 'blockusers_init' );     function blockusers_init() {         if ( !current_user_can( 'edit' ) && is_admin() ) {             wp_redirect( home_url() );             exit;         }     }      I tried using the role instead of capability (`'subscriber'` instead of `'edit'`), and that worked when I was on a single-site installation of WordPress - but this theme is now being used in a multisite/subfolder installation and for some reason the role doesn't work. Using the code above, anytime a subscriber goes to either /wp-admin or /wp-login.php they get redirected to the home page. Any ideas? Thanks for your help!