Code not looping over all products of a given category

I try to fetch all products for a given category managed by the wp e-commerce plugin, but the code I use is not looping all the products returned. All the code is a sort of API to look for products and return them later to an extern application with JSON. First , this is all the code I use:               $catid = $_REQUEST['catid'];//get the category id from the url     $term1 = get_term($catid,'wpsc_product_category');     getdetails($term1->slug,$term1->term_id,$host,$term1->parent);     echo '----------------------------'.'
';     echo $term1->slug .'
';     echo $term1->term_id.'
';     echo $term1->parent.'
';     echo '----------------------------'.'
';     function getdetails($id,$tid,$host,$cid)     {          $wpec_product_categories = get_terms( 'wpsc_product_category', 'hide_empty=0&slug='.$id);         echo '-------this is a stack of the product category array--------
';         var_dump($wpec_product_categories).'
';         echo '-------------------------------------------
';              if($wpec_product_categories[0]->count != 0)         {              echo 'count is '.$wpec_product_categories[0]->count.'
';//here the correct number of products. So, so far all is going good.          foreach($wpec_product_categories as $wpec_categories){                $wpec_term_id = $wpec_categories->term_id;                 $wpec_term_name = $wpec_categories->name;                 $wpec_term_slug = $wpec_categories->slug;                 $wpec_term_parent = $wpec_categories->parent;                 echo '
--------------------
';                 echo  $wpec_term_name.'
';                 echo  $wpec_term_slug.'
';                 echo  $wpec_term_parent.'
';                 echo '
--------------------
';                                                   $wpec_args = array(                                        'post_status' => 'publish',                                        'post_type'   => 'wpsc-product',                                        'wpsc_product_category' => $wpec_term_slug                                       );                                       $wpec_categoryProducts = new WP_Query($wpec_args);                  while ($wpec_categoryProducts->have_posts()) : $wpec_categoryProducts->the_post();                  echo '
---------------------||||||--------------------
';                  echo 'Content:'.$wpec_categoryProducts->the_post().'
';                     echo '
---------------------||||||--------------------
';                       echo 'Product wholesale price: '.wpsc_the_product_price().'
';                     $selthumb ="SELECT p.*, pm.* FROM wp_posts as p, wp_postmeta as pm WHERE  pm.meta_key = '_thumbnail_id' AND pm.meta_value = p.ID AND p.post_parent = '".wpsc_the_product_id()."' AND p.post_type = 'attachment'";              $resthumb = mysql_query($selthumb);              $rowthumb = mysql_fetch_array($resthumb);               $img = stripslashes($rowthumb['guid']) ;                   if($img != '')                   {                       $path =  $img;                   }                   else                   {                       $selimg = "SELECT * FROM wp_wpsc_meta WHERE meta_key = 'image' AND object_id = ".$tid;                       $resimg = mysql_query($selimg);                       $rowimg = mysql_fetch_array($resimg);                       if($rowimg != '')                       {                           $path = "http://".stripcslashes($host."/wp-content/uploads/wpsc/category_images/".$rowimg['meta_value']);                            }                       else                       {                            $selimg = "SELECT * FROM wp_wpsc_meta WHERE meta_key = 'image' AND object_id = ".$cid;                            $resimg = mysql_query($selimg);                             $rowimg = mysql_fetch_array($resimg);                             if($rowimg != '')                             {                                 $path = "http://".stripcslashes($host."/wp-content/uploads/wpsc/category_images/".$rowimg['meta_value']);                             }                             else                             {                                  $selpimg = "SELECT tx.*,m.* FROM wp_term_taxonomy tx,wp_wpsc_meta m WHERE tx.term_id = '".$cid."' AND m.meta_key = 'image' AND m.object_id = tx.parent";                                 $respimg = mysql_query($selpimg);                                 $rowpimg = mysql_fetch_array($respimg);                                 if($rowpimg != '')                                 {                                     $path = "http://".stripcslashes($host."/wp-content/uploads/wpsc/category_images/".$rowpimg['meta_value']);                                 }                                 else                                 {                                     $path= "false";                                 }                             }                       }                   }                        $selcolor = "SELECT * FROM wp_postmeta WHERE post_id = '".wpsc_the_product_id()."' AND meta_key = '_wpsc_color'";                   $rescolor = mysql_query($selcolor);                   $rowcolor = mysql_fetch_array($rescolor);                        $selsize = "SELECT * FROM wp_postmeta WHERE post_id = '".wpsc_the_product_id()."' AND meta_key = '_wpsc_size'";                   $ressize = mysql_query($selsize);                   $rowsize = mysql_fetch_array($ressize);                        $selprice = "SELECT * FROM wp_postmeta WHERE post_id = '".wpsc_the_product_id()."' AND meta_key = '_wpsc_special_price'";                   $resprice = mysql_query($selprice);                   $rowprice = mysql_fetch_array($resprice);                        $selmanu = "SELECT * FROM wp_postmeta WHERE post_id = '".wpsc_the_product_id()."' AND meta_key = '_wpsc_manufacturer'";                   $resmanu = mysql_query($selmanu);                   $rowmenu = mysql_fetch_array($resmanu);                        $product_data = get_post_custom( wpsc_the_product_id() );                   $product_data['meta'] = maybe_unserialize( $product_data );                        $image = stripslashes(sb_get_images_for_product( wpsc_the_product_id() ));                        $list = explode(",",$image);                            $arr[] = array("Product ID" => wpsc_the_product_id(),"Product Title" => wpsc_the_product_title(), "Product Description" => wpsc_the_product_description(), "Product Wholesale Price" => wpsc_the_product_price(), "Product Sale Price" => '$'.$rowprice['meta_value'], "Category Id" => $wpec_term_id,"Category Name" => $wpec_term_name,"Product Image" => $path, "Product Sub Images" => $list , "SKU" => wpsc_product_sku(), "Quantity" => $product_data['meta']['_wpsc_stock'][0], "Size" => $rowsize['meta_value'], "Color" => $rowcolor['meta_value'], "Manufacturer" => $rowmenu['meta_value'] );         $i++;                    endwhile;               }         }     }      I don't understand why foreach and while loop are not looping all the products. They are looping only the first 7-10 items, although when I check the returned number of products, it's around 60 items. My questions is, how to fix my code to loop over all the products? please help, and thanx in advance.


Redirect if string found in URL

I'm trying to redirect non-logged in users to the login page when viewing any pages relating to a plugin. My code is working fine when I specify which pages they can't view, but I'm trying to pull in a string from the URL which is where I'm struggling. Here is an example URL: http://domain.com/idx/city/irvine/ I am trying to detect the string 'idx' in the URL. I looked at the rewrite rules defined in the IDX plugin I'm using:               "idx/city/([^/]+)(?:/page\-(\\d+))?"       => 'index.php?idx-action=results&idx-q-Cities=$matches[1]&idx-d-ResultPage=$matches[2]'      I've tried checking if $_GET['idx-action'] is set but that didn't work.               // Check for registered user or redirect to login/register page     add_action('template_redirect','tc_check_if_logged_in');     function tc_check_if_logged_in() {     // If user is not logged in, check for restricted pages (inside array) and ignore home/front page and admin pages     //if (!is_user_logged_in() && (is_page( array('1306','999999','999998',)) && !is_home() && !is_front_page() && !is_admin())) // commented out as I know this part works          if ($_GET['idx-action']) // Check if IDX query set      {         // If restricted, redirect to login page then redirect back to original page         $url = add_query_arg(             'redirect_to',             get_permalink(),             site_url('wp-login.php')         );         wp_redirect($url);         exit;     }        }       Sorry if question is unclear. Got a really bad head cold and can't think!


MySQL Engine vs. Charset

I am attempting to have my plugin create a new table. I am fairly new to SQL. I have found two different method for creating tables: ### Method I               $table_name = $wpdb->prefix . 'cool_table';     $sql = "CREATE TABLE $table_name (         [command to set up columns go here]         ) DEFAULT CHARSET=utf8;";      ### Method II               if ( ! empty($wpdb->charset) )         $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";     if ( ! empty($wpdb->collate) )         $charset_collate .= " COLLATE $wpdb->collate";          $table_name = $wpdb->prefix . 'cool_table';          $sql = "CREATE TABLE $table_name (         [command to set up columns go here]         ) ENGINE = InnoDB {$charset_collate};";      What is the benefit of setting the default charset vs. setting the ENGINE when creating a new table?


Linking an image to open a youtube video in lightbox/fancybox in wordpress

Here is what i'm having problems with... I want to link a youtube video to start playing in a lightbox/fancybox when a person clicks an image. Kind of like this site has - http://www.adroll.com/ \- if you click the "Click to Play" (which is an image) a window will open (although not lightbox/fancybox) and video will start autoplaying. Would preferably want to do it with the least possible programing needed. I can do some basic editing but don't really know how to write any PHP/javascript


List of all entries of custom-post-type: Add year-parameter?

I've once got help with the following function:               function get_event_list( $latest = true, $order = 'ASC', $return = false ) {              $yesterday = time() - 24*60*60;         $compare = $latest ? '>' : '<';         $current_year = '';              $args = array(             'post_type' => 'wr_event',             //'posts_per_page' => is_archive() ? 16 : -1,             'posts_per_page' => -1,             'meta_key' => 'event_date',             'orderby' => 'meta_value_num',             'order' => $order,             'meta_value' => $yesterday,             'meta_compare' => $compare,             /*'tax_query' => array(                 array(                     'taxonomy'  => 'event_type',                     'field'     => 'slug',                     'terms'     => 'empfehlungen',                     'operator'  => 'NOT IN'                     ),                )*/         );              $loop = new WP_Query( $args );              // if function should not return any posts         if ( $loop->have_posts() && $return ) return true;              echo '
';         while ( $loop->have_posts() ) : $loop->the_post();             global $post;             $this_year = get_post_meta( $post->ID, 'event_date', true );             $this_year = date('Y', (int)$this_year);                  if ( !$latest && ( $this_year != $current_year ) ) :                 if ($current_year != '') echo '

';                 echo '

' . $this_year . '
Archiv anzeigen

';                 $current_year = $this_year;             endif;                 get_template_part( 'inc/event', 'item' );         endwhile;         if ($current_year != '') echo '

