Custom post type with a forced fixed aspect ratio image crop

What I am looking for is similar to a couple other questions. The links are: Creating an Image-Centric Custom Post Type? Using Default WordPress Custom Header Image Crop Feature in a Post Type / MetaBox I am looking for a sort of combination of the two. I'll explain so you don't have to look up these other questions. I would like a user to be able to upload a picture into a custom post type and be prompted to crop the image with a set aspect ratio before saving. I am trying to keep users from needing to crop images outside WordPress just to make them fit into a slideshow with a set image size. The custom header functionality is pretty much what I'd like to use, but I am at a loss on how to pull that into either a plugin or a theme and have it execute in a custom post type. The fact that the user is **asked to crop the image at a set ratio** before proceeding **is key**. I am fairly comfortable with custom post types if anyone can just give me a pointer on how to get WordPress to force a custom cropping of an image before saving the custom post. Thanks in advance to whichever one of you coding geniuses knows/figures out how to do this.


Add custom CSS in WordPress Page

I am new on wordpress. I am admin in a wordpress site and I don't have access to the theme. I want to create a new blog page where I include a new css code. I tried to add on the text editor:               <style>     my css code     </style>          <div>     .....my html part...     </div>      But it didn't work. I can see the html part without the extra css. Is there any way to do it? **Edit:** I can't use inline style, since I want to include :hover in my css


add meta box using function.php

hi does any one know how can i add other meta box and save the data in a different custom fields, using the code below.               <?php     function add_meta_boxes() {         add_meta_box(             'repeatable-fields',             'Audio Playlist',             'repeatable_meta_box_display',             'post',             'normal',             'high');     }     add_action('admin_menu', 'add_meta_boxes');               function repeatable_meta_box_display() {         global $custom_meta_fields, $post;         wp_nonce_field( 'repeatable_meta_box_nonce', 'repeatable_meta_box_nonce' );         //$repeatable_fields = get_post_meta($post->ID, $prefix, true);     ?>              <?php              $meta = get_post_meta($post->ID, 'custom_audio', true);     ?>

                 	                 Name	                 URL

         <?php                  if ( $meta ) {                      foreach ( $meta as $field ) {     ?>
             -	             <input type="text" class="widefat" name="name[]" value="<?php if($field['name'] != '') echo esc_attr( $field['name'] ); ?>" />	                  <input type="text" class="widefat" name="url[]" value="<?php if ($field['url'] != '') echo esc_attr( $field['url'] ); else echo 'http://'; ?>" />	             |||
         <?php                 }              } else {                 // show a blank one     ?>
             -	             <input type="text" class="widefat" name="name[]" />	                       <input type="text" class="widefat" name="url[]" value="http://" />	     |||
         <?php } ?>
             -	             <input type="text" class="widefat" name="name[]" />	                       <input type="text" class="widefat" name="url[]" value="http://" />	     |||

Add another         <input type="submit" class="metabox_submit" value="Save" />
         <?php          }          add_action('save_post', 'repeatable_meta_box_save');     function repeatable_meta_box_save($post_id) {         global $custom_meta_fields;         if ( ! isset( $_POST['repeatable_meta_box_nonce'] ) ||             ! wp_verify_nonce( $_POST['repeatable_meta_box_nonce'], 'repeatable_meta_box_nonce' ) )             return;              if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)             return;              if (!current_user_can('edit_post', $post_id))             return;              // loop through fields and save the data             $old = get_post_meta($post_id, 'custom_audio', true);             $new = array();                       $names = $_POST['name'];             $urls = $_POST['url'];                  $count = count( $names );                  for ( $i = 0; $i < $count; $i++ ) {                 if ( $names[$i] != '' ) :                     $new[$i]['name'] = stripslashes( strip_tags( $names[$i] ) );                           if ( $urls[$i] == 'http://' )                     $new[$i]['url'] = '';                 else                     $new[$i]['url'] = stripslashes( $urls[$i] ); // and however you want to sanitize                 endif;             }                  if ( !empty( $new ) && $new != $old )                 update_post_meta( $post_id, 'custom_audio', $new );             elseif ( empty($new) && $old )                 delete_post_meta( $post_id, 'custom_audio', $old );          } ?>


Save author posts as in pending review - block users updating their posts

How can I let the users (author, editor, contributor etc) to edit their own posts but not to update them, just keep them as in "pending for review" so I can decide if it's ok to publish or not. By default these posts submitted by users are "pending for review" but once I decide to publish the post, the author can edit the post again and publish it without been held for moderation. Is there any way to get the same post pending for review every time the author edit them ? Thanks in advance


Menu with parents, children and or siblings pages display

