Showing different posts on category pages

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;?>


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

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?


Removing "Website" Field from the contact info

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);


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

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?


Change theme based on window size

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...


Wordpress 3.5+ upload tool filter

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.


Remove Categories / Tags From Admin Menu

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?


Theme Check: Could not find post_class

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?


Getting a specific value out of array using get_attached_media

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.


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

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/?


Can the_category display a post count?

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...


Why does this WPDB code throw an empty WPDB error?

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!


Remove Slug from Custom Post Type

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"


How to handle multiple instance of "send_to_editor" js function

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;     }


Does code in function.php differ from theme to theme

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 ?


Woocommerce get attributes of product category

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


Wordpress bug 4.0 midia - images

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


how to add Jquery script to one page?

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?


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

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?


How to Display Network Post Count?

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.


running function during post save and adding variable to post meta

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.


Rename W3 Total Cache admin menu

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?


get_the_post_thumbnail not working inside wp_get_nav_menu_items hook

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?


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

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!


Non WP Rewrite Rule to Admin Screen using plugin

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?


Custom styling Insert Media window

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 ?


Wordpress and multisites, the rigth choice?

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.


How to store the_post_thumbnail() value in a variable

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(); ?>


Custom taxonomy subcategories template page

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!


How to Include a common category in a custom Category Search

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.


how to protect wordpress website

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 }?>


User Answerable Multiple-Choice Question in Post

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?


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

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');


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

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?


Admin - post order by category and sub category

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?


How to display data from db in select list

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>	';


How do I troubleshoot slow loading times caused by plugins?

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?


Image URL only for custom navigation walker (walker_nav_menu)

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.


Filter by post category in Media Library

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?


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

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.


Where is this query?

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;


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

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.


How do I set the blog name?

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.


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

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


How to automatically share posts on facebook?

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'?


Multiple filter conditions for WP_Query

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.


Wordpress custom admin notice still displays after wp_insert_post_data validation

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' );


I am Unable to access WP admin

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.


Create a list of posts with topic headdings

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.


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

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.


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

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?


Filtering WP_Query result by category

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.


Enclosing Shortcode is acting like self-closing

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


user login and its profile

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;      }


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

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?


Get first menu item of custom menu

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)?


How to generate and display widgets areas dynamically?

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?


Need help getting this page nav working correctly

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 ?>


Trying to retrieve post meta

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) ); ?>">


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

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.


Remove comma from last item output from loop

(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; ?>


Cache plugin for medium traffic news blog

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.


Including one page with WordPress functions into another

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';       }     ?>


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

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?


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

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');     }     ?>


Internationalize / translate custom post types & taxonomies

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 );         }


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

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!


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

"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.


Add BuddyPress Profile Menu Item

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.)


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

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!


Bizarre Permalinks Issue: 404 Errors Everywhere

First and foremost, this is definitely a duplicate of the age old question of "my Wordpress permalinks are generating 404 errors", but in a way it's different because no solutions I've tried have worked. **A little back-story to my problem:** I developed a Wordpress site locally, all permalinks and everything worked. I installed a new copy of Wordpress on the server, imported all of my local posts and everything on the homepage looked great, this is where the greatness ends. None of the permalinks work, the pages, posts (all posts are using custom post types), they all give me the message: **"Not Found The requested URL /content/we-need-to-talk-about-kevin/ was not found on this server."** The post type this post belongs to is called: "sketcphad" however I have a rewrite on my register_post_type function that makes it "content" which definitely works locally, so that's not the issue. **Things that I have tried:**   1. Manually replacing the .htaccess rewrite rules, then deleting it and re-adding it in again   2. Adding in flush_rewrite_rules() into my functions.php file   3. Visiting the settings -> permalinks page, then clicking save   4. Trying another permalink structure (currently it's /%postname%) I tried a few others to no avail   5. Tried deleting the content and re-adding it in manually   6. Tried re-adding in the pages manually The puzzling thing about this situation is the site works locally, what could be happening on my server to cause these issues? The server is running basically the same LAMP environment with exception my local LAMP environment is using XAMPP on Windows, but I've moved plenty of sites from local to a remote server without an issue like this. What am I not seeing? **See below for my functions.php code that registers the post types.**               function sketchpad_posttype()     {         // Labels for our custom post type         $labels = array(             'name' => _x('Content', 'sketchpad'),             'singular_name' => _x('Content Entry', 'sketchpad'),             'add_new' => _x('Add New', 'Content Entry'),             'add_new_item' => __('Add Content Entry'),             'edit_item' => __('Edit Content Entry'),             'new_item' => __('New Content Entry'),             'view_item' => __('View Content Entry'),             'search_items' => __('Search Content Entries'),             'not_found' =>  __('Nothing found'),             'not_found_in_trash' => __('Nothing found in Trash'),             'parent_item_colon' => ''         );              // Arguments that specify how we use our custom post type         $args = array(             'labels' => $labels,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,             'query_var' => true,             'menu_icon' => get_stylesheet_directory_uri() . '/images/icons/notepad.png',             'rewrite' => array('slug' => 'content'),             'capability_type' => 'post',             'hierarchical' => false,             'menu_position' => null,             'supports' => array('title','editor', 'thumbnail'),             'taxonomy' => array('category')         );              // Call the register_post_type function and make it official         register_post_type( 'sketchpad' , $args );     }          function article_posttype()     {         // Labels for our custom post type         $labels = array(             'name' => _x('Articles', 'article'),             'singular_name' => _x('Article', 'article'),             'add_new' => _x('Add New', 'Article'),             'add_new_item' => __('Add Article'),             'edit_item' => __('Edit Article'),             'new_item' => __('New Article'),             'view_item' => __('View Article'),             'search_items' => __('Search Articles'),             'not_found' =>  __('Nothing found'),             'not_found_in_trash' => __('Nothing found in Trash'),             'parent_item_colon' => ''         );              // Arguments that specify how we use our custom post type         $args = array(             'labels' => $labels,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,             'query_var' => true,             'menu_icon' => get_stylesheet_directory_uri() . '/images/icons/notepad.png',             'rewrite' => array('slug' => 'article'),             'capability_type' => 'post',             'hierarchical' => false,             'menu_position' => null,             'supports' => array('title','editor','thumbnail'),             'taxonomy' => array('category')         );              // Call the register_post_type function and make it official         register_post_type( 'article' , $args );     }          // Register our custom post types     add_action('init', 'sketchpad_posttype');     add_action('init', 'article_posttype');