';         wp_reset_postdata();         echo '
';     }      The Problem I'm having is, that this function is getting me all events that are older than the current year. How can I transform this function in order to add a param that get's me whatever year I pass in? The goal I'm after is that I don't want to load all events at once, but rather when clicking on "2011" I want to retrieve those events via ajax. Can anyone help me out here please? Thank you in advance, Matt


Custom query var rewrite for custom post type archives widget plugin

I have a website soon to be delivered to the client. The client absolutely wants the following URL to be without the appended query variable:               http://beta.example.com/inav1/2012/?post_type=new      How can I make this happen? Also would you like me to show you what I have done so far? For the archives, I am using a plugin.


Let users share posts via Twitter?

I am using Twitter Tools, which allows me to auto-tweet my blog posts. Thats great, but I would also like a button to allow readers to easily tweet them. <\--- What I am talking about is exactly like the little Twitter button next to this question. How can I add something like that to my blog posts?


insert order number into wp ecommerce order confirmation email

A client site has been barred from using Paypal, so their WP-e-Commerce catalog/cart now has to use manual EFT bank payments to accept money from customers. A customer receives this banking information in their order confirmation email. When a customer makes an EFT payment through their bank website, they have the opportunity to insert a reference to accompany the payment. This is a string of text. We'd like to send the order number in the order confirmation email, so the customer can use the order number as the EFT reference, so the client site can match EFT payments and orders. **How do we insert the order number into the order confirmation email?**


How to use the WP export and get images that are contained in a posts gallery

I ran the standard wp Export on a single custom post type called products. I got all the custom fields and all that but each cpt has a standard post gallery. The link to the image is not coming through the export. I need the imported products to have the same post gallery that the old site did. I also don't want to manually re-add them as there are quite a few. Is there a way to export that custom post type, and pull the images over as well? I am fine with having to manually move the images via ftp but I openned the exported xml and there is no notation of the images linked to this custom post type. I am using 3.4


How do I fix this error: Warning: invalid argument supplied for foreach()?

I recently moved a wordpress install from my local instance to a dev server. For the move, I installed a clean version of wordpress 3.4, moved exact duplicates of the file structre, and used the import / export feature to bring the posts in. I then went in and set the necessary widgets, and settings. I've done this 100 times, and never had this problem. Here is the error: **Warning** : Invalid argument supplied for `foreach()` in **/home/content/46/9411746/html/dev/wp-admin/includes/plugin.php** on line **1285** It only appears in the admin menu. I see it when I try to add a widget, change a setting, work with menus, or update meta data for a post. It pops up all over the admin menu. Here is the function triggering the error in includes/plugin.php               function remove_menu_page( $menu_slug ) {     global $menu;          foreach ( $menu as $i => $item ) {         if ( $menu_slug == $item[2] ) {             unset( $menu[$i] );             return $item;         }     }          return false;     }      I'm using appearance > menus and have two registered here in functions.php here:               add_action( 'init', 'register_my_menus' );          function register_my_menus() {     register_nav_menus(         array(           'header-nav' => __( 'Main Header Navigation', 'kyosay' ),           'footer-nav' => __( 'Footer Navigation', 'kyosay' )         )     );     }      I am doing some other customization of the admin panel, reordering some menu items and eliminating others that my clients don't need. I can include that code if you think it's relevant. Since this issue is triggered in core, I'm at a loss as to how to fix it. _NOTE:_ The issue is not happening on my local build. Thoughts? **Edit: added remove_menu_items code from functions.php for reference**               function remove_menu_items() {     remove_menu_page('link-manager.php'); // Links     remove_menu_page('edit-comments.php'); // Comments     }     add_action( 'admin_init', 'remove_menu_items' );      **Update:**   I have eliminated functions.php as the source of this issue. It seems to be triggered on Ajax events (dragging a new widget to a sidebar, updating a meta- box, etc. I'm going to uninstall and reinstall and see if it's still happening. Could this have something to do with the web host (godaddy) ? It's not showing up on my local build at all.


Can user #1 (the initial user) be deleted without ill effect?

When you create a new Wordpress site, the first user created is user #1 and given the Administrator role. Is there anything special about user #1 that would make it unwise to delete it? (Assuming that there were other users with Administrator role.)


Create shortcode for list of custom post titles with custom fields alongside

I'm stumped. I've looked at various sites but haven't found the exact code I need. Basically I want to create a list of custom post titles with the date from one of the custom fields for that post along side. So I'll end up with a list looking something like this: Post Title 1 (with link) ...... Associated Custom Field   Post Title 2 (with link) ...... " Custom Field   Post Title 3 (with link) ...... " Custom Field etc. I want to be able to add this to a page via a short code [boats]. I know I'm on the right track but have really hashed two bits of code together. I'm not sure how to pull the array from the php script (the bit starting $args=array) into extract(short code_atts ... I'm also not sure about the end part with
     <?php }     wp_reset_query();     }      Here's the mess so far ...               add_shortcode('boats', 'shortcode_boats');     function shortcode_boats($atts){          extract(shortcode_atts          $args=array(       'post_type' => 'yacht-for-sale',       'post_status' => 'publish',       'posts_per_page' => 15,       'caller_get_posts'=> 1     );     $my_query = null;     $my_query = new WP_Query($args);     if( $my_query->have_posts() ) {  ?>
List of Available Yachts & Catamarans

       <?php       while ($my_query->have_posts()) : $my_query->the_post();         $price = get_post_meta($post->ID, 'price', true); ?>
<?php the_title(); ?><?php echo $price; ?>
       <?php endwhile; ?>
     <?php }     wp_reset_query();     }     add_shortcode("boats", "shortcode_boats");      Just in case this can be used in anyway, I'm currently using the 'Display Posts Shortcode' plugin by Bill Erickson in the page but I need the custom- field 'price' lined up with it. [display-posts post_type="yacht-for-sale" order="DSC" orderby="title" posts_per_page="20"] Thanks for any help you can give me on this. I'm not a great php coder ... as you can probably tell. :) Cheers, Tracy


Showing Meta Data for Custom Post Types?

I'm busy learning some basics behind Wordpress development and so far I'm getting on quite well. However, I've hit a stumbling block. Firstly, my test site is; http://popcorn.canny-creative.com And, my reading settings are set as Wordpress to display "Your latest posts" on the homepage. ![Settings](http://i.stack.imgur.com/3orA2.png) If you check the link, you'll notice that "Hello World" and "Let's Get Chinese Food" posts have "posted by...posted on..." meta information, as well as Posted In at the bottom. The problem is, the custom post type (movie_reviews) with Shawshank Redemption and The Dark Knight, don't show these same values. I'm using Underscores as a starting point, and I think I've narrowed it down to template-tags.php being where this information is fetched from. Am I right in thinking the custom-post-type isn't included somehow? Also, is this information "post-meta"? Or have I picked that up wrong? Many thanks.


Best practices for using the transients API

I've recently come across the Transients API in Wordpress in hopes of improving the performance of the plugin that I'm trying to write. Basically the plugin is storing product details from the amazon product advertising API in the database. The product details are stored using the json encoded representation of the array. Now I'm trying to use the transients API so that whenever the admin purges the database records it also updates using the transients API. What I'm currently doing is storing the json encoded value using the `set_transient` method. Something like this:               $data = array(      '123' => "{'title' : '', 'price' : '', 'brand' : ''}"      '456' => ...     );          $value = json_encode($data);     set_transient('amazon_items', $value, 60 * 60);      And then I get it from there using `get_transient`               $asin = '123';     $data = json_decode(get_transient('amazon_items'), true);     print_r($data[$asin]);      Is this ok or should I just store it in an array form so I can just directly access it without using `json_decode`? Is my use case acceptable or is it overkill? Can I still improve this one? Is there a specific limit to how much data I can store using the transients API? In this particular use case I'm expecting it to be more than 50Mb of data.


remove_action with profile_personal_options

I'd like to remove the action `profile_personal_options` (more specifically the color scheme and visual editor checkbox) which shows up in `wp-admin/user- edit.php`. I believe it's as simple as running it through `remove_action()`, but I'm not sure what the second parameter would be. Where would be the best place to look?               remove_action('profile_personal_options');      I was previously using:               function of_remove_profile_fields() {         if (current_user_can('manage_options') == false) {             ?>             <style type="text/css">                 form#your-profile p+h3,                 form#your-profile p+h3+table { display:none!important;visibility:hidden!important; }             </style>             <?php }     }     add_action( 'admin_print_styles-profile.php', 'of_remove_profile_fields' );     add_action( 'admin_print_styles-user-edit.php', 'of_remove_profile_fields' );      but would rather do this the correct way. Thanks! # Update Ack, this actually looks like it may be hardcoded into `user-edit.php`. Should I just go with the CSS method? Is that area really required or WP? Why didn't they plug into their own `do_action('profile_personal_options', $profileuser);` ?


Generating Thumbnails for video

I have checked and read lot of post about one single issue that is far more complicated than it seems. I have a website that uses a lot of videos taken from wwebsite as on the internet ^^ (services like youtube, vimeo, videobuzzy, etc) and we would like to generate on the fly a thumbnail of the embedded video. Each service uses its own API so I should adapt code for each, which it far too much code and I could never manage every service. A webserver propose something like that : http://embed.ly but I tried them and, as exemple, videos from videobuzzy doesn't work. So that's a partial solution. Another solution would be to use a screenshot service that could request the video's URL, render it, take a snapshot and generate an image. Tempting, but results tends to add delays, and I have to find a snapshot service and generate the code (well, this could be the fun part). The simpliest would be to take a screen capture and create an image ourselves, then upload it. I would rather propose something more user-friendly but I have no more clue. Is anyone has some advice on it and do I get the picture right ? Thank you. _**_ADDENDUM **** If I could, instead of the thumbnails, just embed the video (usually an iframe) into a with specific size, that could do the trick...


Shortcode output always showing at top of page

my shortcode output won't appear where I put it, but rather at the top of the content (top of the post/page content). And here is my code               function service_shortcode_index() {     global $content;     $output = include ( TEMPLATEPATH . '/service.php' );     return $output;     }          add_shortcode('service_mid', 'service_shortcode_index');      there are some regular HTML lists with widget in "service.php" The content displays correctly, just in the wrong position.