Here you see the parent menu selected in the horizontal navbar. I already have that working. I need a sidebar like they have with the same parent indicated plus children when they exist . At the moment I have some great code thanks to Michael's feedback at WordPress Stack Exchange on an earlier question here. But that code does not show the parent above the children pages nor children pages above the siblings. Any ideas how can I adjust this code made by Michael:               <?php                           $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0&depth=2');                            if ($children) { ?>
                                <?php echo $children; ?>
                                <?php } //ends (if($children)//         elseif($post->post_parent) { //if no children, try to get parent page and show siblings pages including the page itself             $siblings = wp_list_pages('title_li=&child_of='.$post->post_parent.'&echo=0&depth=1');                               if ($siblings) { ?>
                                    <?php echo $siblings; ?>
          <?php } //ends if($siblings)// ?>                               <?php } else { //optional: if no children and if no parent, then show all top level pages             $pagelist = wp_list_pages('title_li=&echo=0&depth=1');                                    if ($pagelist) { ?>
                                        <?php echo $pagelist; ?>
         <?php } //ends if($pagelist)// ?>         <?php } ?>      The WordPress Codex page http://codex.wordpress.org/Function_Reference/wp_list_pages#List_current_Page_with_its_ancestors_and_children seems interesting, but I have not figured it all out just yet.. **Update:** I added children to a depth of two with the first `if` statement. That helps loading the children and siblings at a permalink level like: http://domain.com/top-level-page/. I just need to do some styling and rework the next to levels. **Update 2 CSS Solution** With some help I do have a menu that works quite well using `wep_list_pages` and some CSS. This is basically a CSS solution.

                          <?php wp_list_pages('title_li='); ?>

        and CSS:               li.current-page-ancestor a, li.current-menu-item a       {         color:#146BBB; //#0D55A8;     }          ul.children .current_page_item a:link,      ul.children .current_page_item a:visited {         background-color:#CCCCCC;         width: 250px;     }               .wplp_menu li{     list-style:none;    /*blends out list dots,can be removed if done somewhere else*/     }          ul#top-level-sidebar {         background: #5097EA;         width: 300px;         margin: 0 10px 0 50px;         float: left;     }          .wplp_menu .page_item a {     display:none;        }     .wplp_menu .current_page_ancestor a,.wplp_menu .children .current_page_item a,.wplp_menu .current_page_item li a  {     display:block;     }          .current_page_item a {    /* CSS for active item*/       font-weight:bold;     }     .current_page_item li a {     font-weight:normal;  /* Resets the above for its children */     }


Better in the long run to use post date or custom taxonomy to sort/separate posts by year?

I have custom type posts that I need to separate by year as the posts are entries in an annual contest. Would it be better in the long run for efficiency of queries, speed, etc to simply use the built in post date or set up a custom taxonomy to group these posts into years? I notice that post_date is stored in the wp_posts table, so it seems to me that this would make for speedier queries than having to reference the separate taxonomy table. Thank you!


Adding new pages to Menu

I am new to Wordpress. I am using the free Theme for my blog. I have added Menu as About Us, Contact Us, Groups etc .. I need to add Static Pages to About Us, Contact Us etc ..!! I dont know to How to create and map it to the Menu !!


How do I get the Social Media Plugin to show up in my Twenty Eleven child theme's header?

Being totally new to WordPress and (extremely) rusty with PHP, I'm having a difficult time figuring out how to add the Social Media Widget to my site's header. I'm using the Twenty Eleven theme, as I need the site to have no sidebars. Ideally, I'd like the social media icons to show up either above or below the site search box (image redacted for client's privacy): ![Widget position](http://i.stack.imgur.com/xUcZu.png) I've tried tutorials and have looked all over the web, but haven't been able to find anything that applies to my rather specific situation. Is this just too hard to do with this theme, and should I just go ahead and use icons instead of a widget? I'm pretty sure I can do this in `functions.php` and `header.php`, but how?


Identifying Importer Posts

Given a site with 100 posts, where an unspecified number of posts are manually written, and the rest are created using the WordPress importer, how would I programmatically identify the posts imported without having access to remote sites or the original import file? E.g. was this post created by the Importer tool?


display loop only if a post meta data exist

I'm looking to display the following loop, only if a custom field data exists, if not, I don't want to display anything.                <?php while (have_posts()) : the_post(); $data = get_post_meta( $post->ID, 'key', true );?>       <!-- info -->      <?php endwhile; ?>      Any guessing? Thanks in advanced.


How can I block with a child theme certain pages?

I am using the Woocommerce Wordpress plugin for an E-commerce site. I want to be able to set the site in a non-ecommerce mode, ie without the cart and checkout etc etc. I know there is a plugin you can buy that does this but I am trying to do this myself. I suppose I have to make myself a child theme and in the `function.php` remove certain pages. I do not want to just hide them because a user could still browse to them. I would like to return a 404 on any E-commercey page even though the page really exists. I could use `wp_delete_posts` but then when I go back to the Parent theme the pages are gone too. What do you advise?


Author Avatar as default first image

I need little bit help and customization on my existng script at function.php for wordpress 3.5. Here's what I have. As you can see here the default picture is none exist will be using                $first_img = $img_dir . '/images/post-default.jpg';      I would like to know if there would be possibility to just grab author's posts picture. Please find below the whole code related to this function. Thanks B4..               ////////////////////////////////////////////////////////////////////////////////     // Get Standard Post Image     ////////////////////////////////////////////////////////////////////////////////     function get_post_image() {       global $post, $posts;       $first_img = '';       ob_start();       ob_end_clean();       $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);       $first_img = $matches [1] [0];            if(empty($first_img)){ //Defines a default image         $img_dir = get_bloginfo('template_directory');         $first_img = $img_dir . '/images/post-default.jpg';       }       return $first_img;     }


Custom fields or something else

I have a problem with displaying some content on my homepage. First i'm going to explain my problem. I have a page with all my blog posts on it (use of excerpt function). When you click on a read more link on the blog posts page, you get the whole article. On my homepage I want to show the 3 latest posts. I already have the top 3 off the posts. (with the use of the excerpt function) but these **teasers** or to long. There is to much text. I don't want to make it shorter because when I do this, the page with all the blogposts is also going to change. I was thinking to use the custom fields in the blog posts. Then I can make an extra field for the teaser content on the homepage? Is this the right solution or is there something else?


Displaying information from custom field on custom post type

I have videos set up as a custom post type and music, commercial, promo set up as categories within this post type: I have a function that displays a custom meta box on the videos post type pages in the wordpress back end. The user is able to enter the ID of a youtube video or the ID of a vimeo video - wordpress then displays the video for the ID on custom post type page. When a user adds a new post to the videos custom post type and assigns it to any of the categories I specify I want wordpress to display the different videos. The code I have at the moment is not doing what I want it to do because it is displaying the same video on each post even though an ID hasnt been specified on some of them. For example on the music post page I have assigned it the category music and put a vimeo video ID which is displayed on the front end but then the same video is displayed for promo and commercial and I dont want that to happen. The loop I have running this is (in single-videos.php):               <?php          $args = array( 'post_type' => 'videos', 'posts_per_page' => 20, 'orderby' => 'date', 'order' => 'ASC' );                         $loop = new WP_Query( $args );                         while ( $loop->have_posts() ) : $loop->the_post();     //$args = array( 'post_type' => 'videos', 'posts_per_page' => 20, 'orderby' => 'date', 'order' => 'ASC' );     $ytubeID = get_post_meta($post->ID, '_youtubeID', true);     $vimID = get_post_meta($post->ID, '_vimeoID', true);     if ($ytubeID || $vimID){     if ($ytubeID){          echo '';          echo '';     } elseif ($vimID){     echo '
';     echo '';     }//end if yutbeID or vimIDthe_excerpt(); //excerpt added for information     }          endwhile;                         wp_reset_query();          ?>      Below is the full function that creates the meta box & stores the information:               // Create the Video Information Meta Box by hooking into the admin menu for a post         add_action('admin_menu', 'video_add_box');              //Function call by the "add_action" to tell it what to add, "video_information" and where "post"         function video_add_box(){         add_meta_box('video_information', 'Video Information', 'video_information', 'videos', 'normal', 'high');         }              //function to populate the meta box added above         function video_information(){         global $post;              // Noncename needed to verify where the data originated         echo '<input type="hidden" name="video_noncename" id="video_noncename" value="' .         wp_create_nonce( plugin_basename(__FILE__) ) . '" />';              //adds the custom field _youtubeID plus some other stuff         $youtubeID = get_post_meta($post->ID, '_youtubeID', true);         if ( empty($youtubeID) ) {         $youtubeID = '';         }              //adds the custom field _vimeoID         $vimeoID = get_post_meta($post->ID, '_vimeoID', true);         if ( empty($vimeoID) ) {         $vimeoID = '';         }              //add the box         echo '
';         echo 'Youtube ID:  <input type="text" name="_youtubeID" value="' . $youtubeID  . '" size="20" maxlength="30" />';         echo '
';         echo 'Vimeo ID:  <input type="text" name="_vimeoID" value="' . $vimeoID  . '" size="20" maxlength="30" />';         echo '
';         } //end video_information function              //save_video_meta is called below with the action "save_post" and saves your IDs to the post         function save_video_meta($post_id, $post) {         // verify this came from the our screen and with proper authorization,         // because save_post can be triggered at other times              if ( !wp_verify_nonce( $_POST['video_noncename'], plugin_basename(__FILE__) )) {         return $post->ID;         }              // Is the user allowed to edit the post or page?              if ( !current_user_can( 'edit_post', $post->ID )){         return $post->ID;         }              $video_meta['_youtubeID'] = $_POST['_youtubeID'];         $video_meta['_vimeoID'] = $_POST['_vimeoID'];         foreach ($video_meta as $key => $value) { // Cycle through the $video_meta array         if( $post->post_type == 'revision' ) return; // Don't store custom data twice              $value = implode(',', (array)$value); // If $value is an array, make it a CSV              if(get_post_meta($post->ID, $key, FALSE)) { // If the custom field already has a value         update_post_meta($post->ID, $key, $value);         } else { // If the custom field doesn't have a value         add_post_meta($post->ID, $key, $value);         }         if(!$value) delete_post_meta($post->ID, $key); // Delete if blank         }//endforeach video meta              } //end save_video_meta              //save the video custom fields         add_action('save_post', 'save_video_meta', 1, 2);


Update post title with category name after editing a category

I have this relationshop between some categories and posts where the name of the category is also the name of the post. When I add a new category, a post that has the same title as the category is created. Now when I edit one of those category titles, I want the corresponding post to update its title automatically as well. Here's what I have:               function update_group($post_id) {              // get the category object         $category = get_term_by( 'id', $post_id, 'category');              // use the object to get your values         $name = $category->name;              $updates = array(             'ID' => 996,             'post_title' => $name         );              wp_update_post($updates);          }          add_filter('edit_category' , 'update_group' );      The problem with this simple code is that when I fetch the category name, the new name that I submitted has not been saved yet when edit_category runs, so the first time I edit a category, wp_update_post updates the post with the old name. That means the post will only get the new and correct name when I submit the category change again via the admin page. Is there a way around this? How do I get the sumbitted category name the first time edit_category is executed?


How to set up Shibboleth authentication for a MU site

So far I haven't found an easy set up plugin that works. "shibboleth" is over 2 years out of date. "HTTP authentication" might work, but I haven't figured out how to set it up yet. I have an IDP set up that work. I have Drupal and Moodle both using it. So I just need to be able to get Wordpress working.


Why does logging in to my wp-admin redirect to my homepage?

Whenever I login to my dashboard I will have to manually go to the dashboard because my websites goes to the homepage first. Is there a reason for this? How do I redirect to the dashboard whenever I login in wp-admin?


Is it possible to add categories to new blogs on Wordpress MU?

I have setup WP MU and I need new blogs to have two additional categories when they're created. Is there a way to do this?


Bug in Stackoverflow styled badge system script

I have modified an old Stackoverflow inspired badge system script to work with the latest Wordpress version. You can view the code here (and please feel free to use it if you wish): http://pastebin.com/zA4zGnKZ It has a condition system that detects `Post tags`, `Post count` and `Comment count`. You can create custom badges and assign conditions to them. It works perfectly besides a very random bug that I cannot fix. I setup a Wordpress test site and created 10 accounts. I played around with the users and the badges were awarded according to its conditions, so for instance, if a user posted 10 articles, they would be awarded the `Junior Publisher` badge. However, **one** user was instantly awarded **all** badges when the account was created. This user has no posts or comments. Even more strange, when I add a new badge, this user automatically gets awarded with it! There is no difference between this user and the other users. All have `Contributor` privileges. The user ID number of this user is 5. **Can you please help me detect why the script is behaving like this?** Obviously, I cannot add the script to a live site yet in scare of random users being awarded all badges like this user.


WordPress add post format support not working

I am working on a theme and for some reason, `add_theme_support( 'post- formats', ... )` is not working. In my theme's `functions.php` I have the following near the top:               function mytheme_setup() {         // ...other functions              // Add post formats support         add_theme_support( 'post-formats', array(             'aside',             'audio',             'chat',             'gallery',             'image',             'link',             'quote',             'status',             'video',         ) );              // ... more other functions     }     add_action( 'after_setup_theme', 'mytheme_setup' );          add_post_type_support( 'post', 'post-formats' );      Yet, when I go to WordPress admin -> Posts -> Edit New Post or Add New Post, I do not see a box allowing me to select a post format. I tried putting `add_post_type_support()` inside `mytheme_setup()` function, but still the same result. Am I missing something?


Hide mu-plugins list

I'm using mu-plugins, http://codex.wordpress.org/Must_Use_Plugins. These plugins are showing in plugins.php, http://d.pr/i/JIvX. Is there any way to hide it? Thanks.


How to pull user/author profile data in a plugin?

My site has a user profile page. For some reason I would like to pull user profile data in my plugin. I know I can pull logged in user profile data using `get_currentuserinfo();`. For example I would like to get displayed profile user id. Can anyone tell me how to pull it.?


Get posts after calculating meta key

I have 2 meta fields for the posts, eg. `meta_value` and `meta_count`. Both are numbers. I want to divide `meta_value` by `meta_count` and based on the results I want to fetch the top 10 posts. So for example, post 1 has the meta_value 5, and meta_count 2. by dividing the result for that post will be 2.5. And the post 2 has meta_value 1 and meta_count 2, its result will be 0.5. I know there is a way to order posts by a specific meta key:               'meta_key' => 'meta_value',     'orderby' => 'meta_value_num',      But I do not know if it is possible what I'm trying to do.


Are there Limitations on filter handles?

I was looking through a 3rd party plugin's code today and found them doing this: `add_filter('some_base_handle'.sanitize_title($string), ...)` Curious, since I was using xh_prof to look for code that was taking up too much time and was confused why there were so many calls to sanitize title. Is it safe to remove the sanitize_title or are there good reasons for it being there? Does anyone have links to Codex documentation that I might have missed about it? I looked at add_filter's page but didn't see anything. EDIT: I looked into the wp-includes/plugins.php code to see if there was anything and didn't see anything to outstanding, anyone know?               function add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 )      {         global $wp_filter, $merged_filters;              $idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority);         $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add,     'accepted_args' => $accepted_args);          unset( $merged_filters[ $tag ] );         return true;     }


How can I allow moderated anonymous contributors to post to my blog?


only show children of a nav menu