Menus - Open items in new tab/window?

I have 3.1.2 running with the Boldy theme. Site link. I have a menu that has a number of external links listed in the items.   By default, these items do NOT load in a new tab/window. There is no option in the Admin --> Appearance --> Menus, to tick a box to say open in new window. How do I get them to do this?


Why not working jquery show() function in wordpress?

I try create a quick comment form on my wordpress with a link like this: ![enter image description here](http://i.stack.imgur.com/vKDGW.jpg) My plan is when you click this link,you get a comment form with jquery show() function, where you can add a comment in ajax.   jquery:                $.noConflict();      jQuery( ".comment-mezo" ).click(function() {      jQuery( "#comment-mezo" ).show( "slow" );     });      html:               Quick comment
       <textarea id="comment"></textarea>
        <input type="submit">
      This function work outside wordpress(i tryed it on jsbin), but inside not.   Why?   We know this thanks for Rares P and sri.:   The jquery is loaded and working.   The id change not help.   The show.js is loaded when the paged is loaded.   And we use this for the script load:               <?php        function show() {       wp_enqueue_style( 'style-name', get_stylesheet_uri() );       wp_enqueue_script( 'script-name', get_template_directory_uri() . '/show.js', array() );        }        add_action( 'wp_enqueue_scripts', 'show' );?>


get a list of all registered actions

i'm trying to debug a plugin which i didn't create and i want to list all registered actions. i read this http://stackoverflow.com/questions/5224209/wordpress-how-do-i-get-all-the- registered-functions-for-the-content-filter but it's specific to one hook and it's about filters, not actions. Is there any variable like $wp_filter or something?


Post thumbnail dependant on category

I have two categories (our work and news) and only one single.php If looking at a single post in the news category then I want to show the thumbnail too so have inserted: `<?php if ( has_post_thumbnail() ) {the_post_thumbnail('medium');} ?>` But I dont want this to appear if viewing a single post within the our work category, what can I add to remove this for category ID#2?


Can You Require the Use of JavaScript in a WordPress Plugin?

I commonly use Mozilla Firefox for testing changes I make for a plugin that I'm developing. I also have the NoScript addon installed because it is also my main browser. I noticed that the Administrative menu in WordPress not only is missing icons ( I get the boxes with numbers which indicates that I failed to load the font icon set ), but completely fails to show when I click the appropriate menu button ( muscle memory ). I am assuming that this means the menu fails to work with JavaScript. Now, does this mean I can therefore require JavaScript for the administrative end of my plugin? What if I decide to use Ajax? Or, how about the end-user side; can I require JavaScript there? My main concerns for these questions lies in accessibility and compatibility...


get_results suddenly not working on a single table

I'm trying to get a list of rows from the DB. All tables work except the one I need. No errors are thrown, don't even get a blank array. My SELECT statement works fine in phpmyadmin directly, but not through Wordpress. Any ideas what might be going on? Its driving me nuts.               $wpdb->get_results("SELECT * FROM  properties")


child_of not working while searching

I'm trying to limit search to a parent page and its own child pages. I've changed searchform.php adding this code:               <input type="hidden" value="<?php         global $post;         $ancestors2 = $post->ancestors;         if ($ancestors2) {             echo end($ancestors2);         } else {             echo $post->ID;         } ?>" name="childof" />      Also I've add a function to my theme's functions.php:               function SearchFilter($query) {     if (is_search() && !empty($_GET['s']) && !empty($_GET['childof'])) {         $parent_page_id = intval($_GET['childof']);         $query->set('child_of', $parent_page_id );     }     return $query;     }     add_filter('pre_get_posts','SearchFilter');      I've tested variables with `var_dump($query)` and it returned:               ["child_of"]=>         int(104)      But, I still can see search results from other pages and not only from parent page (or its child pages). Why? Thanks!


ID of Front-Page

I like to get the ID of the selected front page. My page uses an Template for that page. I've read about `get_option('page_on_front')`, but this didn't work for me. Is there any function to get this ID?


custom post type template changes between preview and publish

I have set up a custom post titled `project` where I have also set a theme file `page-project.php`. When I create a post under that custom post type, and I preview it, it shows on the using the `page-project.php` template, however once I publish it and view the page, it uses the `index.php` template. Can someone tell me why this is happening? This is my custom post type from `functions.php` FYI: just found this out, if I turn permalinks to default settings, it uses the correct template as well.               add_action('init', 'project_register');      function project_register() {         $labels = array(             'name' => _x('My Projects', 'post type general name'),             'singular_name' => _x('Project', 'post type singular name'),             'add_new' => _x('Add New', 'project item'),             'add_new_item' => __('Add New Project Item'),             'edit_item' => __('Edit Project Item'),             'new_item' => __('New Project Item'),             'view_item' => __('View Project Item'),             'search_items' => __('Search Project'),             'not_found' =>  __('Nothing found'),             'not_found_in_trash' => __('Nothing found in Trash'),             'parent_item_colon' => ''         );         $args = array(             'labels' => $labels,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,             'query_var' => true,             'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',             'rewrite' => true,             'capability_type' => 'page',             'hierarchical' => false,             'menu_position' => null,             'supports' => array('title','editor','thumbnail','author')           );              $labels = array(         'name' => _x( 'Project Types', 'taxonomy general name' ),         'singular_name' => _x( 'Project Type', 'taxonomy singular name' ),         'search_items' =>  __( 'Search Project Types' ),         'all_items' => __( 'All Project Types' ),         'parent_item' => __( 'Parent Project Type' ),         'parent_item_colon' => __( 'Parent Project Type:' ),         'edit_item' => __( 'Edit Project Type' ),          'update_item' => __( 'Update Project Type' ),         'add_new_item' => __( 'Add New Project Type' ),         'new_item_name' => __( 'New Project Type Name' ),         'menu_name' => __( 'Project Type' ),       );          register_taxonomy('project_type',array('project'), array('hierarchical' => true,         'labels' => $labels,         'show_ui' => true,         'query_var' => true,         'rewrite' => array( 'slug' => 'type' ),));         register_post_type( 'project' , $args );     }


Custom Rewrite for Profiles

I'm currently trying to modify my rewrites to allow for an additional URL segment e.g. http://example.com/vendors/username/ by default WP allows for additional numeric segments but everything else returns a 404 error. e.g. http://example.com/vendors/test. I'm curious as how I would go about allowing URL's like these. My current structure is: http://example.com/vendors/?username=example It should be: http://example.com/vendors/username AND/OR http://example.com/username But it still has to serve the original page: http://example.com/vendors/username/ I've previously examined this article, but still couldn't sort it out: http://www.hongkiat.com/blog/wordpress-url-rewrite/


How to run multiple websites from single WordPress setup

I want to create a website like visahq.com in WordPress, actually visahq.com has multiple websites like visahq.in for India, visahq.ru(will be shown in Russian) for Russia etc. and each TLD has multiple sub-domains like visahq.in has a sub-domain for Australia http://australia.visahq.in/ like on for each country. Content of all websites are almost same with some changes based on conditions. My problem is I want to manage all TLD and sub-domains on a single WordPress setup how can I do this with WordPress.


Wordpress get the latest plugin installed details

I dont know which plugin is giving the error "bp_setup_current_user was called incorrectly" calling before the buddypress installed. How can I get the details of latest plugin installed in the wordpress?


How to make javascript work on theme options page

Gentlemen! I'm composing a theme options page for my WP theme. And I bumped into the problem of finding the proper way to introduce inline jQuery interactions to the page. Ideally for me in the situation will be inline jQ code               <script type="text/javascript">         $(document).on({             ready: function(){                 alert('Hey!');             }         })     </script>      But this code fails because I guess the admin options page is rendered before the jQuery is included so js generates expected error. The same code with no jQ identifiers works ok means I get alert window when introduce:               <script type="text/javascript">          alert('Hey!');     </script>      Question is how to properly introduce inline js containing jQ (or any other framework) syntax and make it work?