How can I specify the width and height of the Featured Image in TwentyTwelve theme?

I am trying to get set the width, height and position of the Featured image for a new page I created.


Feedburner doesn't work anymore

I really have no idea how to figure out what exactly is wrong and so I'm seeking help here. When I try to validate my feed I get the following error message:                   XML parsing error: <unknown>:8:17928: mismatched tag     ... d/show_ads.js">/*<![CDATA[*/
/*]]>*/</script>

The next day I h ...      The source is the original feed URL, not Feedburner itself, of course. The .js is from Google Adsense that I have implemented in my blog posts recently. I also get this:               In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendation.              line 1, column 485: Self reference doesn't match document location [help]                  ... rel="self" type="application/rss+xml" /><link>http://zoomingjapan.com</l ...      Source here is Feedburner itself. What I did so far is that I removed Adsense almost completely from my blog. The feed recovered partly. At first no latest posts were shown in the feed at all. Now they're shown again: http://feeds.feedburner.com/ZoomingJapan So, it seems to have to do with Adsense or it's just all a huge coincidence. However, what I still don't understand is why the usual Feedburner layout isn't showing up, the the typical RSS Feed Layout instead. Something seems to be going wrong there! Can anybody tell me what exactly is wrong and what I need to do to fix this problem? Let me know if you need any additional information. Thanks so much in advance.


Wp_editor bug with foreach()?

In the user profile I provide some `wp_editor()` for user can insert some extra information the the problem happen                foreach ($condition as $b) {                     $check = $b.$lang;                     ?>                 <div id="tabs-<?php echo $i ?>">                 <?php wp_editor(get_the_author_meta($b . $lang, $profile_id), $check, $settings = array('textarea_name' => $b . $lang, 'textarea_rows' => 10));                 ?>                 </div>             <?php      I'm using tab to switch between these `wp_editor()`, the problem is the `'textarea_rows' => 10` not apply for all `wp_editor()` it just apply for the first editor() .In research I found out that this bug just happen when I using `foreach` with `wp_editor()` to create some editor if i do it manualy like                   <?php wp_editor('', 'test1', $settings = array('textarea_rows' => 10));      wp_editor('', 'test2', $settings = array('textarea_rows' => 5));                         ?>      then the `wp_editor` work nomarlly. Please help why `textarea_rows` not work properly when using `foreach` ?


Custom Field to a Role?

Is it possible to add custom field to a custom role? Say I want to create roles that represent a membership level and want to add billing options to it. So it'd look like this:               Membership level (Custom Role) | Billing options     -----------------------------------------------------------     Free                           | Null     Basic                          | Monthly, Quarterly, Yearly     Pro                            | Yearly, Bi-yearly      The thing I want to achieve is to create a membership level (role) and then on top of attaching capabilities to it, I want to store additional custom data on top of which I can build some business logic. So a role object would look like this:               Role     |- Capabilities (array)     |- Custom Fields (array)        |- Billing (single string)        |- Upgrade options (single string)      Is this possible in Wordpress? Or I'm looking the wrong direction and this should be done in a different way? Thanks in advance


Using "Authy Two Factor Authentication" in custom login page

I have created a custom login page (instead of wp-login that we have in wordpress) and I want to integrate Authy there, I searched everywhere but couldn't find any answers. I have created a custom form and used a hook `add_action( 'after_setup_theme', 'custom_login' );` and from there I am validating user credentials, something like:                  `$creds = array();         $creds['user_login'] = $username;         $creds['user_password'] = $_POST['login_password'];         $creds['remember'] = true;         $user_validate = wp_signon( $creds, false );         if ( !is_wp_error($user_validate) ){           header('Location: '.home_url());              exit();          }`      if the users credentials are valid the user is being redirected to the home page while being logged in too. I have two questions here:   1. I tried enabling Authy for my profile from wp-admin, I tried logging in then and it asked for Authy key that I received as a text message, but I wasn't logged in, instead I was redirected to the home url without being logged in. How do I fix this?   2. How do I allow a user to enable Authy from any custom template (not through wp-login).? I am new to wordpress, I would appreciate if someone could point me in the right direction. Thanks.


How to generate a list of child pages, and use some of their custom fields?

I have a page structure like this:               -Home     -Cars       -Volvo 640        - Pics        - Info       -Porsche 911        - Pics        - Info      I'd like to generate a list of cars on the Cars page of all the cars (which are child pages of Cars). How would I do this? The list is basically a sub- menu which should show all the cars in alphabetical order (note, I don't need links to the 'grandchildren' - Pics, Info). I also need to grab Custom Field data from each car page, and put that beside the link to the page.. is that possible?


Confusion with adding meta capabilities to a role after registering a Custom Post Type with corresponding 'capability_type' parameter

I got quite confused with Custom Post Type (CPT) 'capability_type' parameter and adding generated capabilities to a role. So I've got a CPT called 'external_role' registered as following:               add_action('init', 'external_roles_post_type_init');     function external_roles_post_type_init() {       $labels = array(         'name' => _x('External Roles', 'post type general name'),         'singular_name' => _x('external role', 'post type singular name'),         'add_new' => _x('Add New', 'external role'),         'add_new_item' => __('Add New External Role'),         'edit_item' => __('Edit External Role'),         'new_item' => __('New External Role'),         'view_item' => __('View External Role'),         'search_items' => __('Search External Roles'),         'not_found' =>  __('No job found'),         'not_found_in_trash' => __('No job found in Trash'),          'parent_item_colon' => ''       );       $args = array(         'labels' => $labels,         'public' => true,         'publicly_queryable' => true,         'show_ui' => true,         'has_archive' => 'past-external-roles',         'rewrite' => array('slug' => 'external-roles','with_front' => false),         'query_var' => true,         'capability_type' => array('external_role', 'external_roles'),         'map_meta_cap' => true,         'hierarchical' => false,         'show_in_nav_menus' => false,         'menu_position' => 20,         'supports' => array(           'title',           'editor',           'author',           'custom-fields',           'revisions'         )       );       register_post_type('external_role',$args);     }      So looking at the `capability_type` parameter (if I understand it correctly) will generate the following capabilities: Meta capabilities:   * edit_external_role    * read_external_role   * delete_external_role Primitive capabilities (that are generated based on meta capabilities):   * edit_external_role   * edit_others_external_role   * publish_external_role   * read_private_external_role Ok, so now I would like to grand my capabilities to the `admin` role, so admins can fully manage a new CPT. I was thinking if I only grand `meta capabilities` that would mean that all `primitive capabilities` would be inclusively granted to the role as well? Is that the case? Here is what I've got for adding capabilities to the admin role:               // Add caps for Administrator role     $role =& get_role('administrator');     // external roles capabilities     $role->add_cap('edit_external_role');     $role->add_cap('read_external_role');     $role->add_cap('delete_external_role');      However, this doesn't do the trick. What is the concise and correct way to add all the capabilities to a role to manage a CPT? Many thanks, Dasha **EDIT** I'm using the `init` hook now in the `functions.php` to add caps to the admin role:               add_action( 'init', 'my_custom_roles_capabilities', 0 );     function my_custom_roles_capabilities(){         // Add caps for Administrator role         $role =& get_role('administrator');         // external roles capabilities         $role->add_cap('edit_external_role');         $role->add_cap('read_external_role');         $role->add_cap('delete_external_role');     }


Is there a way to do multiple ordering on a multiple meta_query?

I'm experimenting with searches and multiple criterias and ordering. Let's say we have a real estate site, all posts have 2 custom fields (`price` and `surface`), and we want the visitor to be able to search by entering a :   * minimum price   * maximum price   * minimum surface   * maximum surface This would do the job :               function mwm_register_search_filters( $query ) {              // Only on archive post listings             if( $query->is_archive ) {                  $filters_a = array();                  if( !empty( $_GET['price_min'] ) ) $filters_a[] = array( 'key' => 'price', 'value' => $_GET['price_min'], 'compare' => '>=', 'type' => 'numeric' );             if( !empty( $_GET['price_max'] ) ) $filters_a[] = array( 'key' => 'price', 'value' => $_GET['price_max'], 'compare' => '<=', 'type' => 'numeric' );             if( !empty( $_GET['surface_min'] ) ) $filters_a[] = array( 'key' => 'surface', 'value' => $_GET['surface_min'], 'compare' => '>=', 'type' => 'numeric' );             if( !empty( $_GET['surface_max'] ) ) $filters_a[] = array( 'key' => 'surface', 'value' => $_GET['surface_max'], 'compare' => '<=', 'type' => 'numeric' );                  if( !empty( $filters_a ) ) $query->set( 'meta_query' , $filters_a );              }              return $query;     }     add_filter( 'pre_get_posts' , 'mwm_register_search_filters' );      That's great and it works well. But then comes ordering.. AFAIK Wordpress only allows ordering by one meta_key / meta_value. That's nice but not good enough when you need to order by multiple criterias. Is there a way to order for example :   * First by price ASC   * And within equal prices, order by surface ASC


How to manually specify the current active page with wp_nav_menu()

Is there a way of manually specifying which page is currently "active" when using `wp_nav_menu()`? I have a "Products" page, and on that page I have links to various (dynamic) custom taxonomies. When I click on one of these taxonomies, I stay on the "Products" page but `wp_nav_menu()` loses reference to that fact that I'm still on the "Products" page. Is there a way I can fix this? Thanks! Jon


Fetch the latest post with attachment image

What I want to do seems to be simple but I can't get around it. I'd like to get the latest post that has an image attachment. A little help would be appreciated. Thanks Lita


Determining WordPress' Version from the Host's Command Line?

Given that I can't access the dashboard/admin pages on my blog (that's a future question), and that I have shell access to my hosting server, can I find out the current version of WordPress from the command line? I tried grepping for the string '@since' in all the php files in the top level directory for the blog, and the latest I can see is 2.5...


Appended comments but they show up above the content instead of below