I wanted to know how could i display only the children of a nav menu. ive tried a couple of things like :               if($post->post_type == "page"){                 $postid = $post->ID;                 print_r( get_pages(array("child_of" => $postid)) );             }         But all i get an empty array. so what i want is something like this: http://www.isic.org/student-card/the- isic-student-card.html


Loop with break in the middle

I'm trying to create a gallery type page which shows one post thumbnail from each post category. The trouble is that I want to display the page title and a link to the portfolio page in the middle of a nine square grid. I was thinking the best way to go about it would be to display four thumbnails in three columns followed by the page title and then another 4 thumbnails. I've got the first four like so : **Updated code:**                <?php         $count = 0;         $taxonomy = 'category';//  e.g. post_tag, category         $param_type = 'category__in'; //  e.g. tag__in, category__in         $term_args=array(           'orderby' => 'name',           'order' => 'ASC',         );         $terms = get_terms($taxonomy,$term_args);         if ($terms) { ?>
          <?php                          foreach( $terms as $term ) {             $args=array(               "$param_type" => array($term->term_id),               'post_type' => 'post',               'post_status' => 'publish',               'posts_per_page' => 1,               'caller_get_posts'=> 1               );             $my_query = null;             $my_query = new WP_Query($args);             $post_count = $my_query->post_count;                  if( $my_query->have_posts() ) :                       $count++;                                if ($count <= 4) {                           while ($my_query->have_posts()) : $my_query->the_post();                  ?>

<?php the_category(); ?>

<?php the_title(); ?>
                                             Click for details
                                         <?php if (has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?>
                                         <?php endif; ?>
              <?php                  endwhile;                            }              endif;                } /* end foreach term*/           ?>

Galleries

                                         <a href="<?php echo home_url(); ?>/portfolio" class="btn btn-primary">See Full Portfolio

                  <?php              if ($count >= 4) {                 while ($my_query->have_posts()) : $my_query->the_post();                  ?>

<?php the_category(); ?>

<?php the_title(); ?>
                                             Click for details
                                         <?php if (has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?>
                                         <?php endif; ?>
                                                <?php endwhile;           } ?>
   <?php         } /* end if terms */                     wp_reset_query();  // Restore global post data stomped by the_post().         ?>      My problem is the second loop. I've got as far as the if statement `if ($count > $more_cats_to_show && $count <= $max_count)` but I can't seem to manage to get the next 4 thumbnails.


Check if page has subpages

I'm try to build a menu with `wp_list_pages()` that must work like this:               Main Page         -Subpage1         -Subpage2        I check if the Page has_subpage and i can see the 2 subpages when i'm in the Parent but when i'm visit one of the subpages i don't see anything. So, what i can do to check if page has subpages to get the same list of pages in the subpage(s)? How i use it: in the functions i check if the Page has_subpage,               function has_subpage (){     global $post;     $pages = get_pages("sort_column=menu_order&depth=1&child_of={$post->ID}");     if ($pages) return TRUE;     }      and in my template i call the menu (list of subpages),               <?php if (is_page() && has_subpage()) { ?>              <?php           if($post->post_parent) {           $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0$sort_column=menu_order");           $title_heading = get_the_title($post->post_parent);           }                else {           $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");           $title_heading = get_the_title($post->ID);           }           if ($children) { ?>                <?php echo $children; ?>              <?php } ?>          <?php } ?>      the problem is inside has_subpage() function, cause if i don't use it i get the pages correct, maybe i'm missing something here? thanks a lot!


How to fix: Clicking 'Quick Edit' link in Admin (edit.php) makes posts disappear?

When I'm logged in and go to the Posts management page (edit.php), **if I click the 'Quick Edit' button, the clicked post disappears from the listing!** This occurs in FF7 and Safari 5.1, running WP 3.2.1. Refreshing the page displays the post in the list again, but I can't find a way to use the Quick Edit functionality. Edit: In Post management, after clicking quick-edit, Firebug displays: `a("input[name=\"ping_status\"]", d).prop is not a function` in `/wp- admin/js/inline-edit-post.js?ver=20110609` I've tried:   * Clearing the cache in FF, restarting FF, hard refreshing several times (inspired by a post by Andrew Ozz re fixing post edit functionality   * Reinstalling WP from the Dashboard > Upgrade menu (repeat the cache clearing / refreshing)   * Deactivated the most relevant / recent plugins (meaning those that edit the admin area, non essential plugins). I still have a bunch active, but they are crucial - eg Custom Post Type plugins without which the site would break. Unfortunately, I can't say when this started happening, only that it only happens on this site. Possibly related issues:   * Clicking the 'Publish immediately' button in the Edit Post page does nothing   * Edit Post: Add a tag / Display most used tags fails   * Yoast SEO: not displayed in tabs, doesn't load the SEO title preview, etc (have switched off the plugin: doesn't resolve the other issues)   * Clicking the 'Edit image' popup button loads the semi-opaque overlay, but no thickbox   * I can no longer upload a new image, though I managed that only half an hour ago :( Upload button does nothing   * Firebug reports: `g.prop is not a function`, in file `wp-admin/js/post.js?ver=20110524` It seems that the jquery / ajaxy business in admin is failing (seeing lots of `.prop is not a function`). I previously had an issue with adding links in post content, which is why I mentioned the earlier post. Clearing the cache / refreshing worked for this issue. I'm stumped! Any suggests as to how to proceed would be appreciated, Regards, Tim Update: these links are loaded requested twice, but the top ones never resolve ?? ![Each file is loaded twice, but the top one doesn't resolve](http://i.stack.imgur.com/2injM.png)


Link to Author archive from Navigation Menus in dashboard?

I'd like to display a grid of authors on my site showing the name of the author and their avatar. The tricky part is, I'd like to be able to control this from the Menus page in the dashboard so I have control over who is displayed and in what order they are displayed. Is this doable? I don't think a custom walker would work in this situation as it wouldn't allow for arbitrary order and selection control. So my next thought is how to add another selector on the menus page for authors. Any help?


Where is default wp_head() implemented?

I'm trying to customize a theme, and I see that the header.php calls "wp_head()". I can't seem to find an implementation of this in the theme, so I presume there is a default implementation that implements, for example, the Color Options settings as specified on the admin page. So my related questions are:   * Is there somewhere I can see this default implementation?   * Can this default implementation be "turned off"?   * Can the "Color Options" option be disabled in the admin screen for the theme? Please feel free to point me to relevant documentation if that would be easier. I've looked at the reference pages for the wp_head() function and the corresponding wp_head action hook, but they don't seem to provide enough information for me to tackle the questions above. Thanks.


Organize uploads by year, month and day

As of now my uploaded files are organized by year and month. But I would like to organize them by year, month and day. I mean like this `2012/10/30/image goes here` PS: There is a plugin available to do this. But I don't want to use a plugin for this simple task. Thanks


Redirect from ip to domain

I want to prevent site to be accessible by ip. It could be accessible by only domain name, so I tried with htaccess trick.               RewriteCond %{HTTP_HOST} !^mydomain\.com [NC]     RewriteRule .? http://mydomain.com%{REQUEST_URI} [R=301,L]      It did the trick now my siteurl is changed to mydomain.com instead of my ip. But as per my knowledge its not complete solution. Whenever I change permalinks new htaccess will be generated so above condition will be removed. So I thought I have to try in index.php, tried to redirect if ip is there in url by following:               if(strpos($_SERVER['HTTP_HOST'],'111.111.111.11') !== false) {           header("Location: mydomain.com".$_SERVER['REQUEST_URI']);     }      but it did nothing still site accessed by ip. Let me know if my approach is right or not. Suggest me anything else if there.


Custom GET Parameters In Plugin's Admin Page

In my plugin's options page, I'd like to have custom GET parameters. WordPress already has a "?page=" GET parameter, so simply linking to something like "?myparameter=value" won't work. I though of reading the "page" parameter, and then linking to something like: "?page=&myparameter=value". This seems workable, but I don't know if its the best practice. The complexity of my plugin really doesn't warrant sub-pages for now. So is this the best practice or am I missing something?


Is there any way of only retrieving posts with one or more thumbs up (GD star rating plugin)?

I'm building a website that uses the GD star rating plugin. Right now, I'm using the following code to retrieve two posts of the current page (a custom post type called `bbp_topic`) and sort them by vote:               <?php query_posts('gdsr_sort=thumbs&posts_per_page=2&post_parent='.$post->ID); ?>      I would like now to only retrieve those post that have 1 or more thumbs up. Any suggestions?


Wordpress: Preload next post images

As the title says, i would like a nice bit of coding to stick in my functions that pre-loads any images that are attached to the next post. This means that whilst my users are browsing, they page will load, but it will actually be loading the next page, so when you click-through, the images should already be there and waiting! Think of it as 'buffering' for image. Couple of things to note: I use the post_thumbnail feature and have different sizes setup through functions.php. I also have a plugin that enables multiple Featured Images per post. I posed this question on stackoverflow (who pointed me here) and was given this code to be placed in the loop;                   <?php     $next_post = get_adjacent_post(false, '', false );// set last param to true if you want post that is chronologically previous     $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_parent' => $next_post->ID);     $attachments = get_posts($args);     ?>     <script type="text/javascript">         $(document).ready(function(){             var images = '';             <?php foreach($attachments as $attachment):                 $mime = $attachemnt->post_mime_type;                 if($mime == 'image/jpeg' || $mime == 'image/gif' || $mime == 'image/png'):              ?>             images += '<img src="<?php $attachment->guid ?>" style="display:none" />';             <? endif; endforeach; ?>             if(images != ''){                 $(body).append(images);             }         });     </script>      Although to looks like it could be onto a winner, it doesn't seem to be doing the job quite yet. In my page source it returns the following:               <script type="text/javascript">         jQuery(document).ready(function(){             var images = '';                     if(images != ''){                 jQuery(body).append(images);             }         });     </script>      It is possible i am doing something wrong as i am a chronic copy and paster! Anyone got any thoughts on this? Thanks guys!


Is there any way of changing the post order via user click?

Is there any way of changing the post order, posts number, etc via user click? The same way you can choose displaying questions by time and vote here at StackExchange. How to accomplish that?


Yearly Archive from a custom date metabox (Event Start Date)

I have created a custom post_type called (event) and here's the code                           // Register Custom Post Type Events             function custom_post_type_events() {                      $labels = array(                     'name'                => _x( 'Events', 'Post Type General Name', 'text_domain' ),                     'singular_name'       => _x( 'Event', 'Post Type Singular Name', 'text_domain' ),                     'menu_name'           => __( 'Events', 'text_domain' ),                     'parent_item_colon'   => __( '', 'text_domain' ),                     'all_items'           => __( 'All Events', 'text_domain' ),                     'view_item'           => __( 'View Event', 'text_domain' ),                     'add_new_item'        => __( 'Add New Event', 'text_domain' ),                     'add_new'             => __( 'New Event', 'text_domain' ),                     'edit_item'           => __( 'Edit Event', 'text_domain' ),                     'update_item'         => __( 'Update Event', 'text_domain' ),                     'search_items'        => __( 'Search events', 'text_domain' ),                     'not_found'           => __( 'No events found', 'text_domain' ),                     'not_found_in_trash'  => __( 'No events found in Trash', 'text_domain' ),                 );                 $args = array(                     'label'               => __( 'event', 'text_domain' ),                     'description'         => __( 'Events information pages', 'text_domain' ),                     'labels'              => $labels,                     'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'revisions', 'custom-fields', 'post-formats', ),                     'taxonomies'          => array( 'category', 'post_tag' ),                     'hierarchical'        => false,                     'public'              => true,                     'show_ui'             => true,                     'show_in_menu'        => true,                     'show_in_nav_menus'   => true,                     'show_in_admin_bar'   => true,                     'menu_position'       => 5,                     'menu_icon' => admin_url() . '/images/ef-events-icon.png',  // Icon Path                     'can_export'          => true,                     'has_archive'         => true,                     'exclude_from_search' => true,                     'publicly_queryable'  => true,                     'capability_type'     => 'page',                 );                 register_post_type( 'event', $args );                  }                  // Hook into the 'init' action             add_action( 'init', 'custom_post_type_events', 0 );      Then I have created a custom date meta_box for this event post_type, and here's the code                               add_filter( 'cmb_meta_boxes', 'dt_person_meta_boxes' );                 function dt_person_meta_boxes( $meta_boxes ) {                     $meta_boxes[] = array(                         'id' => 'dt_metabox',                         'title' => 'Event Date and Time',                         'pages' => array('event'),                         'context' => 'side',                         'priority' => 'high',                         'show_names' => true, // Show field names on the left                         'fields' => array(                             array(                                 'name' => 'Event Start Date',                                 'desc' => 'Pick the date of this event',                                 'id' => $prefix . 'event_starttextdate',                                 'type' => 'text_date'                             ),                             array(                                 'name' => 'Event End Date',                                 'desc' => 'Pick the date of this event',                                 'id' => $prefix . 'event_endtextdate',                                 'type' => 'text_date'                             ),                             array(                                 'name' => 'Event Time',                                 'desc' => 'Enter event time (eg. 05:00 p.m.)',                                 'id' => $prefix . 'event_time',                                 'type' => 'text',                                 'save' => true                             )                         )                     );                       return $meta_boxes;                 }      * * * My question is: How to build a custom archive page for the custom post_type (event), that will sort events by the custom meta-box (event_starttextdate) ??? Example: **2013**   * Event-1   * Event-2 **2012**   * Event-3   * Event-4 **2011**   * Event-5   * Event-6   * Event-7   * Event-8 * * * Your help is appreciated, Thank you.


