What is the best way to get the first few post from WordPress in different divs using a loop?

I got the first post using the loop but I can't get the second post. I would like every post to be in a different div but the same style as the first post. To do this, I would probably need to create more loops. I want to do this so I can get a slide show with div's using jquery. The first part of the loop selects the first image in a post and the second part of the loop removes the image from the text and shows the text using the WordPress format. You can find an example here: http://www.volunteeringnews.com/index2.php Thanks you very much!

                      <?php                 $attachments = get_children(                     array(                     'post_type' => 'attachment',                     'post_mime_type' => 'image',                     'post_parent' => $post->ID                     ));                 if(count($attachments) > 0) { ?>                     <?php                         $attachments = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order'));                         if ( ! is_array($attachments) ) continue;                         $count = count($attachments);                         $first_attachment = array_shift($attachments);                         ?>                         <?php echo wp_get_attachment_image($first_attachment->ID, 'medium'); ?>                          <?php } else { ?>                                              <?php } ?>

                  <?php                      //Show first post only             add_filter('the_content', 'narga_excerpts');                 query_posts('showposts=1');                 $ids = array();                 while (have_posts()) : the_post();                 $ids[] = get_the_ID();                 //Add remove filter first image                 function remove_first_image ($content) {                 $content = preg_replace("/]+\>/i", "", $content, 1);                 return $content;}                 add_filter('the_content', 'remove_first_image');                 //Get post format                                get_template_part( 'content', get_post_format() );                 //Remove remove filter first image                 remove_filter( 'the_content', 'remove_first_image' );                 remove_filter( 'the_content', 'narga_excerpts' );                           endwhile;             ?>


Parent class for menu items don't work

I tried it with the function extracted from this page: http://codex.wordpress.org/Function_Reference/wp_nav_menu#How_to_add_a_parent_class_for_menu_item I added the code to my functions.php, but I can't find any element with the class 'parent-menu-item', despite having several pages with sub-items in my WordPress installation. What could I possibly be doing wrong here? Any other functions in my functions.php are working without problems.


the_title() shows title of the first post instead of the page title?

I'm occasionally facing this problem and not sure what causes it, any ideas?               <?php get_header(); ?>

<?php the_title(); ?>
                 <?php get_template_part( 'loop', 'index' ); ?>
     <?php get_footer(); ?>      For a normal page the_title returns "Page title". But for a blog (using loop.php as in index file above) it returns "First posts title". Any ideas?


Can't access my wp admin

I have a wp website.. i love it asit's easy to update. the website is still live and is working fine but i went to use the wp admin lastnight and for some reason it suddenly won't let me access the wp admin, it gives me a http 403 forbidden message and says this website declined to show this wep page. Please help as i really need to update it.


Image slider file 'featured.php' is not automatically sliding images (but works in local server)

I edited the Image slider file featured.php to retrieve the image files from some local folder instead of media gallery (and/or posts). It **works perfectly on local server**. But when I upload it to the site it showed up but stopped animating (sliding automatically). However, slides change when the control buttons are clicked. I tried to put back the original featured.php and looked if it works, but it didn't. I went through all the code and related scripts but can't understand the problem. Is it a javascript problem? Any ideas? (Let me add some details) it comes with a theme called "ElegantEstate". The original file looks like this:
              <?php global $ids;         $ids = array();         $arr = array();         $i=1;              $width = 954;         $height = 289;         $width_small = 49;         $height_small = 49;              $featured_cat = get_option('elegantestate_feat_cat');          $featured_num = get_option('elegantestate_featured_num');               query_posts("showposts=$featured_num&cat=".get_catId());                   while (have_posts()) : the_post();             global $post;                $arr[$i]["title"] = truncate_title(20,false);             $arr[$i]["fulltitle"] = truncate_title(250,false);                  $arr[$i]["excerpt"] = truncate_post(320,false);                  $arr[$i]["permalink"] = get_permalink();                  $arr[$i]["thumbnail"] = get_thumbnail($width,$height,'',$arr[$i]["fulltitle"],$arr[$i]["fulltitle"],false,'featured_image');             $arr[$i]["thumb"] = $arr[$i]["thumbnail"]["thumb"];             $arr[$i]["thumbnail_small"] = get_thumbnail($width_small,$height_small,'',$arr[$i]["fulltitle"],$arr[$i]["fulltitle"]);             $arr[$i]["thumb_small"] = $arr[$i]["thumbnail_small"]["thumb"];                  $arr[$i]["use_timthumb"] = $arr[$i]["thumbnail"]["use_timthumb"];                  $custom = get_post_custom($post->ID);             $arr[$i]["price"] = isset($custom["price"][0]) ? $custom["price"][0] : '';                  $i++;             $ids[]= $post->ID;         endwhile; wp_reset_query(); ?>
             <?php for ($i = 1; $i <= $featured_num; $i++) { ?>                 <?php if ($arr[$i]["title"] == '') break; ?>
                     <?php print_thumbnail($arr[$i]["thumb"], $arr[$i]["use_timthumb"], $arr[$i]["fulltitle"] ,$width, $height); ?>

                             <?php }; ?>

             <?php _e('Previous','ElegantEstate');?>                   <?php for ($i = 1; $i <= $featured_num; $i++) { ?>                 <?php if ($arr[$i]["title"] == '') break; ?>                 <a href="#" class="smallthumb<?php if ($i==1) echo(' active'); if ($i == $featured_num) echo(' last'); ?>">                     <?php print_thumbnail($arr[$i]["thumb_small"], $arr[$i]["use_timthumb"], $arr[$i]["fulltitle"] ,$width_small,$height_small); ?>                              <?php }; ?>                  <?php _e('Next','ElegantEstate');?>

            And it is included in the theme's home.php file. You can see it at http://www.addiscityservices.com/. The control buttons work but the auto sliding is off. Don't know why.


How can i show categories of custom post

I make my `custom post` and the name of that custom post is `FAQ`. so now i want to show the `categories` of that `post`. The code i am using for this is               <?php wp_list_categories('orderby=name&include=3,5'); ?>      But this not showing the post of that `custom post` type. What can i do to get the `categories` of that `custom post` type.


Integrate post tags in Post Edit page with qTranslate

# Summary In the **tags widget** in the **Post Edit page** , I need to know a way to **filter** through:   1. the **tags suggestions**   2. the **tag terms update** when **saving or updating the post** At least that is what I think I need. ![enter image description here](http://i.stack.imgur.com/FsLX0.jpg) # My Case I'm using **qTranslate** _(v.2.5.32)_ to create a multilingual frontend as well as **backend**. My concern here is **showing the translated taxonomy terms in the backend** , specifically **the post tags in the Post Edit page**. qTranslate handles taxonomy translations by using **custom fields (metaboxes)** in the **taxonomy edit page** , one for each language, which are saved to the **options table** database. The plugin translates taxonomy terms in the frontend very well, but **in the backend they don't translate**. Only terms in the **default language** are displayed despite the current language being viewed. ## My Hack So Far Now I managed to create a **hack** so that the terms in the right language would be displayed by using the code below:               if (is_admin()) {            /**        * Fix translation for:        * - Taxonomy & custom taxonomy names in Post Manage page        * - List of tags already added to the post in Post         *   Edit page (but have issues when saving)        */         function mod_wp_get_object_terms_qtranslate($terms, $obj_id, $taxonomy, $args) {              // $taxonomy output seems to be wrapped         // in single quotes, thus remove them to         // make the output valid         $tax = str_replace("'", "", $taxonomy);              if ( !is_taxonomy_hierarchical($tax) ) {                $meta    = get_option('qtranslate_term_name');           $lang    = qtrans_getLanguage();                if ( !empty( $terms ) ) {             foreach ($terms as $term) {               $term->name = $meta[$term->name][$lang];             };           };              }              return $terms;       }       add_filter( 'wp_get_object_terms', 'mod_wp_get_object_terms_qtranslate', 0, 4 );                 /**        * Fix translation for:        * - Taxonomy names in Taxonomy Manage page        * - 'Popular Tags' in Taxonomy (Tags) Manage page        * - Category filter dropdown menu in Post Manage page        * - Category list in Post Edit page        * - 'Most Used' tags list in Post Edit page        *   (but have issues when saving)        */         function mod_get_terms_qtranslate($terms, $taxonomy) {              $meta    = get_option('qtranslate_term_name');         $lang    = qtrans_getLanguage();              if ( !empty( $terms ) ) {           foreach ($terms as $term) {             if ($meta[$term->name][$lang]) {               $term->name = $meta[$term->name][$lang];             }           };         };              return $terms;       }       add_filter( 'get_terms', 'mod_get_terms_qtranslate', 0, 3 );          }      ## The Problem The problem now is in the **tags widget** in the **Post Edit page**. Though I managed to translate the list of tags that are already **added to the post** and the ones in the **'Most Used' list** , I am encountering the following issues:   1. Unable to get the **tags suggestions** to show the **translated version of the terms**. Currently it only suggests terms if I typed in terms from the default language.   2. When the post is **saved/updated** , translated tags from the **added tags list** (either newly added or the existing ones) and from the **'Most Used' list** are treated as **new tags** by Wordpress. If I added terms in the default language, then they will be saved normally. **How do I fix the above issues?** ## What I Have Tried In the first function from my hack above (ie. `mod_wp_get_object_terms_qtranslate`) I added `wp_update_term` inside the `foreach` loop so that the **term data** itself is updated to reflect the current language being viewed. I would assume this would result in retrieving the correct language in the **tag suggestion** list and in **updating the post**.               foreach ($terms as $term) {       $term->name = $meta[$term->name][$lang];            wp_update_term($term->term_id, $taxonomy, array(         'name' => $meta[$term->name][$lang]       ));          };      This didn't seem to work in that the **term data was not updated**.


How to place comments_template(); outside the loop?

I am making a new template and I need to place the comments template outside the wordpress loop and just above the footer in the single.php file. I searched on google and the best answered I could find related to my issue is in this link: http://stackoverflow.com/questions/6384205/displaying-the- wordpress-comments-template-outside-the-loop However, that did not work. The same comments are appearing on all posts. So, how can I display the comments display outsite the wp loop? EDIT: This is the single.php file               <?php     get_header(); ?>

                  <?php while ( have_posts() ) : the_post(); ?>                      <?php get_template_part( 'content-single', get_post_format() ); ?>
<?php _e( 'Post navigation', 'twentytwelve' ); ?>
                     <?php previous_post_link( '%link', '' . _x( '←', 'Previous post link', 'twentytwelve' ) . ' %title' ); ?>                     <?php next_post_link( '%link', '%title ' . _x( '→', 'Next post link', 'twentytwelve' ) . '' ); ?>                                             <?php endwhile; // end of the loop. ?>

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


How to use same theme in different languages?

I have a network of wordpress sites For example rara.org (English) rara.org/fr (French) Now I want to use the same theme which is lets say "Mytheme" for both but I also want the in the french site words like "Search" is in french, the dates that are shown are in french and so on. How can I achieve this? Please help me out.


Append 'Continue Reading' link if post length is more than 3 lines of text?

I'm pretty new to coding for Wordpress, bear with me. I have a section on my home page, that lists the 2 most recent blog posts. If the text goes past three lines, my design gets messed up. So I was wondering if there was a native function that exists for me to append 'Continue Reading' automagically and allow the user to click that link to bring them to the full blog post? For example, this is what I do NOT want: ![Bad](http://i.imgur.com/Vld41Gu.png) This, is what I do want, I did the design in Photoshop and this is what I'd like to happen if the posts are going to be longer than 3 lines of text. ![Good](http://i.imgur.com/jOiMJTC.png) Thanks, I'll try to clarify anything if need be!


Problems with moving my Wordpress site to another domain/server

I'm having problems moving a wordpress site from one domain to another. I've searched the site but couldn find a useful answer for my situation. Here's what i did: I made a backup of the website. Then i exported the database. Then i installed Wordpress on the other domain. Then i copied all my Wordpress files of the old website on the new server overwriting the new installation. Then i deleted everything from the database on the new server and imported the database of the old server. Then i changed the database name and bpassword in the wp- config file. So i did all this but the new site isn't working, and i don't know where it went wrong? So i'd like to start over, but what should i do different? Thankyou for your help!


PHP and video embed code opening in a lightbox

I have a theme that is using PHP to create a link to a specific video page via permalink:               <div class="portfolio_filter_item <?php echo $category_string;?>">

                                                     <a href="<?php the_permalink(); ?>">                                                         <img src="<?php echo $project_thumb;?>">

                                                             **<a href="<?php the_permalink(); ?>"> <?php the_title(); ?>**      Instead of referencing the permalink of the page, I need it to reference the embed code of the video on the page so I can open the link in a lightbox. I've installed a lightbox on the site that should automatically add the lightbox effect to any class "video lightbox.iframe". Any ideas? Thanks!


register_theme_directory and broken deploys

I use `register_theme_directory()` in a mu-plugin to register a custom theme directory (located at `project_root/app/views/`, with site_root at `project_root/public/` and WordPress in a Git submodule at `project_root/public/wp/`. `WP_CONTENT_DIR` is at `project_root/public/content`). I also use Capistrano to deploy my project. Every time I deploy, the site breaks, and I get this message in my Dashboard: > ERROR: The themes directory is either empty or doesn’t exist. Please check > your installation. When I navigate into the Appearance tab, my theme doesn't appear on the list until I refresh the page. After refreshing, I can see my theme, activate it, and everything works again. Why might this be happening on every deploy? I am confused as to why WordPress would think the theme doesn't exist, when it definitely does.


How do i keep my current page menu highlighted on pagination?

I have a navigation menu in a page that highlights the current menu you’re on based on the URL by adding a class. My problem is that my page is paginated, so sometimes the user will end up at: `http://example.com:4001/wordpress/calientes/page/2/` , /page/3/ , /page/4/ and so on... what’s the best way to keep my menu highlighted while the user is browsing the pages? This is my menu:

 Calientes

Tendencias

      This is the Script that use to highlight the current page menu:


How to add terms to a post depending on its title?

I want to add all posts with keyword "Dog Training" in the post title to a specific category. Reason: If you enter something into WordPress search it's not an exact match. Previous WordPress search was much more accurate but they gimped it now. Note the space between the words.


Adding custom taxonomy term on post_save for custom post type

I have a custom post type called course and a custom taxonomy called courses. What I am trying to achieve is that when a user creates a Course post, it automatically adds the post title as a Courses term.               function lms_add_course_term( $post_id ) {          if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )            return;          $post_type = get_post_type($post_id);          if ($post_type !== 'course')      return;      $course_title = get_the_title( $post_id);               // See if the post is already associated with the term     if ( has_term($course_title, 'courses') ) {     return;          }           else {           wp_set_object_terms( $post, $course_title, 'courses', true );          };           add_action( 'save_post', 'lms_add_course_term' );          }      Can't figure out what I am doing wrong. The code returns no errors but nothing else happens.


Setting comment text as required

I want to set also text comment as required... but in the backend only email and author are possible. Without using a javascript validation, how it is possible? Thank you


Filter subpages in while loop from WP Query object

I'm looking to optimize a page where I'm using several queries (with WP Query) to retrieve similar data, and I'm considering merging these queries together then filtering for relevant data once inside a loop. In one of the loops I want to not display subpages even though they are fetched with the query. I'm thinking along the lines of this -                   $query = new WP_Query();              $query->query( 'post_type=pages' );              // Menu, need to remove subpages here         while ( $query->have_posts() ) : $query->the_post();         if (!is_page(the_post());             $menu .= '
' . get_the_title() . '
';         endif; endwhile;      Not sure how to accurately use this statement though, any ideas? Edit: Never mind, solved it using "if( $post->post_parent == 0) { }" after initiating the while loop.


Getting the action's tag name within the action

There's a function attached to a set of actions, like this:               add_action('some_tag', 'the_function');          function the_function($maybe_some_vars){       // ...     }      Is it possible to find out the action name ("some_tag") within the_function? The reason I'm asking, is that I'm attaching the function to multiple actions (some of them custom, some belong to WP like `the_content`). The code that executes within the function depends on knowing the name of the action. I did manage to get it using `debug_backtrace()`, but I'm pretty sure that's not a very reliable way.


Wordpress - custom navigation item classes

I am trying to create something that looks roughly like this:

Home

About

Blog

         <button id="menu" class="menu-button" type="button" role="button" aria-label="Menu Toggle">                    </button>           Given that I am placing the button inside the navigation for mobile is controversial, however at the moment it's the least of my worries. I can't work out how to get custom classes on to my nav items. I'm using Bones as a starting point for my project and I've got most things figured out, but this one, after much googling is still to be resolved. The current function that does my nav is:               function bones_main_nav() {         // display the wp3 menu if available         wp_nav_menu(array(             'container' => false,                           // remove nav container             'container_class' => 'menu clearfix',           // class of container (should you choose to use it)             'menu' => __( 'The Main Menu', 'bonestheme' ),  // nav name             'menu_class' => 'nav top-nav clearfix',         // adding custom nav class             'theme_location' => 'main-nav',                 // where it's located in the theme             'before' => '',                                 // before the menu             'after' => '',                                  // after the menu             'link_before' => '',                            // before each link             'link_after' => '',                             // after each link             'depth' => 0,                                   // limit the depth of the nav             'fallback_cb' => 'bones_main_nav_fallback'      // fallback function         ));     } /* end bones main nav */      Any help with this would be VERY much appreciated. Because it's such a custom navigation that very specific, would I be better to just make a static nav?


On Plugin Activation, How Do I Check for Proper Transport Mechanism?

For a plugin that communicates with somewhere else, I hear we're supposed to use wp_remote_post and wp_remote_get instead of PHP's Curl library. Okay, but is there a fast and proper way on plugin execution to test for a blog's PHP/host OS to have the proper transport mechanism installed? I mean, I could attempt a test POST, but thought WP might have a better, faster mechanism that I can test for? Doing the following is unacceptable:               if (!function_exists('curl_exec')) {         wp_die('The CURL API is not installed with PHP. You cannot use this plugin without that. Ask your web hosting provider to install it.');     }


Custom Query Fields - Altering Meta Value

I'm giving Custom Query Fields a shot for filtering/sorting posts on the front-end of a site. The instructions seem pretty self-explanatory, but I do have another layer that I'm trying to figure out. For one of my custom fields, it is currently storing a fractional number. I am controlling the input so only values like `3 3/4` or `1/5` are accepted (to not break any type of fraction format). This is done due to how the values need to be displayed on the site and the specificity needed (these are for product dimensions). Then, I am using a data attribute, run through the following function to convert the fraction to a decimal:               function fraction_to_decimal($input) {         $fraction = array('whole' => 0);         preg_match('/^((?P<whole>\d+)(?=\s))?(\s*)?(?P<numerator>\d+)\/(?P<denominator>\d+)$/', $input, $fraction);         if (isset($fraction['denominator']) && isset($fraction['numerator'])) {             $result = $fraction['whole'] + $fraction['numerator']/$fraction['denominator'];             return $result;         }         else {             return $input;         }     }      The reason I am doing this on the front-end display and not in the admin is for two reasons:   1. Simplicity for the user to enter (enter in a fraction as you normally would)   2. Going from fraction to decimal suits my needs for filters using http://isotope.metafizzy.co/ The reason I am introducing `Custom Query Fields` into the mix is for my interest in removing Isotope from the setup and rely more on core WordPress filter/sort capabilities. _So - onto the actual question_ Since my meta_values are stored as a "broken" integer, `3 3/5` until they are run through that function, is there a way to intercept the meta value interpretation of Custom Query Fields to get the decimal value instead? Thanks for any help!


How to Query Database for posts with certain Taxonomy Term

I want to write a select query to return data on only posts which have are associated with the taxonomy term `food-and-beverage`               SELECT wp_postmeta . * , wp_posts.post_name     FROM wp_posts, wp_postmeta, wp_terms, wp_term_relationships     WHERE wp_posts.post_type =  'projects'     AND wp_posts.post_status =  'publish'     AND wp_posts.ID = wp_postmeta.post_id     AND wp_term_relationships.object_id = wp_posts.ID     AND wp_term_relationships.term_taxonomy_id = wp_terms.term_id     AND wp_terms.slug =  'food-and-beverage'     ORDER BY wp_posts.ID DESC       For some reason unknown to me, this is returning posts which do not have `food-and-beverage` selected As evidenced by the answer below, this is not the ideal approach, yet it is one that I've committed to, as refactoring the code (this is generated SQL, and theres lots more of it) would take me forever. **EDIT** * * * Since everyone seems to be in agreement (myself included) that the way I'm doing this is wrong, I'm going to reluctantly try to refactor. However, I'm going to leave the question open for the time being in case someone can put together a quick fix for me (I'll happily drop you some **bounty points** ). For the bold/crazy, here is a gist with a big chunk of the source: https://gist.github.com/2950395 I pass the ajax it a couple "filters" as POST variables.


Custom MySQL query to list post

I have the following query:               SELECT       p.*     FROM       orders_items oi       INNER JOIN products pr         ON pr.`post_id` = oi.`product_id`       INNER JOIN posts p         ON p.`ID` = pr.`post_id`         AND p.`post_type` = 'product'     GROUP BY oi.`product_id`     ORDER BY COUNT(oi.id) DESC;      I want to list the post based on the above query. Can anyone please tell me how can change the following code to incorporate above query?                   $args = array(             'posts_per_page' => '10',             'post_type'      => 'product',             'paged'          => '1'         );         global $query_string;         query_posts($args);      Any help guys?


How do I pass the template url to javascript in the ADMIN area of my theme?

I need to pass the path to a php file (located in a folder in my theme) to a JS file being used in my admin area but I have no idea how to accomplish that. What Im trying to do, is build a page where selecting some options in a form will pass the input's value to a php script via ajax. But because JS is client side, I dont know how to point to the correct location. I tried testing using this:               <?php       wp_enqueue_script( 'some_handle' );         $translation_array = array( 'some_string' => __( 'Some string to translate' ), 'a_value' => '10' );         wp_localize_script( 'some_handle', 'object_name', $translation_array );         wp_enqueue_script("admin", $adminDir."js/admin.js", false, "1.0");        ?>      with this in my admin.js:                console.log(object_name.some_string);       But console just reads:               ReferenceError: object_name is not defined


Add function to Simple Twitter Connect to not Tweet pages

How would I add the capability in Simple Twitter Connect (in the stc- publish.php file) to not tweet pages, either newly published or edited? I don't need it to be an admin option, just a change for a few of my sites. It looks like this function would be a good place to add the "don't tweet pages" capabilty (while retaining the check to prevent edited posts from being tweeted) as it checks for edited posts. How can one differentiate between posts and pages?               // this new function prevents edits to existing posts from auto-posting     add_action('transition_post_status','stc_publish_auto_check',10,3);     function stc_publish_auto_check($new, $old, $post) {         if ($new == 'publish' && $old != 'publish') {             $post_types = get_post_types( array('public' => true), 'objects' );             foreach ( $post_types as $post_type ) {                 if ( $post->post_type == $post_type->name ) {                     stc_publish_automatic($post->ID, $post);                     break;                 }             }         }     }      **Edit 4/03/11** Answer and better edit below.


Set default custom post type for XML-RPC

So now that it is possible to work with Custom Post Types over XML-RPC, has anyone figured out a way to set the post type for all items coming in via XLM- RPC to a default post type? IFTTT has a WordPress action that lets you create a photo post via XML-RPC. Both are coming through as default posts, and I would like to make it possible to set all posts coming in over XML-RPC to a custom-post type. Any thoughts?


Get Recent Posts by Date in Multisite

Everything in explanation is about **CDTuts** I've created a **WordPress Network** and I want is to get the recent posts from all of the selected subdomain blogs. I need to get the latest **All** organized by date and not organized by _blog ID_. I don't want to use **switch_to_blog** thus, using foreach, because I'm only looping posts within the next blogs I switch. I want to actually combine the posts and have them all organized by date. I'd figure you'd have to do this by querying mysql instead of using WP_Query. But I was hoping for a more native way of doing this. This is for the list of posts to be made at the bottom of the front page as you can see with timestamps that aren't ascended or descended by the number greater or lesser. I even tried doing something like this, but this wouldn't work either. Sorting the post by Unix timestamp, to only realize that the posts are still being organized by **switch_to_blog** instead of a timely manner.               <?php                    switch_to_blog(1);         $main_posts = get_posts();         switch_to_blog(2);         $php_posts = get_posts();         switch_to_blog(3);         $wp_posts = get_posts();         switch_to_blog(4);         $mac_posts = get_posts();         switch_to_blog(4);         $psd_posts = get_posts();         switch_to_blog(1);              $posts = array_merge($main_posts, $php_posts, $wp_posts, $mac_posts, $psd_posts);         usort($post, get_post_time);              foreach($posts as $post){         ?>
<a href="<?php echo the_permalink(); ?>">

                     <?php echo the_title(); ?>
 <?php echo get_post_time(); ?>

         <?php }              ?>      I've also created a function where I can select the ID of the blog using **switch_to_blog**. This will only work on the tiles at the top of the front page. But I'm also trying to do the same for the latest posts at the bottom. I won't be able to create an offset so that I can keep the tile design while maintaining the 6 latest posts. This was based on a previous answer on StackExchange               function global_latest_post($LatestBlogNumber,$LatestPostNumber, $LatestThumbSize, $LatestThumbNumber) {         $original_blog_id = get_current_blog_id();         $bids = array($LatestBlogNumber);                  foreach($bids as $bid) {             switch_to_blog($bid);             $tiles = new WP_Query('posts_per_page=1');             while ($tiles->have_posts()) : $tiles->the_post(); ?>                 <a href="<?php echo the_permalink(); ?>" class="<?php echo $LatestThumbSize; ?> thumb-<?php echo $LatestThumbNumber; ?>">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Read More →

<?php echo $LatestPostNumber; ?>. <?php echo the_title(); ?> in <?php bloginfo('name'); ?>
                              <?php                        endwhile;         }         switch_to_blog( $original_blog_id ); //switched back to current blog     }


How to show the homepage on a different url, like site.com/blog instead of site.com?

I have Wordpress installed in my root directory, so if you go to site.com you see the list of recent posts. What I want to do is to have the homepage show a static page instead showing recent news etc (I've figured out how to do this), however if someone goes to site.com/blog/, I want to show a list of the recent posts the same way as they show up right now on the homepage. Can I do this - if so, how? P.S the other url doesn't have to be called /blog/, it can be anything, e.g site.com/recent/ or site.com/archive/ would also work. Thanks.


Change menu item order

My primary navigation menu consists of pages, categories, and custom taxonomy. It appears to be in a random order. How do I adjust the order of the links? (the drag/drop in wp menus panel doesn't seem to have any effect)


OOP Plugin: Where should I place the action hooks in the class?

Where in my admin class should I place the action hooks for adding css, scripts and the add menu page? In the __construct? Or should they be placed in a method?


Hook into admin_notices after sending mail

In my (admin) plugin I want to display a message using `admin_notices` action on successful sending of mail. Currently it is not displaying. I know this has something to do with the order of events, but I cannot figure out how to structure it so that the message displays. Currently I'm adding the `admin_notices` action from within an `init` action callback. I'm not sure if this is allowed and therefore this may be the issue. However, if I add it to the `__construct` method, how can I get it to know that the mail has been sent? Currently my `Send_mail` class looks something like:               class Send_mail {         public function __construct() {             add_action('init', array($this, 'send_mail'), 30 );         }              public function send_mail() {             if (!isset($_POST['send-confirmation-true'])) {                 return;             }                  // wp_mail() functionality             // returns true on successful send                  if ($mail_sent == true) {                 add_action('admin_notices', array($this, 'show_admin_notice') );             }         }              public function show_admin_notice() {             // output admin notice html         }     }      === EDIT === After doing some testing, I've found out that actions called after the following if-statement:               if (!isset($_POST['send-confirmation-true'])) {         return;     }      only work if they are hooked to an action that is either `load-(page)` (in my case: `load-post.php`) or before in the action order list. The action I need is `admin_notices` and therefore does not get added. What is causing this behaviour?


Easy way to write complex queries in wordpress

I want to run one sql query like this in wordpress. Just wanted to know if there is an easy way to do this in wp. Thanks. Is this query possible with the use of query_posts anyhow? ` select p1.meta_value as `avg`,p2.meta_value as total,p1.meta_value*p2.meta_value as product from wp_postmeta as p1, wp_postmeta as p2 where p1.meta_key = 'crfp-average-rating' and p2.meta_key = 'crfp-total-ratings' and p1.post_id = p2.post_id; `


Using a private method as an action callback from within a class

I have created a class from within which I would like to call a private method (from within the same class) from the `__construct` method as an action callback. When I would like to use a public method I can access it by:               add_action( 'init', array( $this, 'action_callback' ) );      However, this causes an error when the method is private. I have also tried unsuccessfully:               add_action('init', $this->action_callback() );      How do I access a private method? The class looks something like:               class My_class {         public function __construct() {             add_action( 'init', array( $this, 'action_callback' ) );         }              private function action_callback() {             // do something         }     }


Is there a way to add another row to the tinyMCE kitchen sink toggle?

The tinyMCE "kitchen sink" toggle button shows/hides a row of buttons. I have successfully added my row of shortcode buttons to the tinyMCE editor, but I was wondering if there was a way to make my row only display when the kitchen sink button is clicked. I don't want to add the buttons directly to the kitchen sink row because I have lots of buttons that need their own row. So, can I make the kitchen sink button show two rows instead of one? Or is there some sort of modifier when I add my row to indicate that it should be toggled when the kitchen sink button is clicked? Here is the code I'm using to add my third row of buttons:                   // add shortcode buttons to the tinyMCE editor row 3     function add_button_3() {        if ( current_user_can('edit_posts') &&  current_user_can('edit_pages') )        {          add_filter('mce_external_plugins', 'add_plugin_3');          add_filter('mce_buttons_3', 'register_button_3');        }     }     //setup array of shortcode buttons to add     function register_button_3($buttons) {        array_push($buttons, "dropcap", "divider", "quote", "pullquoteleft", "pullquoteright", "boxdark", "boxlight", "togglesimple", "togglebox", "tabs", "signoff", "columns", "smallbuttons", "largebuttons", "lists");          return $buttons;     }     //setup array for tinyMCE editor interface     function add_plugin_3($plugin_array) {        $plugin_array['lists'] = get_bloginfo('template_url').'/js/customcodes.js';        $plugin_array['signoff'] = get_bloginfo('template_url').'/js/customcodes.js';        $plugin_array['dropcap'] = get_bloginfo('template_url').'/js/customcodes.js';        $plugin_array['divider'] = get_bloginfo('template_url').'/js/customcodes.js';        $plugin_array['quote'] = get_bloginfo('template_url').'/js/customcodes.js';        $plugin_array['pullquoteleft'] = get_bloginfo('template_url').'/js/customcodes.js';        $plugin_array['pullquoteright'] = get_bloginfo('template_url').'/js/customcodes.js';        $plugin_array['boxdark'] = get_bloginfo('template_url').'/js/customcodes.js';        $plugin_array['boxlight'] = get_bloginfo('template_url').'/js/customcodes.js';        $plugin_array['togglesimple'] = get_bloginfo('template_url').'/js/customcodes.js';        $plugin_array['togglebox'] = get_bloginfo('template_url').'/js/customcodes.js';        $plugin_array['tabs'] = get_bloginfo('template_url').'/js/customcodes.js';         $plugin_array['columns'] = get_bloginfo('template_url').'/js/customcodes.js';        $plugin_array['smallbuttons'] = get_bloginfo('template_url').'/js/customcodes.js';        $plugin_array['largebuttons'] = get_bloginfo('template_url').'/js/customcodes.js';        return $plugin_array;     }     add_action('init', 'add_button_3'); // add the add_button function to the page init      However, the row that adds is not toggled by the kitchen sink button.


Access the environment of an admin page from another admin page

I've been busy thinking about a problem, and so far I didn't find a solution to it. ### The _abstract_ scenario On admin page A, I would like to print the value of a (global) variable--in the context of admin page B, though. ### The _concrete_ scenario On a custom user-options page, I would like to list all metaboxes registered for each post type. Both plugins and the theme can add/remove metaboxes with respect to the current page context (`$pagenow`). Thus, the `$wp_meta_boxes` global is set up in that context. * * * So far, I've read into virtually any hook, read a lot on AJAX (the right and the wrong ways), and tried out numerous different approaches I came up with. Unfortunatly, without luck. ### The question Is it possible to retrieve the value of `$wp_meta_boxes` on admin page `post- new.php?post_type=my_super_duper_post_type`, for instance, from another admin page? If so, how would I go about that? Can this be done via AJAX?   Or can I trick the plugins/theme into thinking that the current page is `post- new.php?post_type=my_super_duper_post_type`, for instance, while we're actually on my options page?


Custom taxonomy meta fields

I'm trying to make an anime site like myanimelist.net but in spanish with links of the episodes at the bottom. I created a post type called anime, and some custom taxonomies associated with it: series, movies, ovas, specials, live action, producers, themes, genres, and characters. I used advanced custom fields to assign meta fields to the taxonomies with fields like image, synopsis, type, alternative title, episodes, status, aired, producers, genre, themes, duration and rating. Here is what i want to do: Make one template for all the terms from series that displays the fields that i assigned to each one. So people could visit the term and see the information about the series. Example www.example.com/series/one-piece and it shows the information about that specific series. At the bottom they could see the link to each episode(post) assign to that term. I would like someone to help me make that template if its possible or tell me if I'm doing it right using taxonomies with metafields if its not the best way to do what i want to accomplished, point me in the right direction. I been trying to learn how to code php so i know a little, had read about 200 pages of a couple php book while at work but i understand some of the code if a see it. I would really appreciated the help. Thanks a lot in advanced! PD: I can't use Organize Series plugin as that would be only for the series taxonomy and i need it for movies, ovas, specials, etc...


Multiple meta_values in the pre_get_posts filter?

I have a custom post type with custom fields, the one in particular is "zip". I also have an array that stores like 20 different zip codes. I want to check to see if any of those custom post types have one of those zip codes. If they do, then I want them to appear in the search results. If they don't, I don't want them to appear. How would I go about doing this..? It's driving me insane. Thanks in advance.


How to edit the text below "Leave a Reply"

I use the Twenty Ten theme, customized. The theme text is: Your email address will not be published. With the email box below, this gives readers the impression that they must enter an email address, yet I set my settings so one is not required. I'd like to edit the text to read: You do not have to leave an email address in order to reply. Can this be done? If so, how? Thank you.


Is there any wordpress plugin available to auto share comments?

I'm trying to achieve like this. See the image. ![enter image description here](http://i.stack.imgur.com/2jjhC.png) Is there any good free or premium plugin available to add this feature? I know there are some plugins out there like janrain,gigya. But those plugins have limits in free version. Their fee also high. So i don't like their plugin. Any other good plugin available? Thanks


Set wp-content folder to Dropbox folder

Ideally I would like to do this with both my PC and Mac OSX boxes, but for now I would be thrilled with just the Mac OSX. I am trying to keep my WP Themes & Plugin Local Development synced using Dropbox. I am using XAMPP for both Windows and Mac as my LAMP Stack and am wondering what I have to set in order to get the Mac. Based off the Codex I can do this via setting these two items:               define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/somedir');     define('WP_CONTENT_URL', 'http://example.com/somedir');      I am successful in changing `WP_CONTENT_DIR` to _/Users/seth/Dropbox/Xammp- Content/wordpress/wp-content/_ , which allows me to see my available themes and activate them, however any of the resources (styles.css, images, etc.) doesn't resolve and thus I have a bunch of failed GETs on the resources and the theme is unstyled. Upon further inspection this is the URL resolved for styles.css > _http://localhost:8080/wp-content/themes/[theme-name]/styles.css_ Which again is a failed resource to load. I have no idea what to set `WP_CONTENT_URL` to... Any help? Appreciate it.


How to configure Wordpress to be a subdirectory of my main site as mymainsite.com/blog?

I have developed a site www.mainsite.com based on Ruby on Rails hosted on Heroku. I have also developed a blogging site based on Wordpress at blog.mainsite.com hosted on Dreamhost. I want our users to interact with www.mainsite.com/blog instead of blog.mainsite.com. I have each site function correctly, and the DNS setup correctly. I also set up reverse proxy in Rails to route traffic reverse_proxy /^/blog(/.*)$/, 'http://blog.mainsite.com$1', opts={:preserve_host => true} Most of the time it work. After I messed with the permalinks and restored it, now in Wordpress, whenever I upload a media file (image), it always sends me to www.mainsite.com/wp-admin (404) instead of www.mainsite.com/blog/wp-admin. What is the problem?


How to map sub-directory to second wordpress multisite?

I have setup a two sites using one wordpress installation. The issue that I have now is that I can only access each site via `/blog/` and `/blog/support/`. I want to access the support section using `/support/`. So I created a symlink to the blog directory using a new directory named support. Although this does take me to my wordpress install. It is having issues loading up site 2 even though I have changed the site 2 home and siteurl to `/support/`. All it does is throw a 404 error. How do I get a multi-site wordpress install to work with sub-directories? There is a lot of documentation for multi-domain mapping but not much for the above.


How can I make a custom post type that loops pages in a new dashboard page, each single page is a new dashboard page (all within the back-end)?

I've been wanting to make the most out of WordPress, to use it more and more like a CMS as it truly is a wonderful project. Out of all the CMS/Blogging webapps, WordPress wins in my book. I understand how to create a post-type. What I don't understand is how to make pages within the dashboard, and how to add a sidebar menu item with the links. Also, I would like to know how to make the new posts of the custom post-type display only on the dashboard, as a back-end documentation base, or CRM. Of course I could always use a plugin, but then the opportunity for not only myself to learn would be lost, the opportunity to show the many visitors of this site how to achieve the same thing would be lost as well. Let the Answers begin! P.S. I'm so very grateful for all of the help you all give to the community here. I've searched for this topic and couldn't find it, if this topic is already answered here, please comment with the link to the question with the answer. Thanks!


Permalink Trouble with custom post types

When using custom post types I reach a dilemma where I have to use flush_rewrite_rules(); when using a permalink structure, otherwise it goes to a 404. After using it It works on one CPT but if you have 2 or 3, I still have the same problem and have to back to the basic permalink settting. If you could help me, that would be great.               add_action('init', 'video_register');          function video_register() {          $labels = array(         'name' => _x('Video', 'post type general name'),         'singular_name' => _x('Video', 'post type singular name'),         'add_new' => _x('Add New', 'Video'),         'add_new_item' => __('Add New Video'),         'edit_item' => __('Edit Video'),         'new_item' => __('New Video'),         'view_item' => __('View Video'),         'search_items' => __('Search Video'),         'not_found' =>  __('Nothing found'),         'not_found_in_trash' => __('Nothing found in Trash'),         'parent_item_colon' => ''     );          $args = array(         'labels' => $labels,         'public' => true,         'publicly_queryable' => true,         'show_ui' => true,         'query_var' => true,         'menu_icon' => null,         'rewrite' => true,         'capability_type' => 'post',         'hierarchical' => false,         'menu_position' => null,         'taxonomies' => array('post_tag'),         'supports' => array('title','editor','thumbnail','custom-fields',   'comments',)                 );           register_post_type( 'video' , $args );     flush_rewrite_rules();     }      This is what I'm adding for my custom post type. Thank you.


Can't activate Plugin: unexpected T_STRING, expecting T_FUNCTION

I'm writing a plugin but have a problem. I wanted to make an upload form for my existing plugin, so I don't need to upload every picture with the Media Uploader and Copy&Paste the URL in the form. I used this tutorial: Tutorial Now, when I wanted to install the updated Plugin I get the following error message: > Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in > /var/www/intern/wpkkbk/wp-content/plugins/widget-plugin.php_/widget- > plugin.php on line 133 The code I added looks like this (line 133: `add_action(...)`):               function my_admin_script($hook) {         if ($hook != 'widgets.php')             return;                       wp_enqueue_media();             wp_register_script('my-admin-js', plugins_url('widget-plugin.php_/js/upload.js', dirname(__FILE__)), array('jquery'));             wp_enqueue_script('my-admin-js');          }     add_action('admin_enqueue_scripts', 'my_admin_script');      I don't know, where I made a mistake. It didn't even work, when I used the exact same code from the tutorial. Any suggestions!


Wordpress admin bar showing pending comments which cannot be selected or modified after deleting parent page

My Wordpress admin interface shows there are 4 pending comments, but I've already approved three and deleted one of them via Disqus comment moderation page, but the page they were posted on was later deleted. I then posted two comments myself on a test page, deleted the page, and they are still shown as pending on Wordpress admin. How do I remove them from pending comments list? Page the comments have been posted to is removed, so they do not have anything in "in response to" column, these comments also do not have a checkbox next to them, so I can't select them. There are also no options appearing when hovering above the comment on pending comments moderation page. I just recently installed WordPress to my site and it doesn't have anything custom but Disqus. * * * I am absolutely new to WordPress, so please explain each step of possible solution in detail.


How can i do something after head like adding a hook for after head but before post

What i mean is i am trying to add breadcrumbs to my blog and i thought of adding it before content or after title but there's an issue with that - on archive pages or category pages the breadcrumbs appear for every posts. so i figured i have to attach the breadcrumbs to something above the post - like the head. how can i do that ? this is what I've done so far for the content:               add_filter( 'the_content', array($this, 'adding_bread_crumbs') );     function adding_bread_crumbs( $content ) {         /* Getting the current page permalink and site url */         $pageURl = preg_replace('/\/$/','',get_permalink());         $homeURL = preg_replace('/\/$/','',site_url());              if ( function_exists('yoast_breadcrumb')) {             /* Checking if the current page is home page */             if($pageURl != $homeURL && !is_page('Home')){                 $breadcrumbs = '
';                 $breadcrumbs .= yoast_breadcrumb('
','
',false);                 $breadcrumbs .= '
';                 $content = $breadcrumbs.$content;             }         }         return $content;     }      Is there anything that would replace 'the_content' another hook maybe? or is there an action i have to use ? Thanks


How can I hook into creating a new post and execute wp_die(), before the post is inserted into the database?

Info about wp_die from codex: Kill WordPress execution and display HTML message with error message. A call to this function complements the die() PHP function. The difference is that HTML will be displayed to the user. It is recommended to use this function only when the execution should not continue any further. I have code:               function myHook( $post_ID, $post )     {          wp_die('Error', 'Error',  array( 'response' => 500, 'back_link' => true ));     }     add_action( 'save_post', 'myHook', 0, 2 );      Problem is that error page appears, but post is still inserted. Shouldn't saving be interrupted by this hook? If I misunderstood description, how can I break execution so post will not be saved? EDIT: I just found that save_post is called after instert to database not before. Does there exist any function called before insert that i can hook into? Thanks in advance


Get author custom image field URL to display on post page?

I'm using advanced custom fields and have setup an image field for my users to add an image in their profile. I'd need to display this image on post pages, so i've tried the following...               <?php     $attachment_id = the_author_meta('author_logo');     ?>     <?php echo the_author_meta('author_logo'); ?>     <?php wp_get_attachment_image_src( $attachment_id )?>      <?php wp_get_attachment_url( $attachment_id ); ?>      The output is always the image attachment ID never the URL. What can I change to output the image path URL? Thanks


Show subcategories and hide posts or show posts if not exists subcategories

I'm trying to make a WordPress blog where in the index page only Parents Categories appear. In second page need to appear SubCategories and hide posts, if not exists SubCategories show posts for the Parent Category. Here is the structure.


Can my "add_action" function know the name of the hook calling it?

Lots of hooks:               add_action('thesis_hook_after_comment', 'pj_time');     add_action('thesis_hook_after_comments', 'pj_time');     add_action('thesis_hook_after_comment_box', 'pj_time');     add_action('thesis_hook_after_comment_meta', 'pj_time');     add_action('thesis_hook_after_content', 'pj_time');     add_action('thesis_hook_after_content_area', 'pj_time');     add_action('thesis_hook_after_content_box', 'pj_time');     add_action('thesis_hook_after_footer', 'pj_time');     add_action('thesis_hook_after_header', 'pj_time');     add_action('thesis_hook_after_headline', 'pj_time');     // etc.      How can `function pj_time()` know which hook called it? Is there a global variable or something that tells me which hook we're on? So pj_time() could output something like: "The hook (name of hook here) rocks." I don't know the order the hooks are called either, they're just in alphabetical order here. Otherwise I could use a counter to figure how many hooks we've done so far and determine the name of the hook that way. So I want to know if it's possible to get the name of the hook. Thanks.


Custom Posts Types as Custom Fields

I have three Custom Post Types: Book, Volume and Chapter where one Book can contain many Volumes and one Volume can contain many Chapters. I want to do something like this:   1. The user access "Books" ![enter image description here](http://i.stack.imgur.com/8HbQL.png)   2. The user select a book for editing and, inside that page, on the meta box, he can add/edit just the volumes relating to that book ![enter image description here](http://i.stack.imgur.com/JArg2.png)   3. The user select a volume for editing and, inside that page, on the meta box, he can add/edit just the chapters relating to that volume ![enter image description here](http://i.stack.imgur.com/wpY5K.png)   4. The user finally select a chapter to edit ![enter image description here](http://i.stack.imgur.com/N8cLt.png) I initially thought of putting an iframe inside the meta box area on the post types using the `src` attribute as `edit.php?post_type=post_type` with some filters on its query string, to list just the post type related to the respective page. What would be best in that situation? Is that a pattern on WordPress to work with situations like that, where Custom Post Types needs to be Custom Fields of another Custom Post Type, i.e. one to many entity relationship?


How to get variation by order id on WooCommerce?

I am trying to get variation from `wp_woocommerce_order_itemmeta` by order id. My products have detail terms but I can't find them. It looks like this on `wp_woocommerce_order_itemmeta`:               431 52 _variation_id 27978      432 52 _line_subtotal 30000      433 52 _line_total 30000      434 52 _line_tax 0      435 52 _line_subtotal_tax 0      436 52 Duration 7       And I have been trying to get many ways... but I can't really get them. I need to get "Duration" or "veiw_resume" value by order id               function check_quantity($order_id) {              global $wpdb;              $order = new WC_Order( $order_id );         $items = $order->get_items();              foreach ( $items as $item ) {             $product_name = $item['name'];             $product_id = $item['product_id'];             $product_variation_id = $item['variation_id'];             $pa_version = $item['pa_version'];         }                    $versionvalues = get_the_terms( $product_id);              foreach ( $versionvalues as $versionvalue ) {             //echo $versionvalue->name;             $pa_version2=$versionvalue->name;         }              //$result = array_shift(woocommerce_get_product_terms($product_id, 'pa_view-resumes', 'all'));              /*global $wpdb;         $result = $wpdb->get_results('select t1.order_item_id, t2.* FROM          wp_woocommerce_order_items as t1 JOIN wp_woocommerce_order_itemmeta as t2 ON t1.order_item_id = t2.order_item_id         where t1.order_id='.$order_id);         echo '<pre>';         print_r($result);         echo '</pre>';          */              //get item-meta for job/resume         //$wpdb->get_results ( "SELECT * FROM wp_woocommerce_order_items" );              //Resume-27905-27979              $metakey    = "order_info_kcm";         $metavalue  = $product_name."-".$product_id."-".$product_variation_id."-".$pa_version."-".$pa_version2."-".$result;              $wpdb->query( $wpdb->prepare( "INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value ) VALUES ( %d, %s, %s )",              $order_id,              $metakey,              $metavalue              ) );


How do I pass a post ID to the page URL?

I am using a form (gravity form) on my site. The form is inserted in a page (called form_page) on the users dashboard when they are logged in `http://example.com/dashboard/form_page` I am using a plugin (see below) to dynamically populate the form with content from the post the user is author to. However I need to pass the POST ID to the URL for it to work. So the URL would end up looking like this `http://example.com/dashboard/form_page?gform_post_id=476` This works. However, I am manually appending the `?gform_post_id=476` to the end of the URL to test the concept actually works and it does. However I have no idea how to dynamically pass this post ID to the end of the URL of the page for an Author who is logged in. It might help to know that the "Author" will only have 1 post associated with them. So (out loud) I am thinking there might be a way to GET the POST_ID associated with the logged in USER and then pass it to the URL of that particular page. I am just not sure how to connect the missing piece of this puzzle and would appreciate some guidance. Cheers in advance... My effort so far is as follows `<?php foreach(get_posts(array('author' => $author_id)) as $post)?> <a href="http://example.com/dashboard/form_page?gform_post_id=<?php echo $post->ID ?>">Link</a>` But this seems to get first POST ID the site. Not the ID of the Authors POST. Note: It is a custom post. Plugin used: http://wordpress.org/extend/plugins/gravity-forms-update-post/


Show widget when not using SSL

My wordpress site supports http and https. What I want to do is to add a widget when surfing over http that says something like "Surf this site secure" to show the visitor that I also have a secured version. I don't want to force them to surf over SSL because I'm using a type of certificate that's not supported on Windows XP. Now how can I do this?


How do I copy a wordpress database?

I'm trying to migrate my wordpress site from an old host to a new host. The Wordpress Codex says "you can move by just copying your files and database." Copying the files is easy enough, but how do I copy my database? I'm sure I'm just not looking in the right places, but I can't find any documentation on this anywhere.


Get author and excerpt from URL

Trying to be tricky here, I want to show a list of articles with their author and excerpt. I'm using a custom field and want the user to just be able to list the URLs on their own line and that's it. Is there a way to look up the non-rewritten url based on the friendly one? Then just pull the article ID from there via regex? To further clarify: Say this is the URL http://www.site.com/2013/10/wearable-tech-trends- element14.html Can I take it back (decode) to? http://www.site.com/?p=123 So I can grab the 123 and use that to find the author and excerpt.


How to remove message output for the WP-PostRatings Plugin?

When the user clicks on the _vote_ image, the image changes to the _voted_ state. If the user clicks the image in the _voted_ state again, a message pops up saying: > You Had Already Rated This Post. Post ID #X I want it so that this message does not pop up and the 'voted' image stays as is. Below is what I believe to be the relevant code needed to make this change. It is from lines 558-633 of _wp-postratings.php_. If someone can take a look and let me know what I need to change, I'd be very grateful.               ### Function: Process Ratings     process_ratings();     function process_ratings() {         global $wpdb, $user_identity, $user_ID;         $rate = intval($_GET['rate']);         $post_id = intval($_GET['pid']);         if($rate > 0 && $post_id > 0 && check_allowtorate()) {                   // Check For Bot             $bots_useragent = array('googlebot', 'google', 'msnbot', 'ia_archiver', 'lycos', 'jeeves', 'scooter', 'fast-webcrawler', 'slurp@inktomi', 'turnitinbot', 'technorati', 'yahoo', 'findexa', 'findlinks', 'gaisbo', 'zyborg', 'surveybot', 'bloglines', 'blogsearch', 'ubsub', 'syndic8', 'userland', 'gigabot', 'become.com');             $useragent = $_SERVER['HTTP_USER_AGENT'];             foreach ($bots_useragent as $bot) {                  if (stristr($useragent, $bot) !== false) {                     return;                 }              }             header('Content-Type: text/html; charset='.get_option('blog_charset').'');             postratings_textdomain();             $rated = check_rated($post_id);             // Check Whether Post Has Been Rated By User             if(!$rated) {                 // Check Whether Is There A Valid Post                 $post = get_post($post_id);                 // If Valid Post Then We Rate It                 if($post && !wp_is_post_revision($post)) {                     $ratings_max = intval(get_option('postratings_max'));                     $ratings_custom = intval(get_option('postratings_customrating'));                     $ratings_value = get_option('postratings_ratingsvalue');                     $post_title = addslashes($post->post_title);                     $post_ratings = get_post_custom($post_id);                     $post_ratings_users = intval($post_ratings['ratings_users'][0]);                     $post_ratings_score = intval($post_ratings['ratings_score'][0]);                         // Check For Ratings Lesser Than 1 And Greater Than $ratings_max                     if($rate < 1 || $rate > $ratings_max) {                         $rate = 0;                     }                     $post_ratings_users = ($post_ratings_users+1);                     $post_ratings_score = ($post_ratings_score+intval($ratings_value[$rate-1]));                     $post_ratings_average = round($post_ratings_score/$post_ratings_users, 2);                     if (!update_post_meta($post_id, 'ratings_users', $post_ratings_users)) {                         add_post_meta($post_id, 'ratings_users', $post_ratings_users, true);                     }                     if(!update_post_meta($post_id, 'ratings_score', $post_ratings_score)) {                         add_post_meta($post_id, 'ratings_score', $post_ratings_score, true);                     }                     if(!update_post_meta($post_id, 'ratings_average', $post_ratings_average)) {                         add_post_meta($post_id, 'ratings_average', $post_ratings_average, true);                         }                     // Add Log                     if(!empty($user_identity)) {                         $rate_user = addslashes($user_identity);                     } elseif(!empty($_COOKIE['comment_author_'.COOKIEHASH])) {                         $rate_user = addslashes($_COOKIE['comment_author_'.COOKIEHASH]);                     } else {                         $rate_user = __('Guest', 'wp-postratings');                     }                     $rate_userid = intval($user_ID);                     // Only Create Cookie If User Choose Logging Method 1 Or 3                     $postratings_logging_method = intval(get_option('postratings_logging_method'));                     if($postratings_logging_method == 1 || $postratings_logging_method == 3) {                         $rate_cookie = setcookie("rated_".$post_id, $ratings_value[$rate-1], time() + 30000000, COOKIEPATH);                     }                     // Log Ratings No Matter What                     $rate_log = $wpdb->query("INSERT INTO $wpdb->ratings VALUES (0, $post_id, '$post_title', ".$ratings_value[$rate-1].",'".current_time('timestamp')."', '".get_ipaddress()."', '".@gethostbyaddr(get_ipaddress())."' ,'$rate_user', $rate_userid)");                     // Output AJAX Result                     echo the_ratings_results($post_id, $post_ratings_users, $post_ratings_score, $post_ratings_average);                     exit();                 } else {                     printf(__('Invalid Post ID. Post ID #%s.', 'wp-postratings'), $post_id);                     exit();                 } // End if($post)             } else {                 printf(__('You Had Already Rated This Post. Post ID #%s.', 'wp-postratings'), $post_id);                 exit();              }// End if(!$rated)         } // End if($rate && $post_id && check_allowtorate())     }      * * * _EDIT: You can find the Pluginhere_


Looking for Plugin that displays Facebook group's photos

There are several plugins that handle the auto retrieval/display of photos from my personal facebook profile, but i'm looking for one that will work w/ my facebook group. the group is way more active than the actual website and it'd be a bonus for the website to pull more content from FB. have already looked at: Facebook Photo Fetcher Fotobook neither would allow me to grant access to the group's photos even though i am an admin. i'm sure there were a few more but it was a while back and i must have deleted them out of my plugins directory.


How do I check if a menu exists?

I'm currently retrieving a nav menu based on the parent page's title, and if the page doesn't have a parent then it's own title.               global $post;     $page_title;          if ($post->post_parent) {         $page_title = get_the_title($post->post_parent);     }  else {         $page_title = get_the_title($post);     }          $sidebar_title = 'Sidebar - '.$page_title;     wp_nav_menu(array( 'menu' => $sidebar_title));      Instead of first checking for a parent, I'd like to first check if a page has it's own unique menu. This is what I wrote but it doesn't work:               global $post;     $page_title = get_the_title($post);     $sidebar_title = 'Sidebar - '.$page_title;          if ( !wp_nav_menu(array( 'menu' => $sidebar_title, 'echo' => false )) ) {              $page_title = get_the_title($post->post_parent);         $sidebar_title = 'Sidebar - '.$page_title;     }          wp_nav_menu(array( 'menu' => $sidebar_title ));      TLDR: How do I check if a menu exists?


Order get_terms() By Custom Field

I want to order my categories like I order my pages. I've added an extra field called _Order_ to my taxonomy, but how do I order my terms by this value? Adding and Saving my Order Value:               /** Add New Field To Category **/     function extra_category_fields( $tag ) {         $t_id = $tag->term_id;         $cat_meta = get_option( "category_$t_id" );     ?>
         <?php _e('Category Order'); ?>
                 <input type="text" name="cat_meta[order]" size="3" style="width:5%;" value="<?php echo (isset($cat_meta['order'])) ? $cat_meta['order'] : '0'; ?>" />
             <?php _e('Categories are ordered Smallest to Largest'); ?>
     <?php     }     add_action('protax_edit_form_fields','extra_category_fields');            /** Save Category Meta **/     function save_extra_category_fileds( $term_id ) {         if ( isset( $_POST['cat_meta'] ) ) {             $t_id = $term_id;             $cat_meta = get_option( "category_$t_id");             $cat_keys = array_keys($_POST['cat_meta']);                 foreach ($cat_keys as $key){                 if (isset($_POST['cat_meta'][$key])){                     $cat_meta[$key] = $_POST['cat_meta'][$key];                 }             }             //save the option array             update_option( "category_$t_id", strip_tags($cat_meta) );         }     }     add_action ( 'edited_protax', 'save_extra_category_fileds');      Normally I could retrieve this value such as:               $categories = get_categories(array('taxonomy' => 'protax'));     foreach($categories as $cat){         $tmp = get_option('category_'.$cat->cat_ID);         echo $tmp['order'];     }      Is it possible to order by this custom value? Is there a better way to manually order my categories?


$wpdb - joining shows no result

For one of my client's WP site, I'm making a plugin, where I'm using the db Query. I've two custom tables dedicated to the plugin:   * **user_req** -- stores user chosen posts along with some custom fields' data.   * **user_req_admin** -- stores some very basic things, with a special foreign key `user_req_id`. **Table: user_req**   ![user_req view](http://i.stack.imgur.com/q6i6P.png) **Table: user_req_admin**   ![user_req_admin view](http://i.stack.imgur.com/FKUqR.png) My plan is to **Join 5 tables** with a single query:   1. user_req   2. user_req_admin   3. posts   4. postmeta   5. users Joining will be done by:   * `{$wpdb->user_req_admin}.user_req_id` connects by `{$wpdb->user_req}.id` (Connects both the db with User Request ID)   * `{$wpdb->user_req}.user_id` connects by `{$wpdb->users}.ID` (Fetch the User details using user_id)   * `{$wpdb->user_req}.post_id` connects by `{$wpdb->posts}.ID` (Fetch the Posts details using the `post_id`s in an array)   * `{$wpdb->user_req}.post_id` connects by `{$wpdb->postmeta}.post_id` (Fetch the Custom Fields using the `post_id`s in an array) But for a startup, I tried joining the first two tables (#1 and #2), and eventually Failed! Here's how I tried:               global $wpdb;         $wpdb->print_error();         $inbox_query = "SELECT                               {$wpdb->user_req}.id,                               {$wpdb->user_req}.dt_usr_sent,                               {$wpdb->user_req}.dt_usr_rcvd,                               {$wpdb->user_req}.user_id,                               {$wpdb->user_req}.post_id,                               {$wpdb->user_req}.qty,                               {$wpdb->user_req}.msg_user,                               {$wpdb->user_req}.msg_admin,                               {$wpdb->user_req}.price,                               {$wpdb->user_req_admin}.user_req_id                             FROM                               {$wpdb->user_req}                             LEFT JOIN                               {$wpdb->user_req_admin}                             ON                               {$wpdb->user_req}.id = {$wpdb->user_req_admin}.user_req_id";         $inbox_rows = $wpdb->get_results( $inbox_query, OBJECT );      **RESULT**   `<?php var_dump( $inbox_rows ); ?>` shows an: > **`array`**   >      _`empty`_ **»** WHAT'S THE PROBLEM WITH MY QUERY? ### References   * LEFT JOIN, INNER OUTER JOIN, LEFT OUTER JOIN is driving me crazy. Please help?   * Querying Email Addresses for a List of Users with Same Last Name?


Customizing Deleted/Archived blogs warning pages

When we try to access a _Deleted_ or _Archived_ site in Multisite, WordPress shows a `wp_die()` message. ![This site has been archived or suspended.](http://i.stack.imgur.com/1yBNN.png) And this message appears for _Deleted_ sites: > This user has elected to delete their account and the content is no longer > available. How can we customize that?


Watermarking Images with Wordpress with WP_Image_Editor

I really like the `WP_Image_Editor` class. I wanted to use it for some custom functionality I'm making, but I was wondering - Watermarking images - is there a way that I could use the objects created by `WP_Image_Editor` to merge an image with a watermark? I cannot figure out any obvious way.


How do i get the direct neighbor in a hierarchy

I've build a custom post type for a calendar and created a structure like this:   * 2012 (general parent)      * January-2012        * 1-January-2012 -2-January-2012        * ...       * ...      * Februar-2012        * 1-February-2012       * 2-February-2012        * ...       * ...      * March-2012        * 1-March-2012       * 2-March-2012       * ...       * ...  If I am now on the side for the whole month, I want to display a link to the pages for the previous and next month. example: January <-- **February** --> March I tried *get_previous_posts_link()* and get _NULL_ , then I set _global $post_ and get _NULL_ too. Another question, is this in general the right way? Maybe then I get the post data / link for 31st January? I'm not sure if *get_previous_posts_link()* considers the hierarchy.


Infinite scroll page number

On this guys blog he's using infinite scroll and it's appending the page number to the url so when you click on a story and go back, you start off where you were. I'm using infinite scrolling on a website I'm developing just now but I can't figure out how this is done, it's not a function built into the plugin. I'm not using jetpack, I'm using the standalone plugin Also, if I append a page number to my local installation like this               http://localhost:8888/page/2      Then scroll down, it loads in the next set of posts, then it breaks and doesn't load in anymore posts. Is there a way to append the page number as more posts are loaded in with infinite scroll?


Count posts that have specific taxonomy term attached

When upgrading our portfolio I'm looking for something that shows the number of posts in a (current) category of a post type. Example: I have a category with 'features'. Each feature has it's own description, apps related and blog related posts page I'm fetching the current category with:               <?php $cat_id = get_query_var('cat'); ?>      and get posts with:                <?php query_posts("post_type=apps&cat=$cat_id&showposts=3");?>      How is it possible to count the posts of post_type=apps and category=$cat_id ? I'm sorry for my lack of PHP/WP experience.. does anyone know how to get these 2 things working? Thanks in advance.


Select From wpdb - Author/User Directory page

I am working on a wordpress site where I have created a directory page(authors.php) that lists all users and certain author meta. It works fine however I am trying to figure out how to only show users that have the required author meta filled out. I've tried many different things but have not been able to achieve what I need. Here is my code               <?php         $order = 'user_nicename';     $users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY $order"); // query users              foreach($users as $user) : // start users' profile "loop"         ?>       Everything else I try does not return any results. Is there a way to only select users with specific author meta fields filled out? Any help is appreciated, thanks.


Category slug inside another php code

I'm using this code to get category slug on categories archive page outside of the loop:               <?php $cat = get_term_by('name', single_cat_title('',false), 'category'); echo $cat->slug; ?>      And I would like to know how can I add the result of that code inside 'base' => '/HERE/' of paginate_links php code that looks like this:               <?php echo paginate_links( array( 'current' => $current_paginate_page, 'show_all' => true,'prev_next' => false, 'total' => $wp_query->max_num_pages, 'base' => '/HERE/', 'format' => '%#%' )); ?>      I just don't know how to correctly write it inside another php code. Please help, thank you! http://wordpress.org/support/topic/single_cat_slug?replies=5 http://codex.wordpress.org/Function_Reference/paginate_links


Custom WordPress Feeds operators?

I wish to create a feed of my blog which is a feed of two categories OR the feed of some tag and not the feed of some other category I know how to do "have a feed of this1 + this2 categories", but how do you do "OR" in a feed URL? (and in general, is more complex operators on the URL possible, and how?) Links that don't answer the question (but help define it):   * http://lorelle.wordpress.com/2006/03/27/customizing-rss-feed-links-for-wordpresscom-and-wordpress-sidebar-widgets/   * http://dailycupoftech.com/2007/07/25/creating-custom-wordpress-feeds/


Help extending custom drag-drop page ordering on admin page list screen

I am utilizing the following code which transforms any hierarchical page or custom post type with the ability to reorder the the pages through simple drag/drop. (also this code also adds a new display filter to hierarchical pages to make things simpler). The problem I need help with which currently does not work is being able to drag one page tree into another page tree or out of an existing page tree. Could someone please provide the code modifications required to extend this capability? If you know of a better way to achieve the same objectives with different code instead of extending the code provided below please also post it. **UPDATED:** I have also posted the code here: https://gist.github.com/812204 **NOTE:** for all those individuals who would like to test this out just do the follow. **1st Copy/past the code below in your themes functions.php" file.**               ///////////////////////////////////////////////////////////////////////////////////////////     // CODE TO ADD POST PER PAGE FILTER     ///////////////////////////////////////////////////////////////////////////////////////////             add_filter( 'edit_posts_per_page', 'reorder_edit_posts_per_page', 10, 2 );         function reorder_edit_posts_per_page( $per_page, $post_type ) {                  // CHECK USER PERMISSIONS             if ( !current_user_can('edit_others_pages') )                 return;             $post_type_object = get_post_type_object( $post_type );                  // ONLY APPLY TO HIERARCHICAL POST TYPE             if ( !$post_type_object->hierarchical )                 return;                  // ADD POST PER PAGE DROP DOWN UI             add_action( 'restrict_manage_posts', 'reorder_posts_per_page_filter' );                  // ADD SPECIAL STYLES (MOVE CURSOR & SPINNING LOADER AFTER REORDER)             wp_enqueue_script( 'page-ordering', get_bloginfo('stylesheet_directory') . '/custom/js/page-resorting.js', array('jquery-ui-sortable'), '0.8.4', true );             add_action( 'admin_print_styles', 'reorder_admin_styles' );                  if ( isset( $_GET['spo'] ) && is_numeric( $_GET['spo'] ) && ( $_GET['spo'] == -1 || ($_GET['spo']%10) == 0 ) ) :                 global $edit_per_page, $user_ID;                 $per_page = $_GET['spo'];                 if ( $per_page == -1 )                     $per_page = 99999;                 update_user_option( $user_ID, $edit_per_page, $per_page );             endif;             return $per_page;         }                   // STYLING CSS FOR THE AJAX            function reorder_admin_styles() {             echo '<style type="text/css">table.widefat tbody th, table.widefat tbody td { cursor: move; }</style>';            }                   // FUNCTION TO CREATE THE NUMBER OF POSTS PER PAGE DROPDOWN UI            function reorder_posts_per_page_filter() {             global $per_page;                    $spo = isset($_GET['spo']) ? (int)$_GET['spo'] : $per_page;            ?>             Display:<select name="spo" style="width: 100px;">                 <option<?php selected( $spo, -1 ); ?> value="-1"><?php _e('All Results'); ?></option>                 <?php for( $i=10;$i<=100;$i+=10 ) : ?>                 <option<?php selected( $spo, $i ); ?> value="<?php echo $i ?>"><?php echo $i; ?> <?php _e('Results'); ?></option>                 <?php endfor; ?>                     </select>            <?php            }                         ///////////////////////////////////////////////////////////////////////////////////////////////////////////////         // ACTUAL AJAX REQUEST FOR SORTING PAGES          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////              add_action( 'wp_ajax_simple_page_ordering', 'reorder_do_page_ordering' );         function reorder_do_page_ordering() {                  // RECHECK PERMISSIONS             if ( !current_user_can('edit_others_pages') || !isset($_POST['id']) || empty($_POST['id']) || ( !isset($_POST['previd']) && !isset($_POST['nextid']) ) )                 die(-1);                  // IS IT A REAL POST?             if ( !$post = get_post( $_POST['id'] ) )                 die(-1);             $previd = isset($_POST['previd']) ? $_POST['previd'] : false;             $nextid = isset($_POST['nextid']) ? $_POST['nextid'] : false;             if ( $previd ) {                      // FETCH ALL THE SIBLINGS (RELATIVE ORDERING)                 $siblings = get_posts(array( 'depth' => 1, 'numberposts' => -1, 'post_type' => $post->post_type, 'post_status' => 'publish,pending,draft,future,private', 'post_parent' => $post->post_parent, 'orderby' => 'menu_order', 'order' => 'ASC', 'exclude' => $post->ID ));                 foreach( $siblings as $sibling ) :                          // BEGIN UPDATING MENU ORDERS                     if ( $sibling->ID == $previd ) {                         $menu_order = $sibling->menu_order + 1;                         // UPDATE THE ACTUAL MOVED POST TO 1 AFTER PREV                         wp_update_post(array( 'ID' => $post->ID, 'menu_order' => $menu_order ));                         continue;                     }                          // NOTHING LEFT TO DO - NUMBERS CORRECTLY PADDED                     if ( isset($menu_order) && $menu_order < $sibling->menu_order )                         break;                           // NEED TO UPDATE THE SIBLINGS MENU ORDER AS WELL                     if ( isset($menu_order) ) {                         $menu_order++;                         // UPDATE THE ACTUAL MOVED POST TO 1 AFTER PREV                         wp_update_post(array( 'ID' => $sibling->ID, 'menu_order' => $menu_order ));                      }                        endforeach;             }                  if ( !isset($menu_order) && $nextid ) {                      // FETCH ALL THE SIBLINGS (RELATIVE ORDERING)                 $siblings = get_posts(array( 'depth' => 1, 'numberposts' => -1, 'post_type' => $post->post_type, 'post_status' => 'publish,pending,draft,future,private', 'post_parent' => $post->post_parent, 'orderby' => 'menu_order', 'order' => 'DESC', 'exclude' => $post->ID ));                 foreach( $siblings as $sibling ) :                          // START UPDATING MENU ORDERS                     if ( $sibling->ID == $nextid ) {                         $menu_order = $sibling->menu_order - 1;                         // UPDATE THE ACTUAL MOVED POST TO 1 AFTER PREV                         wp_update_post(array( 'ID' => $post->ID, 'menu_order' => $menu_order ));                         continue;                     }                          // NOTHING LEFT TO DO - NUMBER ALREADY PADDED                     if ( isset($menu_order) && $menu_order > $sibling->menu_order )                         break;                           // NEED TO UPDATE THE SIBLING MENU ORDER                     if ( isset($menu_order) ) {                         $menu_order--;                         // UPDATE THE ACTUAL MOVED POST TO 1 AFTER PREV                         wp_update_post(array( 'ID' => $sibling->ID, 'menu_order' => $menu_order ));                      }                        endforeach;             }                  // FETCH ALL THE SIBLINGS WITH RELATIVE ORDERING AND IF THE MOVED POST HAS CHILDREN REFRESH THE PAGE             $children = get_posts(array( 'depth' => 1, 'numberposts' => 1, 'post_type' => $post->post_type, 'post_status' => 'publish,pending,draft,future,private', 'post_parent' => $post->ID ));             if ( !empty($children) )                 die('children');             die();         }      **2nd Steps** Because we the script below calls a custom js file we need to crate and include this file as well. If you don't want to modify the script above then go and create a folder in the root directory of your theme folder and call it "custom". Next, within this folder create another folder called "js". Next create a new file within this folder called "page-resorting.js" and past the following code into that file. After this is done you should be able to reorder through drag/drop all pages in the admin area.               /////////////////////////////////////////////////////////////////////////////////////////////////////     // THIS SCRIPT APPLIES TO THE CUSTOM SCRIPT MODIFICATION ALLOWING HIERARCHICAL PAGES TO BE REORDERED     /////////////////////////////////////////////////////////////////////////////////////////////////////               jQuery("table.widefat tbody").sortable({           cursor: 'move',         axis: 'y',         containment: 'table.widefat',         scrollSensitivity: 40,         helper: function(e, ui) {                                ui.children().each(function() { jQuery(this).width(jQuery(this).width()); });             return ui;         },         start: function(event, ui) {             if ( ! ui.item.hasClass('alternate') ) ui.item.css( 'background-color', '#ffffff' );             ui.item.children('td, th').css('border','none');             ui.item.css( 'outline', '1px solid #dfdfdf' );         },         stop: function(event, ui) {                  ui.item.removeAttr('style');             ui.item.children('td, th').removeAttr('style');         },         update: function(event, ui) {                if ( ui.item.hasClass('inline-editor') ) {                 jQuery("table.widefat tbody").sortable('cancel');                 alert( 'Please close the quick editor before reordering this item.' );                 return;             }                  var postid = ui.item.find('.check-column input').val(); // THIS POST ID             var postparent = ui.item.find('.post_parent').html();   // POST PARENT                  var prevpostid = ui.item.prev().find('.check-column input').val();             var nextpostid = ui.item.next().find('.check-column input').val();                  // can only sort in same tree                  var prevpostparent = undefined;             if ( prevpostid != undefined ) {                 var prevpostparent = ui.item.prev().find('.post_parent').html()                 if ( prevpostparent != postparent) prevpostid = undefined;             }                  var nextpostparent = undefined;             if ( nextpostid != undefined ) {                 nextpostparent = ui.item.next().find('.post_parent').html();                 if ( nextpostparent != postparent) nextpostid = undefined;             }                     // DISPLAY AN ALERT MESSAGE IF ANY OF THE FOLLOWING TAKES PLACE             // IF PREVIOUS AND NEXT ARE NOT AT THE SAME TREE LEVEL OR NOT AT THE SAME TREE LEVEL AND THE PREVIOUS PAGE IS THE PARENT OF THE NEXT OR JUST MOVED BENEATH ITS OWN CHILDREN                                  if ( ( prevpostid == undefined && nextpostid == undefined ) || ( nextpostid == undefined && nextpostparent == prevpostid ) || ( nextpostid != undefined && prevpostparent == postid ) ) {                 jQuery("table.widefat tbody").sortable('cancel');                 alert( "SORRY, THIS ACTION IS NOT POSSIBLE!\n\n>>> WHY THIS DOES NOT WORK:\nDrag-and-Drop capabilities only work for items within their current tree.\n\n>>> HERE IS HOW YOU CAN MOVE IT:\nIn order to move this item to the location you specified you simply need to use the \"Quick Edit\" link and modify the associated \"Parent\" page.\n\n>>> LOCATING THE QUICK EDIT LINK:\nOn the post you want to move, just hover over the post title and click on the \"Quick Edit\" link which appears below the title." );                 return;             }                  // SHOW AJAX SPINNING SAVE ELEMENT             ui.item.find('.check-column input').hide().after('<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />');                  // EXECUTE THE SORTING VIA AJAX             jQuery.post( ajaxurl, { action: 'simple_page_ordering', id: postid, previd: prevpostid, nextid: nextpostid }, function(response){                            if ( response == 'children' ) window.location.reload();                 else ui.item.find('.check-column input').show().siblings('img').remove();             });                  // FIX CELL COLORS             jQuery( 'table.widefat tbody tr' ).each(function(){                 var i = jQuery('table.widefat tbody tr').index(this);                 if ( i%2 == 0 ) jQuery(this).addClass('alternate');                 else jQuery(this).removeClass('alternate');             });         }     }).disableSelection();


Hide metabox dependant on page template chosen

I'm using the following JQuery script from this answer to toggle the display of metaboxes dependant on the Page Template selected. The example below shows the **featured image** metabox when the **default** template is selected:               (function($){     $(function() {              $('#page_template').change(function() {             $('#postimagediv').toggle($(this).val() == 'default');         }).change();          });     })(jQuery);      My possibly simple question is... How do I get this code to only show the featured image box for my Page Template entitled: **Services**? I have tried simply changing the `'default'` to '`Services'` but no luck.


How to override normal Wordpress search in Buddypress?

hi i have wordpress and buddypress installed and i wanted to be able to search through forum posts, blog posts and other info all over the site. i found Search Engine (Wordpress Plugin) and installed it. after a brief indexing process i was able to perform all of my search requests but the problem is that when this plugin is enabled and i try to search for something inside the wp-admin, there are no results. when i turn the plguin off the wp- admin search runs. i also tried google search plugin but the outcome was the same. how can i keep my search plugin and the normal plugin work together? thanks


Viewing post while editing

While the wordpress editor is great, it's not completely WYSIWYG. Various CSS settings from the theme aren't displayed in the editor. Is there a plug-in that will make the editor more WYSIWYG by loading the CSS? Even a plug-in that adds a frame in the post-edit page that shows the post being edited will be good enough. I just want to see how the post will look like without having to open multiple tabs on my browser.


Passing arguments to a admin menu page callback?

**Situation:** I'm working on a plugin and I'm developing it as a class, everything worked fine until I run into this situation. I wanted to make things a bit cleaner and tried this..               class MyPlugin {         function __construct() {             add_action('admin_menu', array(&$this, 'myplugin_create_menus');         }                      //I don't want to write a function for every options page I create         //so I prefer to just load the content from an external file.                 function load_view($filename) {             $view = require(dirname(__FILE__).'/views/'.$filename.'.php');             return $view;         }              //Here is where the problem comes         function myplugin_create_menus() {             add_menu_page( 'Plugin name',                            'Plugin name',                            'manage_options',                            'my-plugin-settings',                            array(&$this, 'load_view') // Where do I specify the value of $filename??                          );         }          }#end of class      I've tried a bunch of different options but nothing works, maybe I'm in front of it but I can't see it. Of course this is a re-creation, I've prefixed all my functions and they are not exactly as I wrote here but I hope you got the idea of I'm asking for. **Thanks in advance.** P.D.: If you want to see the original source code I'll be glad to paste it and give you the link.


add different stylesheet file to edit themes file list

I am not sure if the title makes sense so feel free to suggest a different one. Anyways… In Wordpress dashboard _Appearance -> Editor_ page I would like to load _app.css_ file located in current theme's _assets/css/_ directory. How can I achieve this?


Stream Video Player does not work with do_shortcode()?

I have downloaded a plugin called Stream Video Player, which has a shortcode. If I put the shortcode into the content editor, it works well and it displays the video. However, if, inside a template I am creating, I call it through the `do_shortcode()` function, it doesn't work, it just shows the text `[stream bla bla]`. Can anyone help me and tell me why this is happening?


Adding "latest from the blog" to the homepage

I have a big problem and no clue how to solve it :) I want to add a "module" to my homepage (static homepage, not blog posts) that will display the 2 latest blog posts in a very particular way and link back to them. The posts would only display on the homepage and not every other page but the php template used for the page is shared with all the custom pages. Here is a quick sketch of it ![Photo of a paper sketch](http://i.stack.imgur.com/Zuaiu.jpg) A site that does this beautifully on their homepage is SEOmoz ( but i don't need that much functionality, only blog post title, thumb, excerpt & link to read more ) ![Screenshot from seomoz.org](http://i.stack.imgur.com/9l4LT.png) Is there a simple way to do this? (plugins, code you can copy/paste from anywhere?) or can I pay someone to write this up for me?


Removing custom background and header feature in child theme

I am creating a child theme using twentyten as my base. I am looking for a way to remove the features of adding custom header and background without touching `functions.php` file in the parent theme. no luck with this :(               function my_child_theme_setup() {         remove_theme_support('custom-background');         remove_theme_support('custom-header');     }          add_action( 'after_setup_theme', 'my_child_theme_setup' );


Custom Post taxonomy template

Friends I need help. Am extending the Mayashop theme for a friend & I ran into a problem. Created a custom post type named watchdog, created a taxonomy for it called watchdog-brand ... now the single-watchdog.php template is working just fine but I can't seem to find the appropriate template for the term itself listing all of the watchdog items under it. Tried archive-watchdog.php , archive-watchdog-brand.php but no luck ... any idea? I also found out that it doesn't even fallback to the archive.php .. just straight forward to the index.php file & here is the code for the custom_post & the taxonomy               register_post_type(                 TYPE_WATCHDOG,        array(          'description' => __('Watchdog', 'yiw'),          'exclude_from_search' => false,          'show_ui' => true,          'labels' => yiw_label( apply_filters( 'yiw_watchdog_label_singular', __('Product', 'yiw') ), apply_filters( 'yiw_watchdog_label_plural', __('Products', 'yiw') ), __('Watchdog', 'yiw') ),          'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields' ),          'public' => true,          'capability_type' => 'post',          'publicly_queryable' => true,          'rewrite' => array( 'slug' => apply_filters( 'yiw_watchdog_rewrite', 'watchdog' ), 'with_front' => true )        )     );           flush_rewrite_rules();               register_taxonomy('watchdog-brand', array( TYPE_WATCHDOG ), array(         'hierarchical' => true,         'labels' => yiw_label_tax(__('Brand', 'yiw'), __('Brands', 'yiw')),         'show_ui' => true,          'show_in_nav_menus' => true,         'query_var' => true,         'rewrite' => array( 'slug' => 'watchdog-brand', 'with_front' => false )     ));     flush_rewrite_rules();      Thanks in advance


WPDB preparing delete from

I know my variables and functions are ok, it must be the way I have added the prepare that is stopping it working.               function delete_record($table, $id) { //deletes a specific record     global $wpdb;     $table_name = get_database_prefix() . $table;     delete_images($table, $id);     $wpdb->query( $wpdb->prepare(          " DELETE FROM %s WHERE %s = %d ",         $table_name,         get_id_name($table),         $id     ) );     return $wpdb;     }      I am getting the error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''wp_tablename' WHERE 'id' = 1' at line 1 Thanks Alex