I am trying to append a comments template to the end of the flash object in this plugin file. Below is the full code. To pinpoint exactly where I added the comments template, please refer to this pastebin. The appended comments template is on line 164. For some reason, even though I appended it, the comments template shows up above the flash object rather than below. Does anyone have a clue how I can solve this?               <?php          require_once('ismobile.php');          /******************************************************************     /* Build Player     ******************************************************************/     class Player {              var $width, $height;                        public function buildPlayer( $profileid = 1, $videoid = 1, $autodetect = 1 ) {             global $wpdb;                         $profile      = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."allvideogallery_profiles WHERE id=".$profileid);                  $this->width  = $profile->width;             $this->height = $profile->height;                  if( isset($_GET['slg']) && $autodetect == 1 ) {                 $slug    = $_GET['slg'];                 $video   = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."allvideogallery_videos WHERE slug='$slug'");                 $videoid = $video->id;             } else {                 $video   = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."allvideogallery_videos WHERE  id=".$videoid);             }                     if($video->type == 'thirdparty') {                 $result    = '
width . 'px; height:' . $this->height . 'px;">';                 $result   .= $video->thirdparty;                 $result   .= '
';             } else {                 $arr_params = array();                   $custpage   = ( $profile->custom_page_url ) ? $profile->custom_page_url : $this->curPageURL();                 if( isset($_GET['catid']) ) {                     $arr_params['catid'] = $_GET['catid'];                 }                 if( isset($_GET['sort']) ) {                     $arr_params['sort'] = $_GET['sort'];                 }                             $videosids=$video->id;     $imgad_query=mysql_query("select * from ".$wpdb->prefix."allvideogallery_videos WHERE published='1' and id='$videosids'");     $imgad_row=mysql_fetch_array($imgad_query);     $imgads=$imgad_row['img_ads'];     $text_ads1=$imgad_row['text_ads'];     $ads_links1=$imgad_row['ads_links'];     $imgad_link='';                      $flashvars = 'base='.get_option('siteurl').'&wp=1&vid='.$videoid.'&pid='.$profileid.'&page='.urlencode( @add_query_arg($arr_params, $custpage) );                 $detect    = new IsMobile();                             $result    = $detect->isMobile() ? $this->gethtmlplayer( $profile, $video ) : $this->getflashplayer( $profile, $flashvars, $ads_links1, $imgads, $text_ads1 );                                   }                         $this->updatehits( $video->slug );                  $cust_class = ( $profile->custom_player_class ) ? $profile->custom_player_class : 'avs_player';                  $output  = '               ' . "\n";                                 $output .= '
width.'px;">' . "\n";             if($profile->title) {                 $output .= '
'.$video->title.'
' . "\n";             }             if($profile->category) {                 $output .= '
Category : '.$video->category.'
' . "\n";             }             if($profile->hits) {                 $output .= '
Hits : '.$video->hits.'
' . "\n";             }             $output .= '

' . "\n";             $output .= $result . "\n";             if($video->description) {                 $output .= '
'.$video->description.'
' . "\n";             }             $output .= '
' . "\n";                  return $output;         }                        public function getflashplayer( $profile, $flashvars, $ads_links1, $imgads, $text_ads1 ) {             global $allvideogallery_plugin_dir;                  if(!empty($imgads)) {  $show_ads1=''; } else { $show_ads1=$text_ads1;  }             $get_ads_width=$this->width;             $get_ads_width1=$get_ads_width-30;                  $siteurl = get_option('siteurl');             $src     = $siteurl . '/wp-content/plugins/' . $allvideogallery_plugin_dir . '/player.swf?random=' . rand();                       $result .= '
width . 'px; height:'.$this->height.'px;">
';             if(!empty($imgads) || !empty($text_ads1)) {              $result .= '
';              $result .= '
';             $result .= '
';             //$result .= '';             $result .= ''.$show_ads1.'';                  $result .= '
';             }                  $result .= '<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="' . $this->width . '" height="' . $this->height . '">';             $result .= '<param name="movie" value="' . $src . '" />';             $result .= '<param name="wmode" value="opaque" />';             $result .= '<param name="allowfullscreen" value="true" />';             $result .= '<param name="allowscriptaccess" value="always" />';             $result .= '<param name="flashvars" value="' . $flashvars . '" />';             $result .= '
<object type="application/x-shockwave-flash" data="' . $src . '" width="' . $this->width . '" height="' . $this->height . '">';             $result .= '<param name="movie" value="' . $src . '" />';             $result .= '<param name="wmode" value="opaque" />';             $result .= '<param name="allowfullscreen" value="true" />';             $result .= '<param name="allowscriptaccess" value="always" />';             $result .= '<param name="flashvars" value="' . $flashvars . '" />';             $result .= '</object>
';             $result .= '</object>

';             $result .= comments_template(); //Append the comments template to the result                  return $result;         }              public function gethtmlplayer( $profile, $video ) {             if($video->type == 'youtube') {                 $url_string = parse_url($video->video, PHP_URL_QUERY);                 parse_str($url_string, $args);                 $result  = 'width.'" height="'.$this->height.'" ';                 $result .= 'src="http://www.youtube.com/embed/'.$args['v'].'" frameborder="0" allowfullscreen>';             } else {                 $preview = $video->preview ? 'poster="' . $video->preview . '"' : '';                 $result  = '<video onclick="this.play();" width="'.$this->width.'" height="'.$this->height.'" '.$preview.' controls>';                 $result .= '<source src="'.$video->video.'" />';                 $result .= '</video>
';                 $result .= comments_template(); //Append the comments template to the result             }                  return $result;         }              function curPageURL() {             $pageURL = 'http';                   if (!empty($_SERVER['HTTPS'])) {if($_SERVER['HTTPS'] == 'on'){$pageURL .= "s";}}              $pageURL .= "://";              if ($_SERVER["SERVER_PORT"] != "80") {                  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];              } else {                  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];              }                   return $pageURL;         }              function updatehits( $slug ) {             global $wpdb;                  $table_name = $wpdb->prefix."allvideogallery_videos";             $video = $wpdb->get_row("SELECT * FROM $table_name WHERE slug='$slug'");                     $count = ($video) ? $video->hits + 1 : 1;             $video->hits = $count;                  $wpdb->update($table_name, array('hits' => $video->hits), array('id' => $video->id));         }          }          ?>


Removing parent slug in hierachial custom post type

I need to remove the parent slug in the permalink of a child post. The child post is of a different cpt than the parent post. So I get:               example.com/parentcpt/parent-post-name/child-post-name //which results to a 404.      I need               example.com/child-post-name      or:               example.com/childcpt/child-post-name      Switching between permalink structures doesnt help either. Ive tried a number of plugins but they dont solve. Adding the following doesnt help:               'rewrite' => array('slug' => false, 'with_front' => false)// register_post_type function      Someone help please ... :)


Need some PHP schoolin'! passing var to url and the old options table

So, I've been building a theme options page, one of the purposes of which is to get some style values to pass to my php stylesheet in the url. Here's what I have:               /* Get all theme settings */          global $options;          $options = get_option( 'theme_options' );          /* ...and set 'em up! */          $stylevar = '?ts='.$options['thumbsize'].'?bg='.$options['bg_color'].'?tc='.$options['text_color'].'?hc='.$options['heading_color'].'?nc='.$options['nav_buttons_color'].'';          /* Enqueue */          if( !is_admin() ){          // This format works     wp_register_style('style', (get_bloginfo('stylesheet_directory') . '/lib/css/style.php?ts='.$options['thumbsize'].''));          // This doesn't     wp_register_style('style', (get_bloginfo('stylesheet_directory') . '/lib/css/style.php'.$stylevar.''));          wp_enqueue_style('style');          }      So two things are happening:   1. I am getting a WP debug error I'd like to address: `Notice: Undefined index` etc. Presumably this has to do with not doing an `isset` check?   2. Putting all the settings in a variable is failing, giving me: `"style.php?ts=200%3Fbg%3D%3Ftc%3D%3Fhc%3D%3Fnc%3D&ver=3.2.1" type="text/css"`. Here's where the schooling comes in. Is there a cleaner way of writing this? Could the options all be output with some king of loop? ... and how do I fix it? Willing to learn, please teach :-)


How to display a description of a given category from a custom taxonomy

I have a taxonomy called **`tcp_product_category`**. In the admin panel I have created a few terms within this taxonomy. On the homepage I want to display the description of one of those terms with the slug **`all-products`**. For all normal categories I use this code:               <?php echo category_description( get_term_by('slug', 'guide', 'category')->term_id  ); ?>      This doesn't appear to work with custom taxonomies. The code:               <?php      echo category_description(          get_term_by('slug', 'all-products', 'tcp_product_category')->term_id     );      ?>      All the values I inserted are correct, but the `get_term_by()` simply doesn't give any results. Any ideas how to fix it? Thanks, Chris Planeta


How to use command 'wp post create' in wp-cli properly?

I need to create a single post with title, content and excerpt with this command as it's described in the utility documentation. Could you please show me an example of how to use it? I couldn't find nor in official documentation neither on Google. Thanks!


Pre_get_posts Gives 404 on Custom Post Type

I'm trying to filter the query on a sub page called "Ask Question" to list all of the recent questions submitted by users, but I get a 404 when going to the page. Flushing the permalink structure did not fix the issue. It is currently set to Month and Name. Creating a new question works properly and I'm able to access the new posts. The custom taxonomies work correctly as well, however the archive pages do not. This is the code that I'm using. **Post type**               function question_post_type() {         $labels = array(             'name'                => _x( 'Questions', 'Post Type General Name', 'text_domain' ),             'singular_name'       => _x( 'Question', 'Post Type Singular Name', 'text_domain' ),             'menu_name'           => __( 'Questions', 'text_domain' ),             'parent_item_colon'   => __( 'Parent Question:', 'text_domain' ),             'all_items'           => __( 'All Questions', 'text_domain' ),             'view_item'           => __( 'View Question', 'text_domain' ),             'add_new_item'        => __( 'Add New Question', 'text_domain' ),             'add_new'             => __( 'New Question', 'text_domain' ),             'edit_item'           => __( 'Edit Question', 'text_domain' ),             'update_item'         => __( 'Update Question', 'text_domain' ),             'search_items'        => __( 'Search questions', 'text_domain' ),             'not_found'           => __( 'No questions found', 'text_domain' ),             'not_found_in_trash'  => __( 'No questions found in Trash', 'text_domain' ),         );              $rewrite = array(             'slug'                => '/ask/question',             'with_front'          => true,             'pages'               => true,             'feeds'               => true,         );              $args = array(             'label'               => __( 'question', 'text_domain' ),             'description'         => __( 'Question', 'text_domain' ),             'labels'              => $labels,             'supports'            => array( 'title', 'editor', 'author', 'comments', 'revisions', 'custom-fields', 'page-attributes', ),             'hierarchical'        => false,             'public'              => true,             'show_ui'             => true,             'show_in_menu'        => true,             'show_in_nav_menus'   => true,             'show_in_admin_bar'   => true,             'menu_position'       => 20,             'can_export'          => true,             'has_archive'         => true,             'exclude_from_search' => false,             'publicly_queryable'  => true,             'rewrite'             => $rewrite,             'capability_type'     => 'post',         );              register_post_type( 'question', $args );     }          add_action( 'init', 'question_post_type', 0 );      **Taxonomy**               if ( ! function_exists('custom_question_taxonomy') ) {              // Register Custom Taxonomy         function custom_question_taxonomy()  {             $labels = array(                 'name'                             => _x( 'Question Types', 'Taxonomy General Name', 'text_domain' ),             'singular_name'              => _x( 'Question Type', 'Taxonomy Singular Name', 'text_domain' ),             'menu_name'                  => __( 'Question Type', 'text_domain' ),             'all_items'                  => __( 'All Question Types', 'text_domain' ),             'parent_item'                => __( 'Parent Question Type', 'text_domain' ),             'parent_item_colon'          => __( 'Parent Question Type:', 'text_domain' ),             'new_item_name'              => __( 'New Question Type', 'text_domain' ),             'add_new_item'               => __( 'Add Question Type', 'text_domain' ),             'edit_item'                  => __( 'Edit Question Type', 'text_domain' ),             'update_item'                => __( 'Update Question Type', 'text_domain' ),             'separate_items_with_commas' => __( 'Separate Question Types with commas', 'text_domain' ),             'search_items'               => __( 'Search Question Type', 'text_domain' ),             'add_or_remove_items'        => __( 'Add or remove Question Types', 'text_domain' ),             'choose_from_most_used'      => __( 'Choose from the most used Question Types', 'text_domain' ),         );              $rewrite = array(             'slug'                       => 'question-type',             'with_front'                 => false,             'hierarchical'               => true,         );              $args = array(             'labels'                     => $labels,             'hierarchical'               => true,             'public'                     => true,             'show_ui'                    => true,             'show_admin_column'          => true,             'show_in_nav_menus'          => true,             'show_tagcloud'              => true,             'rewrite'                    => $rewrite,         );              register_taxonomy( 'question-type', 'question', $args );     }                   add_action( 'init', 'custom_question_taxonomy', 0 );          }      **Query**               function question_posts_query( $query ) {              if ( $query->is_post_type_archive( 'question' ) || $query->is_page(3001) && $query->is_main_query() ) {             $query->set( 'post_type', 'question' );         }         return $query;     }     add_filter( 'pre_get_posts', 'question_posts_query' );      **My page loop**               <?php if (have_posts()) :         while (have_posts() ) : the_post(); ?>

                    <?php the_content(__('Read More »', 'gp_lang')); ?>                    <?php the_terms( $post->ID, 'question-type', '
Category: ', '', '
' ); ?>

              <?php endwhile; ?>     <?php endif; ?>


Plugin/Folder permission issues with Azure

Has anyone come across plugin issues when using Wordpress with Azure? I recently spun up a free wordpress install on azurewebsites.net, using PHP 5.4 and Wordpress 3.5. Once plugin in particualr, WPTouch seems to be having issues when creating a folder or uploading a file. Has anyone else had an issues whhere a plugin is failing due to folder permissons?


the_excerpt() and <-- more --> tag

On my archive page, the_excerpt() does not display content before the more tag, but a cut of the post's full content. I'm obliged to fulfill the "Excerpt" in the post editor which will override it. How to force the_excerpt() to show only the content before the more tag?


custom wp_dropdown_categories items in wordpress

I have the wp_dropdown_categories function in my searchform.php file. Right now it lets the user choose what post category they want to search in. Is there a way I can get the drop down to include a custom taxonomy and a custom post type? For example if I have a custom post type for galleries, and a custom taxonomy for places... how can I display a wp-dropdown that lets the user choose to search either "photos" or "locations"?


Are all options loaded to memory on each request?

Are all options variables fetched from the database and loaded to cache on each request?


Customizing HTML Editor Quicktags button to open a dialog for choosing insert options

I am looking for adding custom quicktag buttons,that would allow me to display a intermediary dialog before inserting the code. ## Situation 1) Clicking a quicktag button opens a dialog or thickbox modal window. 2) Opened dialog displays some options on the class, etc and an Insert button. 3) Clicking "Insert" button inserts the code. To add an quicktags button, we would use               edButtons[ edButtonsLength+ ] = new edButton( 'ed_mybutton' , 'Insert button', '
', '
' );     ////     edHTML += '<input type="button" value="Insert custom code" id="ed_my_button" class="ed_button" onclick="edInsertTag( edCanvas, edButtonLength_t + 1)" title="Insert code" />';      Now how can i bypass the button to open a dialog(or thickbox modal) instead? I can add a button without defining it, like               edHTML += '<input type="button" value="Insert custom code" id="ed_my_button" class="ed_button" onclick="customFunction()" title="Insert code" />';     // and     var customFunction = function() {        openURL = '<?php admin_url() ?>admin-ajax.php?action="insertCodeAction&TB_iframe=true';        tb_show( 'Insert custom code', openURL );     };      Please share your wisdom. Thanks in advance. PS : doing this with TinyMCE is relatively easy, i wonder how do i do that with HTML quicktags. :)


All wordpress network subfolder sites being redirected to main site

I have a WP network setup running the latest versions of WP and Buddypress. I want to set up ~40 users with blogs, and have created these blogs using the Batch Create plugin, but now when I try to visit one of these folders, eg burkphysics.com/elizabethf, it redirects to burkphysics.com. All sites, even sites I create manually do this. I've followed the config steps to properly configure both my wp-admin file and .htaccess file, and I can't see any problems. This also worked fine last year before I upgraded wordpress and buddypress. Here's the .htaccess file:               RewriteEngine On     RewriteBase /wordpress/     RewriteRule ^index\.php$ - [L]          # uploaded files     RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]          # add a trailing slash to /wp-admin     RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]     RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]     RewriteRule . index.php [L]      Any help would be greatly appreciated.


Why does $wpdb return strings for mysql integer values?

I find it very inconvenient and hard to understand that the default behavior of the Wordpress db-interface is to convert all integer (and float?) types to strings. e.g               $wp_posts = $wpdb->get_results('SELECT * from wp_posts');     $unexpected_type = gettype($wp_posts[0]->ID)  == 'string';      Please confirm my suspicion that this is done in order to support very large (capacious) integer types that are not supported by PHP, or provide an alternative explanation as to why one would chose to convert integers to strings. The second part of my question, as maybe expected, is to find out if there is a built in configuration parameter to the `wpdb` class that would allow one to request _integers_ for integer-type records.


Dynamic taxonomy in permalink made all other posts NOT FOUND?

I added my taxonomies in the permalink instead of the Custom Post Type's slug, and it works fine. I'd even say everything was working fine but changing the WP installation to Multisite broke all other posts and pages (not the CPTs). The permalinks are generated correctly every time as ?p=123 or other guessed urls, so the post info is found, but not found for the loop. This is how I got the taxonomy in place of the CPT's slug: 1) The post_type rewrite is defined as %listing_type% and it works fine, as follow:               'rewrite' => array(                  'slug' => '/%listing_type%',                  'with_front' => false,      2) And the following functions replace the %listing_type% and "listing_type" string from the urls and term links, generated by e.g. wp_list_categories(), respectively (removing the CPT's name from the url)                 function listing_type_link_filter_function( $post_link, $id = 0, $leavename = FALSE ) {         if ( strpos('%listing_type%', $post_link) === 'FALSE' ) {           return $post_link;         }         $post = get_post($id);         if ( !is_object($post) || $post->post_type != 'listing' ) {           return $post_link;         }         $terms = wp_get_object_terms($post->ID, 'listing_type');         if ( !$terms ) {           return str_replace('/listing_type', '/', $post_link);         }         return str_replace('%listing_type%', $terms[0]->slug, $post_link);       }          add_filter('post_type_link', 'listing_type_link_filter_function', 1, 3);                 function term_link_filter_function( $termlink, $term, $taxonomy ) {         if ( strpos('listing_type', $termlink) === 'FALSE' ) {           return $termlink;         } else  return str_replace('/listing_type', '', $termlink);       }          add_filter('term_link', 'term_link_filter_function', 1, 3);      Now, I'm almost certain that everything was working fine before I made it a Multisite. I'll research how to safely un-do it (the multisite thing) and post the update later. Any idea what could be breaking the posts and pages NOT in the above CPTs? If I remove the %s from the post_type slug, everything works fine. **UPDATAE** I noticed other working examples had a rewrite rule for each custom permalink, so I added it, and VOILA, the posts are fixed now, but the pages are still broken **THIS PARTIALLY WORKS (posts only)**               global $wp_rewrite;     $wp_rewrite->extra_permastructs['listing'][0] = "%listing_type%/%postname%";         add_rewrite_rule("([^/]+)/([^/]+)/?$", 'index.php?post_type=listing&listing_type=$matches[1]&name=$matches[2]', 'bottom');         add_rewrite_rule("([^/]+)/([^/]+)/?$", 'index.php?post_type=listing&listing_type=$matches[1]&page=$matches[2]', 'bottom');      The above code (inside the CPT definition function) **only fixed the posts** , but the pages (what the second add_rewrite_rule line was ment for) are still broken.


How to publish custom post type for custom role user and not "submit for review"?

I've created a custom post type 'openproject', where i set capabilities.               function custom_post_openproject() {         $labels = array(             'name' => 'openproject',             'add_new' => 'Add new openproject',             'add_new_item' => 'Add new openproject',             'edit_item' => 'Edit openproject',             'menu_name' => 'Openproject'         );         $map_meta_cap = true;         $capability_type = 'openproject';         $capabilities = array(             'edit_files' => 'edit_files',             'upload_files' => 'upload_files',             'edit_post' => 'openproject_edit',             'read_post' => 'openproject_read',             'delete_post' => 'openproject_delete',             'edit_posts' => 'openprojects_edit',             'edit_others_posts' => 'openprojects_edit_others',             'publish_posts' => 'openprojects_publish',             'delete_posts' => 'openprojects_delete',             'delete_published_posts' => 'openprojects_delete_published',             'delete_others_posts' => 'openprojects_delete_others',             'edit_publish_posts' => 'openprojects_edit_publish',         );              $args = array(             'labels' => $labels,             'public' => true,             'show_in_nav_menus' => true,             'show_ui' => true,             'show_in_menu' => true,              'capability_type' => $capability_type,             'capabilities' => $capabilities,             'map_meta_cap' => $map_meta_cap,             'hierarchical' => false,             'with_front' => false,             'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comment'),             'has_archive' => false,             'rewrite' => array('slug'=>'openproject'),         );         register_post_type( 'openproject', $args );     }      I assigned this custom post type to a custom role 'openproject_access'               function openproject_user_can(){         $newrole = add_role(              'openproject_access',              'Membre OpenProject',              array(                 'read'=> true,                      'openprojects_publish' => true,                 'openproject_read' => true,                 'openproject_edit' => true,                 'openprojects_edit_others' => false,                 'openprojects_edit' => true,                 'openproject_delete' => true,                 'openprojects_delete' => true,                 'openprojects_delete_others' => false,                      'edit_comment' => false,                 'moderate_comments' => false,                 'edit_files' => true,                 'upload_files' => true,             )         );      }      I've created a user with this role, but when i'm logged in as this user, the problem is when i create a new 'openproject', i have only "Submit for review" button and not "Publish" ! I think i have set the publish capability properly in my setting (`'publish_posts' => 'openprojects_publish'`, in CPT and `'openprojects_publish' => true,` in the role) What i have missed ? EDIT To be complete, i've tried this on a fresh install of WP 4.0. In my wp_usermeta i've got `a:1:{s:18:"openproject_access";b:1;}` for the capability of that user


Query recent posts by author

I'm fairly new to wordpress but trying to get recent posts by a specific author. The following code displays only most recent bog posts. I am using a custom field to get the author ID. EDIT by vancoder: By which I mean, I am using the ACF plugin, which allows the selection of 1 or more WP users, the api returns the selected user objects Any suggestions would be amazing ...               <?php $current_user = get_field('username');     if( $current_user ) : ?>

Knowledge Community Articles
         <?php $userID = $current_user->ID;         $args = array(         'author' => $userID,         'showposts' => 2,         'caller_get_posts' => 1         );               $query = new WP_Query($args);         if( $query->have_posts() ) {         while ($query->have_posts()) : $query->the_post(); ?>             <div class="article-excerpt<?php echo ' excerpt-' . $c; ?>">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

By <a href="<?php echo get_author_posts_url(get_the_author_meta( 'ID' )); ?>"><?php the_author_meta('display_name'); ?>

                 <?php the_excerpt(); ?>
             <?php endwhile; } ?>             <a href="<?php echo get_author_posts_url(get_the_author_meta( 'ID' )); ?>">More from this Contributor →
     <?php endif; ?>


How to let a user select a media from the media library

Sorry for the low level of research but the media JS code was always a mystery to me, and googling doesn't show any current and reasonable answers. The scenario is simple, I have a form in which I want to let the user either upload a new image or select one from the media library. Easiest way seems to be to open the add media modal and let it handle the actual upload if needed. so all I need is   1. The easy part - open The media modal.    2. The harder part - get the id and maybe the url of the selected media when it closes Is it even possible without extending the modal in some way? I can probably live with the default text on the buttons, but it will be nice to change this as well.


Problem in viewing recent posts from network site to main site

I have created a website in wordpress **damiracle.com** where there I already made a Blog Page. But the client wants to host the blog in a subdomain **blog.damiracle.com** and with different theme. So I made **damiracle.com** , the main and the network admin site after following all the procedure of Codex Creating a Network. After creating the Network I added a new site for blog which is in a sub domain named as **blog.damiracle.com**. I also installed WordPress MU Domain Mapping and WordPress MU Sitewide Tags Pages to view the Recent posts from the **blog.damiracle.com** to the **damiracle.com** but I am facing problem in viewing the posts from the **blog.damiracle.com** to **damiracle.com**. All the posts are viewing are the recent posts which are already inside the blog page of **damiracle.com** I know that I am going wrong but I can't figure out what wrong actually I am doing.


How to modify Genesis core function?

I am trying to modify a Genesis framework core function. I want to remove `strip_shortcodes()` from the function `get_the_content_limit()`. Here is my code:               if ( wp_get_theme( 'genesis' ) ) {     // replace get_the_content_limit() with the custom one     remove_filter( 'the_content_limit', 'get_the_content_limit' );     add_filter( 'the_content_limit', 'custom_get_the_content_limit' );          // copied from genesis/lib/functions/formatting.php:57     function custom_get_the_content_limit( $max_characters, $more_link_text = '(more...)', $stripteaser = false ) {              $content = get_the_content( '', $stripteaser );              //* Strip tags and keep shortcodes so the content truncation count is done correctly         $content = strip_tags( $content, apply_filters( 'get_the_content_limit_allowedtags', '


Targeting a Certain Post in Loop (CSS)

I am making a Top Photos section in a page. This section will have 3 last post (there are galleries in the posts), each with thumbnail, link and excerpt from the posts. The posts will be displayed in "box-style" and align horizontally. Container for these boxes is 1050px wide. Here is my loop:
     <?php $custom_query = new WP_Query('cat=2687&posts_per_page=3'); //Top of the page - Top Photo Category      while($custom_query->have_posts()) : $custom_query->the_post(); ?>
         <li <?php post_class(); ?> id="post-<?php the_ID(); ?>">             <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('top-photo-thumb'); ?>
<?php the_title(); ?>

 <?php llc_excerpt('llc_excerptlength_long', 'llc_excerptmore') ?>

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

     <?php endwhile; ?>     <?php wp_reset_postdata(); // reset the query ?>
      and here is my CSS file:               #top-content{         margin-left: -10px;     }          #top-content ul{         margin: 0 4px;         float: left;     }          #top-content ul li{         width: 320px;         height: 100%;         margin: 0 5px 0 5px;         padding: 0 14px 0 0;         /*display: block;*/         border-right: 1px solid #D6D5D5;     }          #top-content h2 {         font-family: Verdana, Geneva, sans-serif;         font-size: 12pt;         font-style: normal;         line-height: 12pt;         font-weight: bold;         font-variant: normal;         text-transform: none;         color: #4A65A8;         padding: 0px;         margin: 7px 0 0 0;         text-align: left;     }          #top-content ul li p{         width: 320px;         margin: 5px 0 0 0;         text-align: justify;     }          #top-content ul:last-child{         margin-left: 5px;         background-color: yellow;         border-style: 0px;     }          #top-content ul:last-child a img{         margin-left:23px;        }          #top-content ul:last-child h2{         margin-left:23px;        }          #top-content ul:last-child p{         margin-left:23px;        }      (sorry about the messy code.. I've been experimenting :P) I want to make a CSS division-line between these "boxes" (posts). The first and third (last) boxes should be placed right at the left and right edge of the container respectively **without** left and right border, so I think the way to achieve this is by targeting the **second post and then add left and right border** into it. How do I achieve it or do you have other suggestion? (I think it is possible to add custom class at the loop). As you can see, I've been trying to use last-child (with nth and that "n" thingy) selector and still no luck.. I'm not really good at CSS (and PHP) TBH.. Thanks in advance!


How can have a conditional template tag based on the main loop within a secondary loop with new WP_Query(), using get_template_part()

What is the best practice methodology for referencing the main loop from within the context of a secondary loop within a partial called via get_template_part()? For example, say my homepage contains a secondary loop to list two posts of type article:               <?php     $articles = new WP_Query( array(         'post_type' => 'article',         'posts_per_page' => 2     ) );     if ( $posts->have_posts() ) : ?>
             <?php                 while ( $articles->have_posts() ) : $articles->the_post();                     get_template_part( 'templates/listing', 'article');                 endwhile;             ?>
     <?php         endif;     ?>      And in /templates/listing-article.php, I have:               <?php if (!is_front_page()) : ?>
<?php the_content(); ?>
     <?php endif; ?>      Here, the_content() lists the content of the article as expected/intended. is_front_page() returns false as expected, but not as intended - my intention is to show the content if on any page except the homepage. My question is thus: how does one make conditional template tags like is_front_page() return true/false based on the post in the main loop, as opposed to my secondary loop. You could set a global variable in your homepage template that you then reference in your partial, but I'm asking if there's a standard, better solution.


Display author's images only in wp.media

I am using the wp.media modal screen to upload and manage media library. I am using the following code.               file_frame = wp.media.frames.file_frame = wp.media({                 title: "Choose or Upload New Photos",                 button: {text: "Select"},                 library: {type: 'image', author: userSettings.uid},                 id: 'logo-frame',                 multiple: false,                 editing_sidebar: false,                  default_tab: 'upload',                 tabs: 'upload, library',                  returned_image_size: 'thumbnail'             }); I would only like to display images by a certain author thus I am using the following line. author: userSettings.uid. This is not working, all images are still being displayed. Thanks in advance.


what is the use of /wp-includes/SimplePie?

I have this location on my server. `/home/localhost/public_html/wp- includes/SimplePie.` I have not installed samplepie plugin. What is it used for since it is not associated with samplepie plugin. The reason I ask is that, I have fatal error generated from different php files in that location. Each time I debug the error a new error in different file which is at the same location is created. Later I found that it was associated with a plugin. I have removed the plugin but the folder still exist. What is that used for.?


Including 'wp-load.php' after another include() generates an error

I know all the downsides of trying to include wp-load.php, but bear with me :) I'm trying to create my own admin-ajax-like functionality, in a way that I can control whether or not I load the default WordPress environment, whether I load it with the `SHORTINIT` constant defined as true, and with granular control over each module of my plug-in, as required by the specific function being access via AJAX. The only way I can think of doing that is doing AJAX via a custom file, other than admin-ajax.php, and then including wp-load.php when desired. I've actually used it successfully for months. I've named the file `bootstrap.php`, and it sits inside my plugin's 'includes' directory. Requiring `wp-load.php` from within `bootstrap.php` will load WP just fine. Today I decided I needed more control, so I attempted to delay the request for `wp-load.php` for when I've loaded the files containing the AJAX functions. Those files are called within `bootstrap.php` with `include()`, but requiring `wp-load.php` within those files will generate the following error:               Notice: Undefined variable: wpdb in .../wp-includes/ms-settings.php on line 126     Fatal error: Call to a member function set_prefix() on a non-object in .../wp-includes/ms-settings.php on line 126       The problem occurs within the loading of WP, so obviously the `require()` call points to the correct location of the `wp-load.php` file. Calling it from the file of the URL request works fine, but calling it after an `include()` breaks the entire thing... any ideas why? Thanks in advance!


Attempt to display site authors in a carousel - User Image not Outputting inside li tags

I am attempting to display the authors of my site in a jquery carousel but for some reason my images are outputted outwith the `li` tags and I don't know why. **Code** `functions.php`               function contributors() {         global $wpdb;              $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY display_name");              foreach($authors as $author) {             // display user image for each author             echo '
ID.'">'.userphoto($author->ID).'
';         }     }      **Template File**               <?php while ( have_posts() ) : the_post(); ?>

<?php contributors(); ?>

          <?php endwhile; // end of the loop. ?>      **Output**

      What I am aiming for is the image to be outputted between the `li` tags. A bonus question if someone knows the answer - how to edit the query so that only authors are displayed and not site admins? I tried adding a `WHERE` clause to the query but it didn't work. Any help is much appreciated as I am a WordPress n00b.


Wp get all the sub pages of the parent using wp query

Here is my code               $my_wp_query = new WP_Query();     $all_wp_pages = $my_wp_query->query(array('post_type' => 'page','post_parent'=>$parid,'orderby'=>'title','order'=>'ASC' ));      It displays the first level sub pages only. I need all the sub page, sub's sub page ... and all. I searched for a solution and i can get all sub pages using get_pages and wp_list_pages. But i really need to sort the order by custom post meta value. So i have to use custom query. please help. Thanks


custom avatar removal

Hello i have implemented a custom avatar upload from front-end in my wordpress theme. It is working. User can add and remove customa avatar. My problem is when user selects to remove his/her custom avatar, it is removing it from avatar meta but the uploaded avatar image files remains in the server. What i want to make is also force delete the image files of avatar from the server. This is the template of user_profile.php;               <?php     global $current_user, $wp_roles;     get_currentuserinfo();          ?>
         <?php the_content();                 if ( isset($_REQUEST['error']) && $_REQUEST['error'] == 'true' ){                $error = __('The passwords you entered do not match.  Your password was not updated.', 'cosmotheme');           }elseif( isset($_REQUEST['success']) && $_REQUEST['success'] == 'true' ){               $success = __('Your profile info was updated.', 'cosmotheme');           }                     if ( $error ) echo '
' . $error . '
';            if ( isset($success) ) echo '
' . $success . '
';               ?>                   <?php if ( !is_user_logged_in() ) : ?>
                     <?php _e('You must be logged in to edit your profile.', 'cosmotheme'); ?>
         <?php else : ?>             <?php                        ?>     <form method="post" id="adduser" action="<?php the_permalink(); ?>">
     <?php     $action['group'] = 'avatar';     $action['topic'] = 'upload';     $action['index'] = '';     $action['upload_url'] =  home_url().'/wp-admin/media-upload.php?post_id=-1&type=image&TB_iframe=true';          $custom_avatar_url = '';         $custom_avatar_meta =  get_user_meta($current_user->id, 'custom_avatar', true);     if(is_numeric($custom_avatar_meta) && $custom_avatar_meta > 0){     $custom_avatar_url = wp_get_attachment_url($custom_avatar_meta);     }     ?>     <?php _e('Profile picture', 'cosmotheme'); ?>
<input type="button" class="button-primary front_post_input" id="upload_btn" value="<?php _e('Choose file','cosmotheme'); ?>" <?php echo fields::action( $action , 'extern-upload-id' ) ?>  />
     <input type="text" name="image" value="<?php echo $custom_avatar_url; ?>" class="generic-record front_post_input" id="avatar_upload"  onclick="jQuery('#upload_btn').click();"  />     <input type="checkbox" name="remove_avatar" <?php echo $disabled ?> value="1" id="remove_avatar"> <?php _e('Remove avatar', 'cosmotheme'); ?>     <input type="hidden" name="avatar_id" id="avatar_upload_id" value="<?php echo $custom_avatar_meta; ?>"  class="generic-record generic-single-record " />

                     <?php _e('Username', 'cosmotheme'); ?>                     <input class="text-input" name="user-name" type="text" id="user-name" disabled value="<?php the_author_meta( 'user_login', $current_user->id ); ?>" />

                     <?php _e('First name', 'cosmotheme'); ?>                     <input class="text-input" name="first-name" type="text" id="first-name" <?php echo $disabled ?> value="<?php the_author_meta( 'user_firstname', $current_user->id ); ?>" />

                     <?php _e('Last name', 'cosmotheme'); ?>                     <input class="text-input" name="last-name" type="text" id="last-name" <?php echo $disabled ?> value="<?php the_author_meta( 'user_lastname', $current_user->id ); ?>" />

                     <?php _e('E-mail *', 'cosmotheme'); ?>                     <input class="text-input" name="email" type="text" id="email" <?php echo $disabled ?> value="<?php the_author_meta( 'user_email', $current_user->id ); ?>" />

                     <?php _e('Website', 'cosmotheme'); ?>                     <input class="text-input" name="url" type="text" id="url" <?php echo $disabled ?> value="<?php the_author_meta( 'user_url', $current_user->id ); ?>" />

                     <?php _e('Password *', 'cosmotheme'); ?>                      <input class="text-input" name="pass1" <?php echo $disabled ?> type="password" id="pass1" />

                     <?php _e('Repeat password *', 'cosmotheme'); ?>                     <input class="text-input" name="pass2" <?php echo $disabled ?> type="password" id="pass2" />

                     <?php _e('Biographical information', 'cosmotheme') ?>                     <textarea name="description" id="description" <?php echo $disabled ?> rows="3" cols="50"><?php the_author_meta( 'description', $current_user->id ); ?></textarea>

                     <?php //echo $referer; ?>                     <input name="updateuser" type="submit" id="updateuser" <?php echo $disabled ?> class="submit button" value="<?php _e('Update', 'cosmotheme'); ?>" />                     <?php wp_nonce_field( 'update-user' ) ?>                     <input name="action" type="hidden" id="action" <?php echo $disabled ?> value="update-user" />
             </form>             <?php endif; ?>
        And this is the user_profile_update.php;               <?php          /* Get user info. */     global $current_user, $wp_roles;     get_currentuserinfo();          /* Load the registration file. */     //require_once( ABSPATH . WPINC . '/registration.php' );          /* If profile was saved, update profile. */     if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'update-user' && ( !defined('IS_FOR_DEMO' ) || get_the_author_meta( 'user_login', $current_user->id ) != 'demo') ) {              /* Update user password. */         if ( !empty($_POST['pass1'] ) && !empty( $_POST['pass2'] ) ) {              if ( $_POST['pass1'] == $_POST['pass2'] ){                 wp_update_user( array( 'ID' => $current_user->id, 'user_pass' => esc_attr( $_POST['pass1'] ) ) );             }else{                 $error = __('The passwords you entered do not match.  Your password was not updated.', 'cosmotheme');             }         }              /* Update user information. */         if ( !empty( $_POST['url'] ) )             update_user_meta( $current_user->id, 'user_url', esc_url( $_POST['url'] ) );         if ( !empty( $_POST['email'] ) )             update_user_meta( $current_user->id, 'user_email', esc_attr( $_POST['email'] ) );         if ( !empty( $_POST['first-name'] ) ) {              update_user_meta( $current_user->id, 'first_name', esc_attr( $_POST['first-name'] ) );          }         if ( !empty( $_POST['last-name'] ) )             update_user_meta($current_user->id, 'last_name', esc_attr( $_POST['last-name'] ) );         if ( !empty( $_POST['description'] ) )             update_user_meta( $current_user->id, 'description', esc_attr( $_POST['description'] ) );              if ( !empty( $_POST['avatar_id'] )  && $_POST['avatar_id'] != get_user_meta($current_user->id, 'custom_avatar', true) && empty( $_POST['remove_avatar'])){              update_user_meta( $current_user->id, 'custom_avatar', esc_attr( $_POST['avatar_id'] ) );         }elseif( !empty( $_POST['remove_avatar']) && $_POST['remove_avatar'] == 1){             update_user_meta( $current_user->id, 'custom_avatar', '-1' );         }         /* Redirect so the page will show updated info. */        // if ( !$error ) {             $redirect_url   = get_permalink();                     if(isset($error) && $error != ''){                           $msg        = array( 'error' => "true" );                     }else{                           $msg        = array( 'success' => "true" );                      }                     $_url    = add_query_arg( $msg , $redirect_url );                  wp_redirect( $_url );             exit;        // }     }     ?>      As you can see if the user checks the input "remove avatar" i am updating the custom_avatar meta -1 which makes it invisible to show. This is working but as i said before, i also need to force delete the image file from the server. Can you help me? Thanks.


Blog automatically redirected to error page

I have a blog link. It was loading fine, but now when I open it. It redirects to error page.


blog url redirecting

I used to host a word press blog and a forum on a server (srv71) with a domain name. And a few days ago I transferred my whole site to a new server (srv14) but I havn't updated my dns and I've shutdown the former server srv71. So visiting my.domain.name/blog or my.domain.name/phpbb would lead to time out error. I tried to connect my new blog and forum using the IP address and this problem occurred. Visiting the forum is fine (my.ip.addr.14/phpbb) but the blog would try to redirect me to my.domain.name/blog, not my.ip.addr.14/blog. I looked into the wp-config.php and found this line:               define( 'DOMAIN_CURRENT_SITE', 'my.domain.name' );      I thought I got it and replaced 'my.domain.name' with 'my.ip.addr.14', then visiting my.ip.addr.14/blog wourd return an establishing database connection error (all the database, username, password, hostname are correct in wp- config.php, I'm certain of that). Then I commented out this line, leaving it as default. Then again my.ip.addr.14/blog redirected me to my.domain.name/blog. Then I backup my blog database, deleted .htaccess and wp-config.php, and reinstalled and generated new .htaccess and wp-config.php files. Now my.ip.addr.14/blog would show a empty blog with 'hello world', the first post by default. Then I imported the database and again my.ip.addr.14/blog redirected me to my.domain.name/blog. I checked the 'wp_' tables such as wp_options and wp_site but found no manually set values (all NULL) about the site url. The newly generated .htaccess is identical to the former .htaccess file. The former wp-config.php is 8 line longer than the newly created (default) wp- config.php:               define('WP_ALLOW_MULTISITE', true);     define( 'MULTISITE', true );     define( 'SUBDOMAIN_INSTALL', false);     $base = '/blog/';     define( 'DOMAIN_CURRENT_SITE', 'my.domain.name' );     define( 'PATH_CURRENT_SITE', '/blog/' );     define( 'SITE_ID_CURRENT_SITE', 1 );     define( 'BLOG_ID_CURRENT_SITE', 1 );      Any one has dealt with similar problems? Thanks!


Problem using explode inside add_shortcode() callback funciton

Explode not working as i expect inside add_shortcode() callback funciton. **Here is the scenario:** My implemented sortcode is like this:               [table]         name1 = value1;         name2 = value2;         name3 = value3     [/table]      Which I make table using simple explode. Exploding `;` to get each row then exploding `=` to put them in right column. But explode is not working right. It exploding the whitespace after `"`, `-` and so on. I have tested the function outside wordpress to check if it have problem working with string but it works fine. Here is page where you see the table http://computercarebd.com/?product=dell- inspiron-4030 When you look at the table you will see the **Display** row is got broken (made another array element by `explode();`) after **14.0″** And here is the shortcode for it http://pastebin.com/ZYuuNb11 When you check the homepage you will see the features i have added on the product preview where i used the same method but its working fine. I have used `get_the_content()` to get the content then used the same explode method. So, i believe I have to modify the contents on the the table_shortcode() callback function to make it work with explode. Thanks and let me know if i was clear enough.               function table_shortcode($atts, $content = NULL){         $content = strip_tags($content);         $contents = explode(';', $content);         extract(shortcode_atts(array('width' => '370px', 'align' => 'alignright'), $atts));              $table = '
';         foreach($contents as $content){             if(!empty($content)){                 $table .= '
';                     $row_items = explode('=', $content);                     $table .= '
'.(trim($row_items[0])).'
';                     $table .= '
'.(trim($row_items[1])).'
';                     $table .= '

';                 $table .= '
';             }         }         $table .= '
';         return $table;     }


What log files does a WordPress installation write to?

When tracking down WordPress problems, I've had a hard time finding where WordPress sends errors to. Where does WordPress send errors by default? Are there multiple files that different kinds of errors are directed to? (I'm either a terribly ungifted Googler or WordPress's own documentation is hard to sort through.)


get_posts in meta box dropdown not showing latest posts

I’ve got a metabox I set up using WPAlchemy that allows authors to add a link to an associated post. It’s been working fine for months but now for some reason the dropdown with the appropriate posts isn’t updating. Here’s the code in the custom post meta php file:               <p>          <?php $mb->the_field(‘product_video_ID’); ?>     <select name=”<?php $mb->the_name(); ?>”>     <option value=”">None</option>          <?php          global $thispost;     $myposts = get_posts(‘numberposts=5000&offset=1′);          foreach($myposts as $thispost) :     if (in_category(“Product Videos”, $thispost)) {     ?>     <option value=”<?php echo $thispost->ID; ?>” <?php $mb->the_select_state($thispost->ID);?> ><?php echo get_the_title($thispost->ID); ?></option>          <?php } ?>          <?php endforeach; ?>     <?php setup_postdata($thispost);?>     </select>     </p>      I tried adding a couple test posts in the Product Videos category and they didn’t show, either. I commented the lines that filtered for that category and the Meta box dropdown updated to show every post… except the one I wanted and the new test ones. Anybody have any idea what might be going on? Is there some part of the machinery here that isn’t updating that I should fix? Thanks so much!


Using a page (Blog template) for home page blog posts is problematic?

I bought a few themes that by default don't have blog posts on home page as normal WordPress themes such as Twenty Eleven has. I had to create a page of Blog template and then use it for home page in Settings -> Reading. It works, except for the pagination pages aren't redirecting properly AND page number isn't shown in the page title. For example, both of these pages are accessible with or without trailing slash:   * http://www.shanghaiwebhosting.com/page/3/   * http://www.shanghaiwebhosting.com/page/3 And they NEVER redirect to the canonical one as normal WordPress blog pagination pages should. And the page number isn't being displayed in <title></title>, it's just "Page | Shanghai Web Hosting". Seems $paged or $page variable isn't assigned a value or something. It's all the same problems with another site that I used a Blog template page for the home page:   * http://www.rackspacereviews.org/page/3/   * http://www.rackspacereviews.org/page/3 Are both accessible and NEVER redirects. The page number is neither shown in the title tag. Any idea why this is happening and how I can fix this? Would it be a theme issue or is it a WordPress bug? Thanks!


jQuery UI Datepicker not working

i want to add a datepicker on a custom page but i doesn not work. WP version is 3.2.1. Those are the init string i used on wp code:               wp_enqueue_script('jquery');     wp_enqueue_script('jquery-ui-core');     wp_enqueue_script('jquery-ui-datepicker', get_bloginfo('template_url') . '/js/jquery-ui-datepicker.min.js', array('jquery','jquery-ui-core'));     wp_enqueue_style('jquery.ui.theme', get_bloginfo('template_url') . '/js/smoothness/jquery-ui-1.8.16.custom.css');      Those enqueques generate this code:                              <link rel='stylesheet' id='jquery.ui.theme-css'  href='http://www.xxxxxxxx.it/wp-content/themes/greyzed/js/smoothness/jquery-ui-1.8.16.custom.css?ver=3.2.1' type='text/css' media='all' />      On the page body, i use this code:
Data<input type="text" id="datepicker" name="day" class="text" />
      The datepicker does not work. I do not know how to debug this issue. It does nothing, like the jQuery is not even there. **UPDATE:** With your help i managed to debug the code. I placed the script after the div and changed into:                     This code give me error when calling the datepicker method, the error states:               Uncaught TypeError: Object [object Object] has no method 'datepicker'      If i type jQuery('#datepicker') on javascript console, i get this:               [<input type="text" id="datepicker" name="day" class="text">]      I get no other errors except for that one, all the references to jQuery seems to work fine. **UPDATE 2:** Finally i got it working! i had to place 'wp_print_scripts' instead of 'init', and i had to reposition some init code of another plugin that was conflicting. The only remaining issue are the themes... if i use the basic theme within googlecode, it works. If i use other themes (embedded in wp or linked with wp_enqueque_style) the theme will be not loaded.... if i check the generated html, there is no sign of the line that should load the jQuery theme.


List Categories By Specified First Character

I'm trying to get category list by specified first character. For example if specified character query is "A", then just wanna list categories start with "A". How is it possible?


Extend the twentyten dropdown menu with jQuery with a delay onmouseout

I would like to extend the pure CSS dropdown menu of the standard twentyten theme in order to accomodate a small delay on hiding the submenu onmouseout. Is there any way we could do this using jQuery? I've seen some solutions using hoverIntent:   * jQuery Hoverintent plugin in TwentyEleven Menu   * Improving the Thesis built-in dropdown menu via javascript. These do not seem to work for me. I have multiple levels of navigation, and the solutions above display all sublevels of the navigation at once (without the delay onmouseout). Could anyone please help me out? Does a plugin maybe exist for this sort of thing? Thanks in advance


Custom Taxonomy 404

I've created a couple of custom post types:               add_action( 'init', 'register_post_types' );     function register_post_types() {         register_post_type(             'jobsearch-post',             array(                 'labels' => array(                 'name' => __( 'Job Searches Post' ),                 'singular_name' => __( 'Job Search Post' )             ),             'public' => true,             'has_archive' => true,             'rewrite' => array(                 'slug' => 'jobsearch'             )         )     );     register_post_type(         'recruiters-post',         array(             'labels' => array(                 'name' => __( 'Recruiters Post' ),                 'singular_name' => __( 'Recruiter Post' )             ),             'public' => true,             'has_archive' => true,             'rewrite' => array(                 'slug' => 'recruiters'             )         )     );     }      Which appear to be working correctly. However, I have a couple of related taxonomies:               add_action( 'init', 'register_taxonomies' );     function register_taxonomies() {     register_taxonomy(         'recruiters-tax',         array (             0 => 'recruiters-post',         ),         array(             'hierarchical' => true,             'label' => 'Recruiters Taxonomy',             'show_ui' => true,             'query_var' => true,             'rewrite' => array(                 'slug' => ''             ),             'singular_label' => 'Recruiter Taxonomy'         )     );     register_taxonomy(         'jobsearch-tax',         array (             0 => 'jobsearch-post',         ),         array(             'hierarchical' => true,             'label' => 'Job Searches Taxonomy',             'show_ui' => true,             'query_var' => true,             'rewrite' => array(                 'slug' => ''             ),             'singular_label' => 'Job Search Taxonomy'         )     );     }      As you can see these are hierarchical. Unfortunately, though, I get a 404 ONLY if I try to access items within the recruiters taxonomy, e.g: `http://localhost:8888/recruiters/some-category` I can access job postings: `http://localhost:8888/jobsearch/some-category` And I can also access the root custom post types: `http://localhost:8888/recruiters` `http://localhost:8888/jobsearch` Is there something I'm missing that is preventing me from reaching nested taxonomies from only the recruiters taxonomy? Note that I have been constantly hitting the "Save Changes" button in my permalink settings in between trying to get this to work. This is driving me crazy!


Get list of all custom tanonomy id

I created a custom taxonomy called Location then added New Jersey, New York, etc. Is there a Wordpress function that will get the list of all ids under the Location similar to what get_all_category_ids() does?