Rewrite URL based on form input

I have a form:               <form action="<?php echo get_permalink(); ?>" method="get">     <select name="genres[]">     <option value="jazz"></option>     <option value="blues"></option>     <option value="rock"></option>     </select>     </form>      After submitting the form, in the URL the input becomes `example.com/?genres%5B%5D=jazz&genres%5B%5D=blues&genres%5B%5D=rock` Next to that it doesn't look very nice, I have other inputs in my form (and around 18 genres) so if a user selects a lot, the URL becomes very long. I'm not very skilled in wordpress rewrite rules. I'd like the URL to become `?genres=jazz,blues,rock` but I would also be satisfied if just the characters won't be ASCII code, so the url becomes `?genres[]=jazz&genres[]=blues&genres[]=rock`. I'm also using the array (`$genres = $_GET['genres']`) as input for a query so if I alter it, it should still be usable as an array. That's why I think just rewriting the ASCII codes to characters is the best option.


Show posts on a page based on a category and tag(s)

I have been looking all over the internet for this, and have not yet found an answer I could use.   Found out that I may can use something called query_posts or get_posts, but I have no idea how to use them. Isn't there some sort of plugin that could do this for me? Say if I made a post under the category Guides, with the tag of Computer and Internet, it should be listed under a page called Guides for Computers.   Is this possible? Thank you very much in advance.


What is the structure of the "Featured Image" field in the DB?

On a WP install with about 1400 images and the Media Tools 1.1 plugin, I ran both "Import External and Set Featured Image" and "Set Featured Image". But the **featured images functionality didnt work, because it designated (in the DB) the wrong filename for the images** : Instead of pointing to the correct file, it appended a "1" to its name, **causing, for example, a 404 for "Protest-11-620x264.jpg"** , **when it should point to "Protest-1-620x264.jpg"** **I need to do asearch & replace in the DB on *_wp_attachment_metadata* field and remove the extra "1" from the filenames**. Naturally I will use a regex, but how do I process the contents of the field? **Which one of the sections of the data has which featured image to use? In other words, what do I need look for to know the filename is the right one to search &replace?** For example (note the "Protest-11-620x264.jpg" in there)               _wp_attachment_metadata = a:5:{s:5:"width";i:800;s:6:"height";i:536;s:4:"file";s:22:"2013/11/Protest-11.jpg";s:5:"sizes";a:9:{s:9:"thumbnail";a:4:{s:4:"file";s:22:"Protest-11-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:10:"image/jpeg";}s:6:"medium";a:4:{s:4:"file";s:22:"Protest-11-300x201.jpg";s:5:"width";i:300;s:6:"height";i:201;s:9:"mime-type";s:10:"image/jpeg";}s:6:"slider";a:4:{s:4:"file";s:22:"Protest-11-800x400.jpg";s:5:"width";i:800;s:6:"height";i:400;s:9:"mime-type";s:10:"image/jpeg";}s:7:"content";a:4:{s:4:"file";s:22:"Protest-11-620x264.jpg";s:5:"width";i:620;s:6:"height";i:264;s:9:"mime-type";s:10:"image/jpeg";}s:9:"spotlight";a:4:{s:4:"file";s:22:"Protest-11-580x326.jpg";s:5:"width";i:580;s:6:"height";i:326;s:9:"mime-type";s:10:"image/jpeg";}s:4:"loop";a:4:{s:4:"file";s:22:"Protest-11-174x131.jpg";s:5:"width";i:174;s:6:"height";i:131;s:9:"mime-type";s:10:"image/jpeg";}s:8:"carousel";a:4:{s:4:"file";s:21:"Protest-11-174x98.jpg";s:5:"width";i:174;s:6:"height";i:98;s:9:"mime-type";s:10:"image/jpeg";}s:8:"cp_large";a:4:{s:4:"file";s:22:"Protest-11-300x225.jpg";s:5:"width";i:300;s:6:"height";i:225;s:9:"mime-type";s:10:"image/jpeg";}s:8:"cp_small";a:4:{s:4:"file";s:20:"Protest-11-70x53.jpg";s:5:"width";i:70;s:6:"height";i:53;s:9:"mime-type";s:10:"image/jpeg";}}s:10:"image_meta";a:10:{s:8:"aperture";d:3.5;s:6:"credit";s:0:"";s:6:"camera";s:10:"NIKON D40X";s:7:"caption";s:0:"";s:17:"created_timestamp";i:1383833520;s:9:"copyright";s:0:"";s:12:"focal_length";s:2:"18";s:3:"iso";s:3:"200";s:13:"shutter_speed";s:7:"0.00125";s:5:"title";s:0:"";}}


Post list based on the user that is logged in

I've been all over this site and google, and the WP codex looking for an answer to this one. I know it's out there, and I know it's easy. Maybe has something to do with user_nicename, but I just can't make it work. What I'm trying to do for the site I'm working on is eliminate any need and any ability for the user to see the backend of the blog. This means front-page everything: Login, Post, and if I can swing it - a dash board. I envision changing the "site admin" link on the wp login/logout code to link to a blog page called "User Dashboard" there, the user could view a list of their posts and comments. Really reaching for the stars, they should also be able to see a list of comments on their posts, and really really reaching for the stars - some kind of messaging system. I'm currently simply trying to get the post list down! I can't figure out how to return the_author post list based on a dynamic setting of where the request is coming from. IE: Only list the current logged in users posts/comments. There is a plugin called Full Author User List or something to that affect, that doesn't work anymore as it's outdated. Any help?


The Great WordPress Admin Menu Challenge of Jan 2011 (a.k.a. How to Resolve Some Challenges when Modifying the WordPress Admin Menu System?)

## This question is a bit unique. It is in part a _"challenge"_ I'm issuing to the WordPress team _( **or anyone else** )_ related to trac tickets: #16048, #16050 and #16204. ### The Goal _The goal is to get around the three (3) issues illustrated in the screenshot_ below when trying to modify the WordPress Admin menu section:   1. Get the _"Microsite"_ submenu page to be highlighted when editing an Attorney _(for this we need to somehow be able to apply "current" to the submenu item,_ andsome hooks in the _wp_menu_output() function would provide what's needed here)_,    2. Get the Attorney Menu Page link to link to `/wp-admin/edit.php?post_type=attorney` when editing an Attorney _(and thosesame needed hooks in the _wp_menu_output() function could handle this)_, and    3. Get the _"Microsite"_ link not to trigger a _"You do not have sufficient permissions to access this page"_ error *(this is the nastiest one to resolve, and a hook on the return value of `user_can_access_admin_page()` could handle this issue nicely.) ![Screenshot for The Great WordPress Admin Menu Challenge of Jan 2011](http://mikeschinkel.com/websnaps/skitched-20110115-010057.png) ### More than just my use-case These three (3) issues are for my use-case but their are emblematic of the issues related to configure the admin menus in WordPress. Several on the WordPress team said that it's easy and thus implied I'm missing something _(which may be right)_ but I've looked at this problem for weeks and not figured out how to get around it so I created the plugin you see below ( **also downloadable from Gist**) as the simplest use-case example of the issues. The code in `admin_menu2()` is rather hackish but that's pretty much what's required to modify the Admin Menus in WordPress. Note that I did not try to use the new `remove_menu_page()` nor the new `remove_submenu_page()` functions in 3.1 because it would have taken longer to create the plugin -- I already had the code in `admin_menu2()` from an existing project -- and I don't believe they would address the problem anyway. ### What do I need? I need one of two (2) things:   1. A solution to the problems that I expose with this plugin and explain in this question and in the screenshot _(BTW, **I'll disqualify your solution** if you use PHP Output Buffering to solve any part of this)_, or   2. To have the WordPress Team recognize that there is indeed a need for these hooks and to get them to reconsider their position on the tickets. ### How do you Take the Challenge?   1. Download and install a pristine new copy of WordPress 3.1 _(any revision will probably do)_ ,   2. Download, install and activate the _"The Great WordPress Admin Menu Challenge of Jan 2011"_ plugin below _(ordownload the plugin from Gist)_, and then    3. Follow the instructions found on the plugin page for this plugin _(see the following screenshot)_ but basically load the screenshot you see above and then try to figure out the three (3) issues described: ![Screenshot of "The Great WordPress Admin Menu Challenge of Jan 2011" plugin instructions](http://mikeschinkel.com/websnaps/Plugins_%E2%80%B9_WordPress_3.1_Test_Site_%E2%80%94_WordPress-20110115-011459.png) ### One Ray of Hope Fortunately Andrew Nacin of the WordPress team offered to look at this once I'd coded it so I'm primarily posting here for him to review and comment as well as having others to comment. I know he is busy but I do hope he **(or even you)** can take the time to install this plugin on a pristine install of v3.1 and see if he can resolve the issue. ### If you Agree the Challenge is Impossible? If after trying this challenge you come to the same conclusion as me, and if you'd like to see the WordPress Admin menus be more configurable please comment on these trac tickets (#16048 - #16050 - #16204) and vote this question up to show support for it. ### I'll Gladly Admit I Missed Something, If I Did Of course it's possible I could be completely brain dead on this and someone could point out exactly how to do it. Actually, I really hope that ends up being the case; I'd rather be wrong and have this working than vice-versa. ### And Here's the Plugin You can also **downloadable if from Gist**:               <?php     /*     Plugin Name: The Great WordPress Admin Menu Challenge of Jan 2011     Description: "The Great WordPress Admin Menu Challenge of Jan 2011" was inspired by the WordPress team's apparent lack of understanding of the problems addressed by trac tickets #16048 and #16050 (See also: #16204) and suggestion that the Admin Menu Editor plugin handles the use-cases that the tickets address. Debate spilled over onto Twitter with participation from @nacin, @aaronjorbin, @petemall, @westi, @janeforshort, @PatchesWelcome; supportive comments from @ramsey, @brianlayman, @TheLeggett, a retweeting of @nacin's simple yet (AFAICT) insufficient solution by @vbakaitis, @Viper007Bond, @nickopris, @Trademark, @favstar_pop, @designsimply, @darylkoop, @iamjohnford, @markjaquith, @JohnJamesJacoby and @dd32. Also see comments on @nacin's blog post entitled "Better admin menu handling for post types in WordPress 3.1." The desired goal of the "challenge" is to simply either to find a solution that has eluded me or, to get those who are dismissing it as solvable without added hooks in WordPress to have a tangible example to explore in hopes they will recognize that there is indeed a need for at least some of the requested hooks. There are three (3) steps to the challenge: 1.) Get the "Microsite" submenu page to be highlighted when editing an Attorney, 2.) Get the Attorney Menu Page link to link here  when editing an Attorney, and 3.) Get the "Microsite" link not to trigger a "You do not have sufficient permissions to access this page" error.  Here is a screenshot that attempts to illustrate the callenge. The code can be found on gist here. Activate it as a plugin in a WordPress 3.1 install and go here to see what the screenshot illustrates. Be sure to load the screenshot in another browser tab or window first.     Author:      Mike Schinkel     Author URI:  http://about.me/mikeschinkel     Plugin URI:  https://gist.github.com/780709     */     if (!class_exists('TheGreatWordPressAdminMenuChallenge')) {       class TheGreatWordPressAdminMenuChallenge {         static function on_load() {           add_action('init',array(__CLASS__,'init'));           add_action('admin_menu',array(__CLASS__,'admin_menu1'));      // Simulates generic "Microsite" plugin           add_action('admin_menu',array(__CLASS__,'admin_menu2'),100);  // Simulates website-specific plugin           add_action('post_row_actions',array(__CLASS__,'post_row_actions'),10,2);         }         static function post_row_actions($actions,$post) {           $url = admin_url(self::this_microsite_url($post->ID));           $actions = array_merge(array('microsite'=>"Microsite"),$actions);           return $actions;         }         static function the_microsite_editor() {           echo "We are in the Microsite Editor for " . self::post_title();         }         static function admin_menu1() {           if (self::this_post_id() && in_array(self::this_post_type(),array('attorney','practice_area'))) {             add_submenu_page(               self::this_parent_slug(),               self::microsite_page_title(),               self::microsite_page_title(),               $capability = 'edit_posts',               'microsite',               array($microsite,'the_microsite_editor')             );             global $wp_post_types;             $parent_type_meta = $wp_post_types[self::this_post_type()];             global $menu;             $slug = false;             foreach($menu as $index => $menu_page)               if ($menu_page[0]===$parent_type_meta->label) {                 $slug = $menu_page[2];                 break;               }             if ($slug) {               global $pagenow;               global $submenu;               // Setting this makes gives the link to the microsite in the menu the highlight for "current" menu option               global $submenu_file;               $submenu_file = self::this_microsite_url();               $index = end(array_keys($submenu[$slug]));               $submenu[$slug][$index][12] = $submenu_file;             }           }         }         static function this_parent_slug() {           return "edit.php?post_type=" . self::this_post_type();         }         static function post_title() {           $post_id = self::this_post_id();           return ($post_id ? get_post($post_id)->post_title : false);         }         static function microsite_page_title() {           return 'Microsite for ' . self::post_title();         }         static function this_post_type($get_post=true) {           $post_type = (isset($_GET['post_type']) ? $_GET['post_type'] : false);           if (!$post_type && $get_post) {             $post_id = self::this_post_id();             $post_type = get_post($post_id)->post_type;           }           return $post_type;         }         static function this_post_id() {           $post_id = false;           $post_type = self::this_post_type(false);           if (isset($_GET[$post_type]))             $post_id = intval($_GET[$post_type]);           else if (isset($_GET['post']))             $post_id = intval($_GET['post']);           return $post_id;         }         static function this_microsite_url($post_id=false) {           $post_type = self::this_post_type();           $post_id = $post_id ? intval($post_id) : self::this_post_id();           return "edit.php?post_type={$post_type}&page=microsite&attorney={$post_id}";         }         static function admin_menu2() {           // The code required for this is super, nasty, ugly and shouldn't be, but at least it *is* doable           global $menu;           global $submenu;           global $microsite;                $parent_type = self::this_post_type();           foreach(array('attorney','practice_area') as $post_type) {             $slug = "edit.php?post_type={$post_type}";             if ($post_type==$parent_type) {  // If a microsite remove everything except the microsite editor               $microsite_url = self::this_microsite_url();               foreach($submenu[$slug] as $submenu_index => $submenu_page) {                 if ($submenu_page[2]!=$microsite_url) {                   unset($submenu[$slug][$submenu_index]);                 }               }             } else {               $submenu[$slug] = array();             }           }                 // Remove the Submenus for each menu           unset($submenu['index.php']);           unset($submenu['edit.php?post_type=article']);           unset($submenu['edit.php?post_type=event']);           unset($submenu['edit.php?post_type=case_study']);           unset($submenu['edit.php?post_type=news_item']);           unset($submenu['edit.php?post_type=transaction']);           unset($submenu['edit.php?post_type=page']);           unset($submenu['upload.php']);                unset($submenu['users.php'][13]); // Removed the "Add New"                $remove = array_flip(array(             'edit.php',             'link-manager.php',             'edit-comments.php',             'edit.php?post_type=microsite-page',           ));           if (!current_user_can('manage_tools'))             $remove['tools.php'] = count($remove);                foreach($menu as $index => $menu_page) {             if (isset($remove[$menu_page[2]])) {               unset($submenu[$menu_page[2]]);               unset($menu[$index]);             }           }                $move = array(             'edit.php?post_type=page' => array( 'move-to' => 35,  0 => 'Other Pages' ),             'separator2' => array( 'move-to' => 40 ),             'upload.php' => array( 'move-to' => 50, 0 => 'Media Library' ),           );           $add = array();           foreach($menu as $index => $menu_page) {             if (isset($move[$menu_page[2]])) {               foreach($move[$menu_page[2]] as $value_index => $value) {                 if ($value_index==='move-to') {                   $move_to = $value;                 } else {                   $menu_page[$value_index] = $value;                 }               }               $add[$move_to] = $menu_page;               unset($menu[$index]);             }           }           foreach($add as $index => $value)             $menu[$index] = $value;                add_menu_page(             'Attorney Positions',             'Attorney Positions',             'edit_posts',             'edit-tags.php?taxonomy=attorney-position&post_type=attorney',             false,             false,             55);                ksort($menu); // Need to sort or it doesn't come out right.         }         static function init() {           register_post_type('attorney',array(             'label'           => 'Attorneys',             'public'          => true,           ));           register_post_type('practice_area',array(             'label'           => 'Practice Areas',             'public'          => true,           ));           register_taxonomy('attorney-position','attorney',array(             'label'=>'Attorney Positions',           ));           register_post_type('article',array(             'label'           => 'Articles & Presentations',             'public'          => true,           ));           register_post_type('case_study',array(             'label'           => 'Case Studies',             'public'          => true,           ));           register_post_type('news_item',array(             'label'           => 'Firm News',             'public'          => true,           ));           register_post_type('event',array(             'label'           => 'Events',             'public'          => true,           ));           register_post_type('transaction',array(             'label'           => 'Transactions',             'public'          => true,           ));                // Install the test data           $post_id = 10;           $attorney = get_post($post_id);           if (!$attorney) {             global $wpdb;             $wpdb->insert($wpdb->posts,array(               'ID' => $post_id,               'post_title' => 'John Smith',               'post_type' => 'attorney',               'post_content' => 'This is a post about the Attorney John Smith.',               'post_status' => 'publish',               'post_author' => 1,             ));           }         }       }       TheGreatWordPressAdminMenuChallenge::on_load();     }      To all who read this, I'm really hoping you can help. Thanks in advance.


Can't post comment to blog in wp-multisite

I'm running a wp-multisite install with ~100 blogs. I recently discovered a blog that I can't post a comment to (though I've been able to previously). When I try to submit a comment, I get the following warning dialog: ![enter image description here](http://i.stack.imgur.com/ni5x4.png) When I press send "send" I get an the comment field looks like this: ![enter image description here](http://i.stack.imgur.com/XTGlN.png) And nothing ever happens. I'm able to post comments to other blogs on the wp- multisite without problems, and this happens even when I'm logged in as superadmin.


Add a YouTube or Vimeo video as a post attachment?

I'm developing a gallery plugin and I was wondering if I could add a YouTube and Vimeo "embed" option to the media uploader to be able to add YouTube and Vimeo videos as attachments to a post instead of uploading the video files directly to the server. I'm thinking along the lines of an option with a textarea where one could put the YouTube or Vimeo HTML embed code and this would be added to the media library with a mime type of "text/html". Any clues would be much appreciated


How to update Wordpress plugins to latest using SVN

I can get latest WP using latest.tar.gz http://wordpress.org/latest.tar.gz How to get latest plugins? I checked about svn i need to know when new version is out and in command svn sw put latest link so thats bad option. Trunk is bad couse its development so that means it can be not be stable therefore not called stable version. So for WP ill use link latest.tar.gz But what to do with plugins? They have one more problem. They dont have latest. I could use svn if there would be a way to auto get latest without checking all plugins im using do they have new version number and entering it in svn external file. So whats best solution? Is there autochecker? Autodownloader? In website i know but its slow and my server has time limits witch is too small for update to finish.


Caption shortcodes not including caption as attribute

I recently installed the bonpress theme and am having trouble with the captions showing correctly. The more I try to understand how captions are supposed to work in Wordpress, the more I suspect something is not happening right with my installation. When creating a post and inserting an image with a caption, Wordpress creates the following shortcode:               [caption id="attachment_40" align="alignleft" width="1024"] That's what I get for only spending $15 on a motorcycle cover[/caption]      As I read through several pages such as the first example here and the sample code here (used by bonpress), it appears as though the caption should be passed as an attribute, e.g.:               [caption id="attachment_40" align="alignleft" width="1024" caption="That's what I get for only spending $15 on a motorcycle cover"][/caption]      If I manually enter the shortcode with `caption` as an attribute, it renders correctly. Is something broken in my install that makes it so it doesn't build it this way? **Update:** The caption shortcode is constructed by `image_add_caption` in /wp-admin/includes/media.php (line 134 in WP 3.4.2). The shortcodes are being constructed properly according to this code, so this leaves me wondering why all the code I can find regarding the customization of `img_caption_shortcode` filter assumes the caption is an attribute?


How to play a video without using plugin?

I want to play a video inside my site itself without using any plugins. How can I do that?


Echo URL of large version of Featured Image

I use this plugin to echo the URL of a post's featured image in the header:               <?php     /** Plugin Name: Post Thumbnail FB header */     function fb_header()     {         // Not on a single page or post? Stop here.         if ( ! is_singular() )             return;              $post_ID = get_queried_object_id();              // We got no thumbnail? Stop here.         if ( ! has_post_thumbnail( $post_ID ) )             return;              // Get the Attachment ID         $att_ID = get_post_thumbnail_id( $post_ID );              // Get the Attachment         $att    = wp_get_attachment_image_src( $att_ID );              printf(              '<link rel="image_src" href="%s" />'             ,array_shift( $att )         );     }     add_action( 'wp_head', 'fb_header' );     ?>      As it stands currently, it echo's the featured image. I want it to echo the URL of the Large version of the featured image. **How can I do this?** Just to note that all my featured images have a large version...


How to remove admin bar logo in WordPress using plugin

I'm following the instructions from this page to remove the adminbar wordpress logo and cannot quite understand why this is not working in a plugin I have created.               // Hide top left WordPress logo          add_action( 'admin_bar_menu', 'remove_wp_logo', 999 );          function remove_wp_logo( $wp_admin_bar ) {         $wp_admin_bar->remove_node( 'wp-logo' );     }      Everything else in my plugin is working except this. Only difference I see in that example is that it is referring to the functions.php file? Any thoughts would be appreciated?


Custom Taxonomy and Tax_Query

I've been having a lot of trouble getting a `WP_Query` running with a `tax_query` on my custom taxonomy. I'm 99.9% sure that my `register_taxonomy` is correct, as I'm able to tag posts with the right term, see it in the database, and the correct term returns with this function: http://pastebin.com/18Aj1ysT . But when I use a `tax_query` in my `WP_Query`, I get no posts. My query is:               $nextSundayTalkArgs = array(           'post_type' => 'talk',           'posts_per_page' => 1,           'tax_query' => array(               array(                   'taxonomy' => 'talktype',                   'field' => 'slug',                   'terms' => 'sunday-talk'               )           )       );       $nextSundayTalkQuery = new WP_Query( $nextSundayTalkArgs );      It works perfectly without 'tax_query'. If I use something like 'talktype' => 'sunday-talk' instead, using query_var when I register the taxonomy, it simply ignores the line as thought it weren't there and prints any talk (instead of saying "no posts"). Inserting `<?php echo $GLOBALS['nextSundayTalkQuery']->request; ?>` gets me this:               SELECT SQL_CALC_FOUND_ROWS wp_posts.ID      FROM wp_posts WHERE 1=1     AND 0 = 1      AND wp_posts.post_type = 'talk'      AND (         wp_posts.post_status = 'publish'          OR wp_posts.post_author = 1          AND wp_posts.post_status = 'private'     )      GROUP BY wp_posts.ID      ORDER BY wp_posts.post_date DESC      LIMIT 0, 1      Using identical code to query WordPress' default "category" taxonomy works fine, so it seems to be related to my custom taxonomy or post type. To save space on this post, my custom post type code is here: http://pastebin.com/LxKt2pv5 and my custom taxonomy code is here: http://pastebin.com/NxuuxKuG I've tried including `'include_children' => false` as has been suggested, but no luck. I would appreciate any and all help, as this problem has been unsolvable for months with many people trying (and failing, unfortunately) to figure out what's wrong.


Portfolio & Blog cohabitation : multiple single.php files?

I'm currently creating a website that's going to be powered by Wordpress and have both a portfolio and a blog. How should I go about coding up the `single.php`? I understand custom post types are the way to go when it comes to a portfolio+blog setup, but when it comes to displaying the post/portfolio item in its entirety, is there such a thing as multiple `single.php` files? Thanks in advance!


whats the difference between term_id and term_taxonomy_id

the title says it all. At the moment in my custom taxonomies I'm getting the terms using the term id and taxonomy name. Thought this question would've been asked before but can't find it anywhere! So just thought I'd ask and see if anyone has any answers. cheers, daithi


Hierarchical Custom Posts - Highlighting Current Post in Sub-Menu

I have created a hierarchical custom post type called events and have used wp_list_pages to list the sub-posts for each event post (See below). This navigation works great, but I cannot figure out how to highlight the menu items based on the post being viewed. I normally use .current_menu_item, but this class is not generated for CPT. Is there any way I can add this class to the link for the current post? Thank you for your help!               //If the post has a parent, get the parent id     if($post->post_parent) {         $args = array(           'title_li'  => '',           'child_of'  => $post->post_parent,           'post_type' => 'events',           'echo'      => 0         );         //Create a variable for the parent post id          $top_page = $post->post_parent;     }     //If the post is a parent, get the post id     else {         $args = array(           'title_li'  => '',           'child_of'  => $post->ID,           'post_type' => 'events',           'echo'      => 0         );         //Create a variable for the post id         $top_page = $post->ID;       }     //List child pages     $post_children = wp_list_pages( $args );     //Get the title of the the parent page     $top_title = get_the_title($top_page);      //Get the of permalink the parent page     $top_link = get_permalink($top_page);              //If there are children, list them in a side nav         if ( $post_children ) {         ?>
             <a href="<?php echo $top_link; ?>">
<?php echo $top_title; ?>

                 <?php echo $post_children ?>


How to optimize 'select found_rows()' query? Several 'high load average' alerts daily

I have 5,000 regular posts, 6,000 posts in one post type and 2,000 posts in another post type. Needless to say, that has made the wp_posts table quite large. Not to mention, I have custom taxonomies set up to mimic the post types so for every Company A entered into Company post type, there is Company A, I manually entered Company A into Company taxonomy. That way, when I do a regular post about Company A, I can effectively 'tag' Company A into the post and then that post appears on Company A's custom post type page. Specs: Running WP Super Cache w/ Cloudflare as CDN. Theme is Wordpress TwentyEleven but heavily customized. Server: 2048 RAM, 80gb Raid, 8+CPU 4x priority, 5000GB Bandwidth. Traffic is 750k views/month & 200k uniques. I'm starting to see performance issues increase pretty rapidly with two instances in the last week where I got an 'error connecting to database' message on the site and had to restart mysql service. Not to mention, high load average emails several times a day. Ran Debug queries. Ran it with WP Super Cache. Uninstalled WP Super Cache & tried W3 Total Cache w/ most of the options enabled. In both trials, I saw the longest load time caused by these two queries (but only on the first load! Almost 0 on subsequent loads):               Time: 7.79628753662E-5     Query: SELECT FOUND_ROWS()     Call from: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/child-theme/index.php'), WP_Query->__construct, WP_Query->query, WP_Query->get_posts, WP_Query->set_found_posts, W3_Db->query, W3_DbCache->query, W3_DbCallUnderlying->query, W3_Db->query, W3_DbProcessor->query, W3_Db->default_query          Time: 6.29425048828E-5     Query: SET SESSION query_cache_type = 0;     Call from: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/child-theme/index.php'), get_footer, locate_template, load_template, require_once('/themes/child-theme/footer.php'), wp_footer, do_action('wp_footer'), call_user_func_array, Debug_Queries->the_queries, Debug_Queries->get_queries, W3_Db->query, W3_DbCache->query, W3_DbCallUnderlying->query, W3_Db->query, W3_DbProcessor->query, W3_Db->default_query      I did remove an array which made it so that we looked for posts types in addition to regular posts but that didn't seem to make a difference. Full example query output: http://pastebin.com/L0mSXe9q Also, here is the template code for the main index:                   <?php if ( have_posts() ) : ?>                  <?php /* Start the Loop */ ?>                      <?php while ( have_posts() ) : the_post(); ?>                      <?php if ( 'status' == get_post_format() ) {                          get_template_part( 'content-status', get_post_format() );                      } else get_template_part( 'excerpt', get_post_format() );                  ?>                  <?php endwhile; ?>      Really not sure where to proceed from here.


Facebook user login integration with WordPress

I am trying to use Facebook login to register users on my blog, but after users are logged into their Facebook account, their account is still not created in WordPress. I would like to have the users registered by taking their Facebook email and creating a random password. After the user is registered, they should be automatically logged in and sent to the profile page where they can update their name, add some custom user meta data and a short bio. The code for the Facebook login integration with WordPress I'm using is below: 1- // This is the login button that goes in my index/page               Rejoignez-nous sur facebook      2- // This goes in my functions.php               //create facebook href button     function FbC_head(){         if( is_user_logged_in() ) return;         ?>

                  <?php     }     add_action( 'wp_head', 'FbC_head' );//end          //load jquery if needed     function FbC_enqueue_scripts(){         wp_enqueue_script( 'jquery' );     }     //add_action( 'wp_enqueue_scripts', 'FbC_enqueue_scripts');//end          //event handler in footer     function FbC_footer(){         ?>                  <?php     }     add_action( 'wp_footer', 'FbC_footer' );//end      3- // Finally this is the function to do the registration and named according to 1- (checkFB.php)               //don't worry I don't wanna show this on http://wordpress.stackexchange.com/!     require_once('/this_is_the_path_to_my_server_/wp-load.php');     require_once('/this_is_the_path_to_my_server_/wp-config.php');          /*     $_REQUEST is sent with 2 arrays. We will retrieve the ID and then start checking.     */     $login = $_REQUEST['userResp']['id'];          //Check if the username exists already     $id = username_exists($login);     $errors = array();          //Case 1 : When the ID doesn't exist.     if(!$id) {         $email = $_REQUEST['userResp']['email'];         $existingID = email_exists($email);         //Case 1 confirmed : If the email also does not exist, we can proceed with registration.         if(!$existingID) {             $pass = wp_generate_password( $length=12, $include_standard_special_chars=false );             $userData = array();             $userData['user_login'] = $login;             $userData['user_email'] = $email;             $userData['user_password'] = $pass;             $userData['user_nicename'] = $_REQUEST['userResp']['first_name'] .' '. $_REQUEST['userResp']['last_name'];             $userData['first_name'] = $_REQUEST['userResp']['first_name'];             $userData['last_name'] = $_REQUEST['userResp']['last_name'];             $insertStatus = wp_insert_user($userData);             if(is_wp_error($insertStatus)) {                 $errors = array_merge($errors, $insertStatus->getErrorMessages());             }             else {                 wp_set_auth_cookie($insertStatus, true);             }                }         //Case 2 : When the email ID the user has attached to his FB account is also registered here.         else {             $userFB = get_user_meta($existingID, 'fbid', true);             //if a user is already attached to the email.             if(!empty($userFB)) {                 //Case 2a : Here we match the Facebook ID of the user to the facebook ID of the email ID.                 if($userFB == $login)                     wp_set_auth_cookie($existingID, true);                 else {                     array_push($errors, __("Another Facebook ID seems to be attached to your account. Please check."));                 }             }             //Create the link between the user's email ID and the facebook ID for the first time, and log him in.             else {                 if(!add_user_meta($existingID, 'fbid', $login, true)) {                     array_push($errors, __("Sorry! We were unable to link your FB account."));                 }                 else {                     wp_set_auth_cookie($existingID, true);                 }             }         }     }            //Case 3 : When the user is already registered     else {         wp_set_auth_cookie($id, true);     }          $resp = array();     if(!count($errors)) {         $resp['status'] = "Success";         $resp['loggedIn'] = true;         $resp['errors'] = $errors;     }     else {         $resp['status'] = "Failure";         $resp['loggedIn'] = false;         $resp['errors'] = $errors;     }     echo "reply(".json_encode($resp).")";


Does WordPress Development Mode Exist (with not minified JS)?

A lot of WP JS is minified and therefore it's hard to be analyzed in the Console. Is there any way to have all scripts uncompressed?


Make "sidebar template" the default template for new pages

On **_Twenty Eleven_** or on its child themes the default template for new pages is a template with **no sidebar**. I don't know why this is like this; it seems to me that the designers of Wordpress are still not thinking about CMS functionality in some places. For example the most obvious place to put a menu in a CMS is the sidebar. But with Twenty Eleven the only way to show a menu in all pages is to explicitly set all the pages to **_"sidebar template"_**. I would think it's a design bug, as the only solution so far is to tell everyone to _"don't forget to set the new pages to "sidebar template""_. I'm sure there must be a single line in `functions.php` which changes the default action but I don't know what that line is. Could you tell me what should I write in `functions.php` to set all new pages to **_"sidebar template"_** when using Twenty Eleven? _I'm sure that it has been asked before but I really couldn't find it anywhere using the search function._


What does wordpress search, search?

I just realized in testing, it appears worpress search is not matching my search term "php" with any post's tagged with "php" or in a category of "php" unless php is in the title or body, is that all the search searches for?


How can I remove the new stats message?

I've recently (latest update) been welcomed to my stats page with this annoying message: ![enter image description here](http://i.stack.imgur.com/VlATz.png) Can anyone tell me how to remove that offensive red "did you know" message? **Edit:** Looks like adding:               .gotonewdash {display: none;}      to wp-admin/css/wp-admin.min.css did the trick of hiding it, but according To Tom J Nowell, this is a big no-no. Does anyone have recommendation for doing this properly?


GUID URL Question

I had a website that needed to be re-done, so I hosted a new dev site (not locally) with a temporary domain. The dev/new site was completed and I then moved the domain from the old site to the dev/new site. All seemed to work perfectly after the domain switch, except that the images/posts for the blog are taking forever to load and I could see in the browser when loading a post it was looking for the temporary domain and not the new domain. I checked the GUID column on the database and I see all the post_type and content etc. are still using the temporary domain URL. Will it be safe to use a plugin like Blue Velvet or an SQL querie to replace the temporary domain with the original domain without breaking the site? I'm just a wee bit nervous to pull the trigger based on reading so many warnings to not touch the "GUID" column.


How to dispaly comment form error messages in the same page

I want to display comment form validation errors (as well as captcha error) on the comment form itself and not on a different page. How can I do that ?


Could the WP script/style loader be used to concatenate and gzip scripts and styles in the front-end?

WP has a nice javascript loader included in wp-admin: http://core.trac.wordpress.org/browser/tags/3.0.4/wp-admin/load-scripts.php and a CSS loader: http://core.trac.wordpress.org/browser/tags/3.0.4/wp- admin/load-styles.php I was wondering if it's possible to use them in the front-end too, not just admin, because they can concatenate all enqueued scripts, and serve them as a single gzipped file


Displaying comment counts in WP Gallery thumbnail view

Wordpress founder, Matt Mullenweg, has a great feature in his photo galleries. In thumbnail view, any photo that has a comment attached displays the comment count under the thumbnail. Look here (scroll down and you'll see some thumbnails with comment counts): http://ma.tt/2010/11/luxembourg/ He appears to be using the built-in gallery function, but I have been scouring the internet and cannot find any way to do this. Any help would be appreciated. Thanks! EDIT: It should also be noted that in this particular case I actually don't need the standard captions to show at all. Instead of adding the comment-count to the caption, I would be happy with a way to replace the standard caption with the comment count. I'm not sure if this make things any easier. Thanks!


Modifying the following code to displaying the title and the content of static page Posts page?

I read a tutorial about how to Display the contents of static page Posts page. Basically I had to place this code right before the Loop:               <?php //This is the code from the tutorial     if ( 'page' == get_option('show_on_front') && get_option('page_for_posts') && is_home() ) : the_post();      $page_for_posts_id = get_option('page_for_posts');      setup_postdata(get_page($page_for_posts_id));     ?>      <div id="post-<?php the_ID(); ?>" class="page">
        <?php the_content(); ?>        <?php edit_post_link('Edit', '', '', $page_for_posts_id); ?>

     <?php      rewind_posts();     endif;     ?>      I wanted to also include `the_content`, but instead the `the_title` of the first post (blog) entry was shown:
            <?php the_title(); ?>            <?php the_content(); ?>            <?php edit_post_link('Edit', '', '', $page_for_posts_id); ?>
      picture: ![enter image description here](http://i.stack.imgur.com/nEdKz.png) **Code:** **loop.php**               <?php     if ( 'page' == get_option('show_on_front') && get_option('page_for_posts') && is_home() ) : the_post();         $page_for_posts_id = get_option('page_for_posts');         setup_postdata(get_page($page_for_posts_id));     ?>

<?php the_title(); ?>

<?php the_content(); ?>
             <?php edit_post_link('Edit', '', '', $page_for_posts_id); ?>

                     <?php                         rewind_posts();                     endif;                     ?>
          <?php         /* Start the Loop.          *          * In Twenty Ten we use the same loop in multiple contexts.          * It is broken into three main parts: when we're displaying          * posts that are in the gallery category, when we're displaying          * posts in the asides category, and finally all other posts.          *          * Additionally, we sometimes check for whether we are on an          * archive page, a search page, etc., allowing for small differences          * in the loop on each template without actually duplicating          * the rest of the loop that is shared.          *          * Without further ado, the loop:          */ ?>     <?php while ( have_posts() ) : the_post(); ?>       (...) **blog.php:**               <?php     /**      * Template Name: Blog      * @package WordPress      * @subpackage Prominent      * @since Prominent 1.0      */     get_header(); ?>             <?php // Start the Main Loop             if ( have_posts() ) : ?>                 <?php while ( have_posts() ) : the_post(); ?>

<?php the_content(); ?>

                 <?php endwhile; ?>             <?php endif; ?>             <?php get_sidebar(); ?>

     <?php get_footer(); ?>      Any suggestions? **EDIT:** Right now I'm using the following code. It retrieves the page's specific **the_content** but when retrieving the_title, it still retrieving the first blog post.               <?php     /**      * Template Name: Blog      * @package WordPress      * @subpackage Prominent      * @since Prominent 1.0      */     get_header(); ?>

             <?php /* Display the contents of static page Posts page */             if ( 'page' == get_option('show_on_front') && get_option('page_for_posts') && is_home() ) : the_post();                 $page_for_posts_id = get_option('page_for_posts');                 setup_postdata(get_page($page_for_posts_id));             ?>                 <div id="post-<?php the_ID(); ?>" class="page">

<?php the_content(); ?>
                         <?php edit_post_link('Edit', '', '', $page_for_posts_id); ?>

             <?php                 rewind_posts();             endif;             ?>

                  <?php // find all content that has the type of video and then to loop through them. ?>                  <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>                                  <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>                                 <?php if ( is_front_page() ) { ?>
<?php the_title(); ?>
                                 <?php } else { ?>
<?php the_title(); ?>
                                 <?php } ?>
                                     <?php the_content(); ?>                                     <?php wp_link_pages( array( 'before' => '
' . __( 'Pages:', 'twentyten' ), 'after' => '
' ) ); ?>                                     <?php edit_post_link( __( 'Edit', 'twentyten' ), '', '' ); ?>

                                  <?php comments_template( '', true ); ?>                  <?php endwhile; ?>
             <?php get_sidebar(); ?>

     <?php get_footer(); ?>


database optimization and server errors

I've a self hosted wordpress blog. The server showing internal (500) server error and usually the system admins ask me to optimize my database. The database is relatively small in size and fits in few MBs. The error usually displaying is Fast CGI process. The usual reply from admins are as below > As we have checked and found that you are using Mysql database and fetching > database through php code from database server which is at remote location > and in this process when queries are being more then PHP fast cgi > application get hanged and that's why you are getting this issue, For this > you should check code or database optimization How can I optimize my database? I've installed a wordpress plugin to optimize my tables. Or is it a server problem?


WP Multisite Static Frontpage

I created a multisite and my question is as followed: Im trying to display a default static page for each new site. So when they create a new site, they automatically get a default page I made. This is the only page they need and have controle over. This page has only widgetized area's in it so that the site-admin can add content by adding widgets into the widget area's. They dont have access to create a post or page themselves. By adding a piece of code into wp-admin/includes/upgrade.php the page will be automatically made by WP whenever a new site is made. However, the page isnt connected to the template with the html/php code in it to display the widgets they add. Normally in WP you can create a page and on the right side you can select a template. Is it clear this far? (even I get confused lol) So what Im asking is.. is there a way to create a static frontpage for all newly created sites (like test.example.com and test2.example.com) with a template connected to it? Thanks in advance!!! It would make my day!


Remove action from shortcode

There is add_action() function inside function which is callback for add_shortcode(). Any idea how to remove this action with the help of custom plugin? Should I hook to any action which is called later then add_shortcode() function? I do not want to removing and re-adding shortcode, because there is huge function beyond it. Simple example:               function test_shortcode() {       ... other code ...       add_action( 'some_hook', 'custom_function');       ... other code ...     }          add_action( 'wp_head', 'setup_theme' );     function setup_theme() {       ... other code...       add_shortcode( 'test', 'test_shortcode' );       ... other code ...     }      I need to remove custom_function() from this shortcode. Thank you for your help...


Managing Backups: Space Issues

I recently reached 95% full storage on my GMail. Approximately 60% of this was, in fact, email backups from Wordpress' "WP-DB-Backup" plugin on 10+ sites that I manage. (I get a scheduled daily backup of the whole database.) There must be a better way to manage my backups. Ideally, if I can somehow automatically delete all but the most recent backup (whatever the solution is), that would be best. Sure, I can manually do this in GMail, but it's tedious and error-prone. Is there a better way to do this, or a better way to manage WP backups without worrying about HD space? GMail doesn't look like it's a good solution.


How to Append to the_excerpt() Function

I have the following snippet of code:               <?php>$more = '.....';?>
<?php the_excerpt(); ?>
      What I am trying to do is append the value of $more to the_excerpt() function but unsure how to do. I have tried:
<?php the_excerpt() . $more; ?>
      but no go. Any help would be appreciated. Thanks.   sp.


How do I direct my domain name straight to my WordPress page?

I've sifted through a lot of similar questions on Google but haven't found anything that works. I changed my Document Root section in the apache2 sites- enabled 000-default file to `/var/www/wordpress` but when I do that and go to my domain name, it just says Apache can't find the file.


Posting code inside the post instead of in the template file using shortcode

I am using two plugins one of which is Thumbs Rating which have have a shortcode like this for example in order to display the thumbs rating option: The code bellow is to be used in the templates files but I would like to have the option of using functions like the bellow and related ones inside posts using a shortcode if possible.               <?=function_exists('thumbs_rating_getlink') ? thumbs_rating_getlink() : ''?>      I add this into my post but it doesnt show instead gets parsed as normal text. Is there a way to convert the code above into a shortcode something like [thumbsrating] which I can use in my posts. ( I want to paste the shortcode at a specific spot inside my post this is the reason for doing this ) Edit: Here is the code I had created with shortcode API but it didnt work:                   function rating_function() {       return '=function_exists('thumbs_rating_getlink') ? thumbs_rating_getlink() : ''';     }     add_shortcode('rating', 'rating_function');      The result I got by adding the shortcode [rating] in my post was the return as text and not executed as PHP. Any suggestions? Thanks


How to convert hits from Top 10 plugin to WordPress Popular Posts?

How can I import/convert hits from the plugin top 10 to wordpress popular posts plugin?


Using pre_get_posts to filter out posts, pagination problem

I'm trying to figure out how to fix my pagination problem while filtering out posts on the fly. I have a dropdown box just above the category archive that allows a user to sort or filter out posts based on custom fields. The posts, filter just fine on the first page. My problem shows up the minute I filter posts from within 2'nd or deeper page because filtering them out also reduces the number of existing pages. This returns a 404 error for me. I was wondering how to modify this to also **check if the page exists** , if not... return to first page. `$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;` Updated the code as requested:               // ADD SORT QUERY VAR     add_action( 'init', 'sort_rewrite_rules' );     function sort_rewrite_rules() {         // SORT QUERY VAR         add_rewrite_tag( '%sort%', '([^/]+)' );     }          add_action( 'pre_get_posts', 'filter_pre_get_posts',11 );     function filter_pre_get_posts( $query ) {         // DON'T AFFECT WP-ADMIN SCREENS         if ( is_admin() )             return;     // SORT ADS FROM THE MAIN QUERY     $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;     $sort = get_query_var( 'sort' );     if ( $query->is_main_query() && $sort ) {                   //EXCLUDE EXPIRED POSTS         if ( 'expired' == $sort ) {             $today = date('Y-m-d H:i:s');             $metaquery = array(                             array(                                  'key' => 'expire_date',                                  'value' => $today,                                  'type' => 'DATETIME',                                  'compare' => '>'                         )                 );             $query->set( 'meta_query', $metaquery );             $query->set( 'paged', $paged );         }          }     }               <div id="sort">         <form action="" method="GET">             <select name="sort" id="sort-dropdown">          <option value="expired" <?php selected( get_query_var( 'sort' ), 'expired' ); ?>><?php _e( 'Exclude Expired Posts', 'txt' ); ?></option>             </select>             <button type="submit" id="sort-submit">Sort</button>         </form>         </div>


Display one post on category.php: Wrong featured image

**What I want** When a user opens a category link, there should be automatically displayed the first queried post. My query looks like this:                   <?php global $query_string;                 $posts = query_posts($query_string.'&posts_per_page=1&order=ASC'); ?>                  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>             <?php get_template_part( 'content', get_post_format() ); ?>             <?php endwhile; endif; ?>                  <?php wp_reset_query(); ?>      **The problem** The category URL displays the first queried content, but the wrong featured image, which is taken from the last queried post, meaning `order=DESC` is used. Any idea how to solve this? **Maybe important** The featured images are set as full screen background images via backstretch.js by using               wp_enqueue_script( 'backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/jquery.backstretch.min.js', array( 'jquery' ), '1.0.0' );     wp_enqueue_script( 'backstretch-set', get_bloginfo('stylesheet_directory').'/js/backstretch-set.js' , array( 'jquery', 'backstretch' ), '1.0.0' );          wp_localize_script( 'backstretch-set', 'BackStretchImg', array( 'src' => wp_get_attachment_url( get_post_thumbnail_id() ) ) );


How to hook into wordpress admin upload iframe?

I have written a plugin which lets the user upload file attachments for using wordpress as a download site.   So I have added a meta box which shows the user the files he has uploaded for every post. Every thing is working fine until I wanted to make it so that if a user uploads file using the built-in upload manager and then closes the ThickBox a function of mine is invoked to update that meta box for new files. In simple words, I want to be able to listen on the ThickBox close event. That's it.