Building a List of Posts grouped by custom taxonomy as the section header only to be displayed if at least one post is in that tax

I have CPT "Dealers" and a custom tax of "States" where each post in the CPT is associated to one state. The hope is to create the header for the state then list each post in that state taxonomy under it; and only show the state header if at least one post is associated with it. All this does right now is display the STATE as the               h3 class="state" tag and doesn't list the posts associated with the tax. e.g. **STATE 1**   **STATE 2**   It should be creating a div with the class of "dealer" for each post under the header of the state. e.g: **STATE 1**   Post Title   Address   City, ST   800.555.1234   www.example.com   Post Title   Address   City, ST   800.555.1234   www.example.com   **STATE 2**   Post Title   Address   City, ST   800.555.1234   www.example.com   I'm using Advanced Custom Fields to call in the $street_address, etc. Here's the code I have right now. Thoughts?               <?php     $states = get_terms( 'states' );     ?>          <?php     foreach ( $states as $state ) {         $state_query = new WP_Query( array(              'post_type' => 'dealers',             'tax_query' => array(                  array(                     'taxonomy' => 'states',                     'field' => 'name',                     'terms' => $_GET['state'],                     'operator' => 'IN'                 )             )          ) );     ?>
<?php echo $state->name; ?>
         <?php         if ( $state_query->have_posts() ) : while ( $state_query->have_posts() ) : the_post();              $id = get_the_ID();             $street_address = get_field ('street_address', $id);             $dealer_city = get_field ('dealer_city');             $dealer_state = get_field ('dealer_state');             $phone_number = get_field ('phone_number');             $toll_free = get_field ('toll_free');             $dealer_website = get_field ('dealer_website');              ?>

<?php the_title(); ?>

<?php echo $street_address; ?>

<?php echo $dealer_city; ?>, <?php echo $dealer_state; ?>
                 <?php if ( get_field('phone_number') ) { ?>
<?php echo $phone_number; ?>
<?php } ?>
              <?php endwhile; endif; ?>          <?php      wp_reset_postdata(); ?>          <?php } ?>


Consuming an external API in WordPress?

I have a client who has a WordPress website, and he want to extend it to add new functionalities. These functionalities are included in a website I have already done (a kind of search engine over a database, with some filters), and which is under new enhancements. What I'm planning to do is to create a json api of my website (with all search funtion over my database), and make the wordpress website consuming this api, then I'll only have to create views to show search results. The problem is that I don't know WordPress at all (for me it is something where you can add articles via admin panel...) and I don't know how we can write our own server side code in it. I have searched on Google and found something called "plugin", but I'm wondering if it is possible to do so, and if it is the simplest way to do as I don't need to have the code used by any other third party. If it is possible to hack a WordPress install to add my PHP files, code what I need (my views with the same WordPress css) it would be simpler, but I don't know if it possible ?


modify all posts of a category to "no comments allowed"

I'm looking for a way to modify all posts of a certain category to be "no comments allowed" without going into each post settings, one by one, and modifying manually. Perhaps a MySQL statement? Thanks


Whole right area of wordpress admin dashboard not showing

Whole right area of Wordpress admin dashboard not showing... WP version is 2.7.1 What could be the reason? It was working before. ![alt text](http://i.stack.imgur.com/lKOZf.jpg)


Redirecting posts in Wordpress to a specific page

I created a page so that it would appear in my navigation menu. This page would however be my posts page (i.e. all posts would go here) and would also be my front page. I am unable to find anything other than editing the 'Home' in the theme file (none of the themes I tried had the 'Home' editable). In other words, I'm looking for something that would redirect all of my posts as a stream into my homepage that also has a link in the navigation menu. I tried looking at a lot of places for help in this, however I couldn't find anything useful. Thanks!


When does remove_filter not work?

There are reports that `remove_filter` does not work under some circumstances, and that we should provide alternatives. However, the article does not really make it clear under which circumstances this happens. I am looking for code examples that will break `remove_filter`, with WordPress and PHP version, and eventually other relevant info, provided. I think the following snippet should be a useable template:               <?php     include('wp-load.php');          function filtertest_function($value)     {         return 'Filtered';     }          var_dump(apply_filters('filtertest', 'Original value'));     add_filter('filtertest', 'filtertest_function');     var_dump(apply_filters('filtertest', 'Original value'));     remove_filter('filtertest', 'filtertest_function');     var_dump(apply_filters('filtertest', 'Original value'));      This will return the expected:               string(14) "Original value"     string(8) "Filtered"     string(14) "Original value"      I believe the error comes up in some cases where the filter is part of a class, or multiple filters are used. I understand `_wp_filter_build_unique_id` is involved. Please point out where in that code the source of the error is.


How to prepare images for a layout width change?

I maintain a site that will get a new layout, with a new width for the content area (currently 390px, say 500px for the new width). Many images (but not all) are sized to the current width (some are smaller, some are larger but should they should not be). How do I prepare the resize to the new width of 500px? Not all images are included as attachments (yet). I would like:   * All images that are 390px and have an original of 500px or larger, should resize to 500px   * An overview of all images that could not be resized because the original is not available or smaller than 500px   * An overview of all images that are larger than 500px, so I can decide on them myself   * All OEmbeds that are 390px should resize to 500px   * An overview of all "old-style embeds" (probably all Flash objects) so I can replace them by OEmbeds of the correct size.


unique identifier for the same pages in a multilanguage/site context

I've got always the same problem. If I program a multisite for multilanguage purposes, I cannot find a way to not change the page links in every language. I mean, suppose I've got a page named 'Activity' in the english version. Then got the Italian version, and the same page is called 'Attività'. If I've got a manually-setted link outside the menus, say:               get_page_by_title('Activity')      Then I've got to translate it in the IT theme:               get_page_by_title('Actività')      And so on for all the other languages. So, is there a way to avoid having to check for all links in every language? Thank you


How to do simple addition to increase favorites count of my wordpress posts

I have a code in my functions.php that gives me a count of how many favorites a post has got.               function wpfp_get_current_count() {     global $wpdb;     $current_post = get_the_ID();     $query = "SELECT post_id, meta_value, post_status FROM $wpdb->postmeta";     $query .= " LEFT JOIN $wpdb->posts ON post_id=$wpdb->posts.ID";     $query .= " WHERE post_status='publish' AND meta_key='wpfp_favorites' AND post_id = '".$current_post."'";     $results = $wpdb->get_results($query);     if ($results) {         foreach ($results as $o):             echo $o->meta_value;         endforeach;     }else {echo( '0' );}}      And I use the following code to achieve the count and it works just fine.               <?php echo 'TOTAL FAVORITES: ' .wpfp_get_current_count(); ?>      Now, I would like to add 300 favorites by default. So that if my actual favorites are 33 then the total favorites becomes 333. I guess i need a lesson on some basic php addition. If possible please suggest me a modified code. I tried the code below, but the addition does not happen. To be honest I asked this question earlier here on wordpress.org frorum but could not get a reply. Please help.


Show activities of defined BuddyPress groups

I want to show activity loop for certain groups only. If I use               <?php if ( bp_has_activities( array(bp_ajax_querystring( 'activity' ),'object' => 'groups','per_page'=>6 ,'primary_id' => $group_id, 'page' => isset($_REQUEST['page']) ? $_REQUEST['page'] : 1 ) ) ) : ?>      I can pass one group ID to filter results. The problem is that I have an array of groups IDs. I tried               <?php if ( bp_has_activities( array(bp_ajax_querystring( 'activity' ),'object' => 'groups','per_page'=>6 ,'in' => $groups_ids, 'page' => isset($_REQUEST['page']) ? $_REQUEST['page'] : 1 ) ) ) : ?>      But `'in' => $array` only takes an array of activities IDs. How to achieve this?


How can I combine meta_query queries?

I'm trying to build combined meta_query queries but they don't work. Any ideas how I can implement queries like the example below? Thanks, Hinnerk               Array     (         [relation] => AND         [0] => Array             (                 [key] => price                 [value] => 1000                 [type] => numeric                 [compare] => <=             )              [1] => Array             (                 [relation] => OR                 [0] => Array                     (                         [key] => roomcount                         [value] => 3                         [type] => numeric                         [compare] => >=                     )                      [1] => Array                     (                         [key] => bathroomcount                         [value] => 2                         [type] => numeric                         [compare] => >=                     )                  )          )


get custom post type by tag

Is it possible to retrieve post entry for a custom post type by tag, I have been trying with the following code, however it just locks me into a infinte loop.               <aside class="supporting_images">         <?php /*<?php if($post->ID == 241) : echo apply_filters('the_content', '[slideshow=3]'); endif;  ?>         <?php the_post_thumbnail(); ?>*/?>              <?php if($post->ID == 241) : ?>             <?php                 $query = new WP_Query();                 $query->query('tag=branding');             ?>             <?php while ($query->have_posts()) : ?>                 hello             <?php endwhile; ?>         <?php endif;?>


Displaying content of single post

How I can display content for a single post? My code:               if (is_single()){         get_header();         get_sidebar('left-article');         render_article();         get_footer();     }      In `render_article` I call `single_post_title()` to get title of post. However I don't know how to get time and contents of the post as I can't find any function like `single_post_content()` or `single_post_time()`.


Woocommerce tabs don't work properly

Hi all I know this question has been asked many times - I'm working on a custom theme but my WooCommerce products tabs are not working, ie. both panels are showing at the same time. It's a theme issue as everything works ok when I activate 2014 theme. I thought jquery was already bundled with WP 4.0 but I'm still doing the following:               function load_scripts() {        // Add font, used in the main stylesheet.     wp_enqueue_script( 'twentyfourteen-font', 'http://fonts.googleapis.com/css?family=Kaushan+Script', array('jquery'), null );          // Load jquery     wp_enqueue_script( 'jquery' );     // Load stylesheet     wp_enqueue_style( 'my-style', get_stylesheet_uri() );     }     add_action( 'wp_enqueue_scripts', 'load_scripts' );      Now I am aware of the noconflict wrappers requirement - Getting jquery to work with custom theme But as it's WooCommerce not working and not my own code I think I'm still initialising it the wrong way. What have I missed?


Stop Wordpress removing <script> tags when switching from HTML to Visual (TinyMCE)

Ok, I've seen solutions which go halfway to sorting out this problem, but nothing definitive, and nothing that 100% solves my problem. Scenario:   * In HTML mode, I add some javascript to a post I'm editing.   * I switch to Visual, then back to HTML, and the tag and all of its content are gone. How do I stop this from happening? I've tried adding custom code to my functions.php trying to access the extended_valid_elements for TinyMCE, but nothing works. Please help!


Creating a "CRUD" pluging for WP to create custom post types from a MS Access DB

I have a Microsoft Access database which contains data for my Wordpress site. I would like to run a CRUD (CREATE, READ, UPDATE, DELETE) application as a WP plugin, which imports data from the Access BD to "CRUD" WP Custom Post Types. If this a feasible project, what are the first steps for getting started? Please provide examples if available. Thanks


Return Custom Post Type Categories

I have setup a custom post type within Wordpress. For this I have also registered a new taxonomy and added various categories. I then have assigned these to the posts, all of which works, it shows within the post edit etc. How do I show these on the frontend? Whatever I try it does not work, its like wordpress doesn't know about them. Is there specific code to do this?


Php Mysql Terms

I have configured wordpress in local system. I came across these terms in Phpmysql database under wp_options. Can any one please tell me, what does it mean?               a:2:{s:12:"twentyeleven";s:7:"/themes";s:9:"twentyten";s:7:"/themes";}


What is the use of the wp_links table?

I'm wondering what is the use of the wp_links table, couldn't links have been implemented as a custom post type, if the menu system also uses custom post types?


How to check username/password without signing in the user

I'm writing a plugin that creates an API endpoint that validates username/password pairs. I'm currently using `wp_signon()` to check whether the username/password combo works. This works fine when the credentials fail because it returns an error object. But when the credentials are good, it automatcially signs in that user, so my endpoint returns a whole page. The codex currently doesn't even mention the fact that it automatically logs in the user. It also doesn't appear to accept a parameter to suppress that functionality. For my purposes I simple boolean would be fine. **UPDATE:** I had to choose one single answer, but there was a lot of useful info several of the other answers which I'll try to summarize briefly here...   1. There IS a function that does exactly what I was trying to do: `wp_authenticate($username, $password)` HOWEVER, it comes with one drawback. It will automatically set the login cookies which can create problems in a situation like mine. So be careful. This function is not currently in the codex.   2. The best choice for what I'm doing is `wp_authenticate_username_password($user, $username, $password)` because it DOESN'T set the login cookies. This function is more documented, but the REALLY important detail that wasn't in the codex is that you can pass `NULL` as the first parameter. This means you can effectively use it to do exactly like `wp_authenticate()` without worrying about the cookies getting screwed up. Read the documentation so you don't get confused by the response. It returns a either a WP_User object or a WP_Error (not a boolean!).


Wordpress register_siderbar get incremented value

I have register a sidebar where I need a variable to be incremented each time a widget is added to the sidebar. What I have done:                register_sidebar(array(         'name' => __('home-page-widget', 'carhire'),         'id' => 'home-page-widget',         'before_widget' => __('

%d'),          $i,         'after_widget' => '

',         'before_title' => '
',         'after_title' => '
',     ));      Where `$i` gives 0 all the time. I need it to be 1 for first widget, 2 for second, 3 for third. and so on.


How do I create an alphabetically organized glossary of links?

Here is the kind of archive page I am trying to reproduce for my client: http://www.catwalkyourself.com/page/ready_to_wear/autumn_winter12-13/rtw12_13.php As you can see, it is a list of alphabetically organized lists. How would I go about creating this in Wordpress?


is_admin() returns true when using admin-ajax.php from front end script

Had a situation today where I was using admin-ajax.php from a front end script. As I understand it this the wp way to make ajax calls (registering my function with the wp_ajax_nopriv_myfunction hook) Seems to me that since admin-ajax.php is on the admin side is_admin() returns true whereas my script calls it from the front end side. This causes an issue with a plugin I use that does things differently on front and admin side of things. So I was wondering if I was doing something wrong is there a way to use ajax in front end the wp way and have is_admin() to return false ? hope I could make myself understand


get_the_category listing in hierarchial order

Hello at the moment I'm wondering how I would be able to make this work to post in Hierarchical order within the post loop.               <?php          foreach ((get_the_category()) as $childcat)          {              if (cat_is_ancestor_of('42', $childcat))              {                  echo '
 cat_ID).'">'; echo $childcat->cat_name . '
';              }         }     ?>      I would like it to output as such:   * Parent      * Child     * Child        * Grandchild


Page not found (404 Error) even if the page exists?

So I created a page called test.mydomain.com/hello and when I try to access it, it gives me a 404 error. I tried switching my permalink structure to default and back to post name to see if this was the error, but it's not. In the page editor, I can see that it's the good permalink and when I click on view page, it still gives me a 404 error. Also my htacess is just the default htaccess:               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>     # END WordPresss      Any ideas arre greatly appreciated!!


Foreach Columns & Pagination

I am using the plugin "Categories Images" and using a foreach statement that I am trying to adapt for display of 11 items in three rows for a yearly magazine archive. The 11 items are custom category images (each issue's image cover with name and description). Each page of 11 items represents one year in the archive. I want to paginate backward and forward to brows each page/year. The items would display as such:               ABCD     EFGH     IJK      Here is the foreach code on its own:                   foreach (get_terms('magarchive') as $cat) : ?>         <a href="<?php echo get_term_link($cat->slug, 'magarchive'); ?>"><?php echo $cat->name; ?>
 -
         <a href="<?php echo get_term_link($cat->slug, 'magarchive'); ?>"><?php echo $cat->description; ?>

         <a href="<?php echo get_term_link($cat->slug, 'magarchive'); ?>"><img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" />         <?php endforeach; ?>      I've tried applying tables, css, arrays, etc. But I can only get the items to display in a single vertical column. I am just not skilled enough at this point with stylizing the echo of foreach's output. Any help would be greatly appreciated. Thank you...


wp_footer hook only working on homepage not in other pages

I try to output a javascript code in `wp_footer` hook but it is not printed in all pages it is working in home page only. I have checked for the presence of `wp_footer();` function in `footer.php` it is present but still i couldn't get this work. I have deactivated all plugins. I have tried it with default themes like `twenty_thirteen` Whatever i have checked is the problem arising area but it looks there is no problem from those, looks very strange. But this happens only in live site not in localhost. Is there some other place to check for the problem? What might be the problem? Why it is not printing in any other pages except the homepage? Here is the sample code               function test(){     ?>     <script>     console.log("testing");     </script>     <?php     }          add_action('wp_footer','test');      One more note `wp_head` hook also performing the same way as it prints only on homepage not in any other pages.


Custom post types permalinks not working

Am I declaring my custom post types incorrectly? My permalinks are only working intermittently on my site. I believe I have my server set up correctly; I have a few Drupal installs up along with my Wordpress install and their clean urls / htaccess rules are working fine. I've also tried disabling all plugins but that had no effect. What could I be missing? Thanks in advance.               function five_oh_one_customizations_custom_post_types(){     $homepage_args = array(         'public' => true,         'supports' => array(             'title', 'editor', 'thumbnail', 'custom_fields', 'revisions'         ),         'labels' => array(             'name' => 'Homepages',             'singular_name' => 'Homepage',             'add_new' => 'Add new Homepage',             'add_new_item' => 'Add new Homepage',             'edit_item' => 'Edit Homepage',             'new_item' => 'New Homepage',             'view_item' => 'View Homepage',             'not_found' => 'No Homempages found',             'not_found_in_trash' => 'No Homepagess found in trash'         ),         'hiearchial' => false,         'rewrite' => array(             'with_front' => false,             'slug' => '/',             'feeds' => false,             'pages' => false         ),         'has_archive' => false,         'query_var' => 'homepage',         'show_in_nav_menus' => false,         'menu_position' => 2);          $grantee_args = array(         'public' => true,         'supports' => array(             'title', 'editor', 'thumbnail', 'custom_fields', 'revisions'         ),         'labels' => array(             'name' => 'Grantees',             'singular_name' => 'Grantee',             'add_new' => 'Add new Grantee',             'add_new_item' => 'Add new Grantee',             'edit_item' => 'Edit Grantee',             'new_item' => 'New Grantee',             'view_item' => 'View Grantee',             'search_item' => 'Search Grantees',             'not_found' => 'No Grantees found',             'not_found_in_trash' => 'No Grantees found in trash'         ),         'capability_type' => 'post',         'hiearchial' => false,         'rewrite' => array(             'slug' => 'grantee',         ),         'has_archive' => true,         'show_in_nav_menus' => false,         'query_var' => 'grantee',         'menu_position' => 3     );          $grantee_project_args = array(         'public' => true,         'supports' => array(             'title', 'editor', 'thumbnail', 'custom_fields', 'revisions'         ),         'labels' => array(             'name' => 'Grantee Projects',             'singular_name' => 'Grantee Project',             'add_new' => 'Add new Grantee Project',             'add_new_item' => 'Add new Grantee Project',             'edit_item' => 'Edit Grantee Project',             'new_item' => 'New Grantee Project',             'view_item' => 'View Grantee Project',             'search_item' => 'Search Grantee Projects',             'not_found' => 'No Grantee Projects found',             'not_found_in_trash' => 'No Grantee Projects found in trash'         ),         'capability_type' => 'post',         'hiearchial' => false,         'rewrite' => array(             'slug' => 'grantee-project'         ),         'has_archive' => true,         'show_in_nav_menus' => false,         'query_var' => 'grantee_project',         'menu_position' => 4     );          //create custom content types - we'll add the custom fields manually in the ui with the Advanced Custom Fields plugin     //http://www.advancedcustomfields.com/docs/getting-started/      register_post_type('homepage', $homepage_args);     register_post_type('grantee', $grantee_args);     register_post_type('grantee_project', $grantee_project_args);          //create custom taxonomy for grantee project content type        $taxonomy_args = array(         'public' => true,         'show_ui' => true,         'hierarchical' => true,         'query_var' => 'grantee_project_taxonomy',         'rewrite' => false,         'show_tagcloud' => false,         'show_in_nav_menus' => false,         'capabilities' => array(             'manage_terms' => 'do_not_alllow',             'edit_terms' => 'do_not_allow',             'delete_terms' => 'do_not_allow',             'assign_terms' => 'edit_posts'         ),         'labels' => array(             'name' => 'Investment Categories',             'singular_name' => 'Investment Category',             'all_items' => 'All Categories',             'parent_item' => 'Parent Category',         )     );          register_taxonomy('grantee_project_categories', array('grantee_project'), $taxonomy_args);     }


Link from Thumbnail to Post not working

i am trying to link my posts thumbnail to the post that it is pulling, however its not coming through as a link :S               <?php         $carouselPosts = new WP_Query();         $carouselPosts->query('showposts=3');         ?>         <?php while ($carouselPosts->have_posts()) : $carouselPosts->the_post(); ?>         <a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail(array(70,70)); ?>

<?php the_excerpt(); ?>

         <?php endwhile; ?>      I put the wrap round the actual div, is this the correct way to do this? thanks


Sticky post appears twice

I am trying to modify the number of posts_per_page in the loop. This way:               function posts_per_page($query) {         $query->query_vars['posts_per_page'] = 3;     }     add_filter('pre_get_posts', 'posts_per_page', 11);      The problem I have is that when I do so, then sticky posts appear twice in the loop: first one at the begining of the loop and second one in their original position. So in this case, the first page has 4 posts (3 of loop without sticky + the sticky post), and the sticky post will appear (again) later in its "page" with other 2 posts. **EDIT: SOLUTION** After doing quite much research I realised sticky posts appear always in the first page. If the original sticky post was already in the first page then only the sticky appears (this post only will appear one). I needed to know exacty how many posts will my query have, but $wp_query->found_posts was not counting the sticky posts. And if I did $wp_query->found_posts + get_option( 'sticky_posts' ) wouldnt be correct as it doesnt consider the 'sticky post from first page' I said before and also counts non-published sticky posts. With $wp_query->posts I get the real number of posts in my first page, so:               $sticky = count($wp_query->posts) - get_option( 'posts_per_page' );          if ($sticky<0) {$sticky=0;}//In case there is only one page of results      Now $sticky will have the real number of sticky posts.


Customize user account activation message

During the process of a user creating a new account, once they click on the link in the activation email, they receive the message on the login page: > Your account is now active! > > Username: ****** > > Password: ****** > > Your account is now activated. View your site or Login I need to customize this message. This content seems to be produced by `wp- activate.php`, but I don't see any hooks, such as `wpmu_signup_user_notification` found in `ms-functions.php`. I'm using WordPress 3.8 multisite (subdomain).


How to Import Users via command line script into sub sites on a Multisite Network

Does anybody know how best to import users via command line or via php script into sub sites on a Multisite Network and/or know how best to go about extending a plugin that does import users into sub sites? Example: Cimy User Manager - e.g., with an api or other code that runs the plugin at command line. FYI, Cimy User Manager seems to do a great job of loading a list of users via `csv` file into a sub site but this requires the GUI and a number of admin clicks ... this got me thinking if it was possible to run a plugin at command line so initially i posted this thread -> http://wordpress.org/support/topic/api-or-method-to-import-users-from-command- line ... Any help or pointers that can be shared to add users via command line scripts is greatly appreciated.


can not access wp-admin after migrating to openshift

I recently migrated to Redhat's Openshift PaaS. My site is little bit slow in loading but working fine but Now I am unable to access wp-admin. `mysite/wp-admin` is redirecting to `mysite/wp- admin/upgrade.php?_wp_http_referer=%2Fwp-admin%2F` which says "webpage is not available. What may be the possible reason behind it and how to resolve the problem?


WordPress and Localization

I know that WordPress supports multiple languages - You can read more details here http://codex.wordpress.org/WordPress_in_Your_Language My question is, what is the difference in a localized version over the standard english versoin? Does it only contain extra language files? What should I look for? Thanks.


get posts with hierarchy and all post meta

I created a custom post type to act as a Family Tree. There are currently 40+ post-meta fields that collect all of the important information. Wordpress's built in "parent" function is used to assign children appropriately and create the tree. I needed to loop through all of the posts, get all of the necessary data via get_post_custom, and then display hierarchically, similar to the end display of wp_list_pages. However, I needed good access to the html output of each post. I originally used a recursive function, that called get_posts and looped for each level of children. Inside each post loop, I would grab the meta. It worked beautifully when I had 30 posts. I have 150 now, and it is slow, of course. I'm making hundreds of database calls. Since I need to fix this, the next idea I have is to implement something like this:               $children = get_posts($args); // get all posts in cpt          foreach($children as $childkey => $child) {         $post_meta = get_post_custom($child->ID); // get post meta for each post         $children[$childkey]->meta = array();                    foreach($post_meta as $key => $meta) {                 if(isset($key) && !empty($key)) { ${$key} = trim($meta[0]); } else ${$key} = "";                 $children[$childkey]->meta[$key] = ${$key}; // append post meta                }         }             I then will need to sort through this array one last time and arrange it to be hierarchial with children beneath their parents. ( I may do this first if it's significantly faster to do with fewer values in array..) My question is -> Is this the right way to go about doing this? Is there a built in function I've missed? Is there something I can do to ensure that you can have hundreds of posts without causing that much time to query? ( does this question belong here or at stack overflow? )


How can I display other user avatars on an author profile page?

I have an author profile page where I'm displaying a user avatar and information about the author. On this same page, I'm also trying to include posts by other authors with their avatar displayed next to their post title. The problem I'm having is that get_avatar(get_the_author_meta('ID')) is only displaying the avatar of the current profile page author and not the author of the posts within the loop. So instead of the different author avatars, I have the avatar of the current author page repeated over and over. Here is my code:               $args = array(         'cat' => '55',         'posts_per_page' => '3'     );          $Voices = new WP_Query($args);         if ($Voices->have_posts() ) {             while ($Voices->have_posts() ) {                 $Voices->the_post();                 echo get_avatar(get_the_author_meta('ID'), 150);                 echo '' . the_title() . '';                   coauthors_posts_links();             }         }          wp_reset_postdata();


Error on using __FILE__ for add_menu_page() Function

I am trying to creat an custom option page but I ham getting error on setting the add menu page() function. I need to use the **FILE** as the $menu_slug 4th parameter of the function                 add_menu_page('Item Display','Item Display','administrator', '__FILE__', function(){  });      but I am getting this error: **You do not have sufficient permissions to access this page.** ![enter image description here](http://i.stack.imgur.com/XK7Up.png)


category doesn't showing up in admin

After WordPress update certain of my categories doesn't showing up in admin,but it's ok in the DB, and it display in the parent dropdown, ![enter image description here](http://i.stack.imgur.com/Mfu3t.png) how i can fix this please


Wordpress Update Question

I have one simple question I need update every new update of wordpress script and plugins or i don't need update i ask because every this update can finish with some error ? Thanks.


What query to append the 10 next posts?

I am loading more posts with ajax when clicking on a button. There is 4 posts when you arrive on the page and everytime you click on the button, it needs to load 4 more. What query would I need to use? On my ajax.php, this is what my custom query looks like:               $queryLoadPosts = new WP_Query(array(             'post_type' => 'track',             'posts_per_page' => 4         ));      I also tried 'page_id' => 2, but it did not work. I also though about doing a loop and incrementing a variable and only start echoing the posts when ex: $i >3, but that would be the worst code...


Counting posts by certain author with custom taxonomy

I'm using this code to display the last three posts of a custom taxonomy ('special') by a certain author:               <?php query_posts( array( 'taxo' => 'special', 'showposts' => 3, 'author' => 2 ) ); ?>          <?php if(have_posts()) : while(have_posts()) : the_post(); ?>          <a href="<?php the_permalink(); ?>"><?php the_title(); ?>          <?php endwhile; endif; ?>
      Now I want WordPress to count also the total amount of posts this user made with this taxonomy and display the number, anyone knows how this would work? Thanks in advance.


Widgets not activated alert after using get_sidebar()

I stumbled upon avery strange problem while creating a sidebar for my wordpress theme using the **get_sidebar()** function in **header.php**. I inserted the following code in **function.php** :               function myfunc_sidebars_init() {         register_sidebar(array(             'name' => __('Main Sidebar', 'mytheme'),             'description' => __('Widget area for the main sidebar.', 'mytheme'),             'id' => 'sidebar-main',             'before_widget' => '
',             'after_widget' => '
',             'before_title' => '
',             'after_title' => '
',             ));         }     }     add_action( 'widgets_init', 'myfunc_sidebars_init' );      My **sideber.php** looks like this:
          <?php if ( is_active_sidebar( 'sidebar1' ) ) : ?>              <?php dynamic_sidebar( 'sidebar1' ); ?>          <?php else : ?>

<?php _e("Please activate some Widgets","mytheme"); ?>.

          <?php endif; ?>
      I also selected the sidebar in **Appearance->Menus** in the admin panel and all default widgets are added to the sidebar in **Appearance->Widgets** (Search, Recent Posts, Recent Comments, etc.). However after loading the theme there is an alert in the sidebar menu saying _"Please activate some Widgets"_. Why is that and how can I fix it?


Multisite wordpress and subdomain URL collisions

I have a multisite WordPress installed on a server using a domain, **site.com** and I have a subdomain setup in WordPress, so subsites are at **sub1.site.com** , **sub2.site.com** etc. In addition to this, the main site has other services in subfolders that are not related to WordPress, such as `site.com/something`. Everything is working fine, except that when a customer on a subsite uses permalinks by post name, and uses the same title as one of the main site's subfolders, it goes to the main site's subfolder; for example `sub1.site.com/something` goes to the same place as `site.com/something`. Is there anything I can do _(by editing`.htaccess` or `httpd.conf`_? Or should I just move WordPress to it's on subfolder in main site (`site.com/wordpress`) to prevent these URL collisions?


Title after content dynamic_sidebar

Is there a configuration to change the `dynamic_sidebar` widget's title order? I want to display title after the content. I used JavaScript to swap it at page load and looking for a robust -- tangible -- solution.


Get Value of Custom Field

I use a dropdownbox to show all custom types ('abschreibungstabelle'). It works fine. But now, I want to show the value of the custom field 'nutzungsdauer' in my input-field. Any ideas?                 <input type="text" class="text-input" placeholder="Nutzungsdauer" value="" name="nutzungsdauer" id="nd">      function.php                function afa_type_dropdown( $post_type )     {     $posts = get_posts(         array(             'post_type'  => $post_type,             'numberposts' => -1         )     );     if( ! $posts ) return;          $out = '<select id="afa_select"><option>Anlagegut auswählen</option>';     foreach( $posts as $p )     {         $out .= '<option value="' . get_permalink( $p ) . '">' . esc_html( $p->post_title ) . '</option>';        }     $out .= '</select>';     return $out;     }


REQUIRED: Could not find wp_link_pages. See: wp_link_pages by Theme Checker

I have run my theme through WordPress theme checker to see if it can be submitted to WordPress.org. I encountered this error: > REQUIRED: Could not find wp_link_pages. See: wp_link_pages But this is not true. I am using a custom function `wp_my_own_link_pages()` which is a replacement for `wp_link_pages()`. It generates pagination with a compatible HTML structure for the theme. Did I miss something required? How can I make this work?


How WP_Customize_Background_Image_Control is supposed to work?

I'm trying to add a second background image function to my theme customizer with this code.                   // HTML Background Image     $wp_customize->add_setting(         'html_background_image',          array(             'capability'     => 'edit_theme_options',     ));          $wp_customize->add_control(          new WP_Customize_Background_Image_Control(             $wp_customize,             'background_image',              array(                 'label'    => __('HTML Background Image', 'TEXTDOMAIN'),                 'section'  => 'background_image',                 'settings' => 'html_background_image',     )));      But it doesn't work. Am I missing something here?


Rotate images in header based on date

I am new to WordPress and I would appreciate some cool advice here. I have changed the `header.php` file in the Editor to include an image. I wonder if it is possible to automatically display one of 9 possible images depending on the date (ie. rotate them)


changing Wordpress login page

I'm trying to change the default Wordpress login/signup page by doing this: Adding this code anywhere in function.php file of my theme:               function custom_login_css() {     echo '<link rel="stylesheet" type="text/css" href="'.get_stylesheet_directory_uri().'/login/login-styles.css" />';     }     add_action('login_head', 'custom_login_css');      Creating a /login directory in my theme's folder and put login-styles.css in it and save it.                .login form {       margin-left:auto;       margin-right:auto;       padding:30px;       border: 1px solid rgba(0,0,0,.2);       background-clip: padding-box;       background: rgba(255, 255, 255, 0.9);       box-shadow: 0 0 13px 3px rgba(0,0,0,.5);       overflow: hidden;       }      When I try to load http://www.mscaspian.com/store/wp-login.php I get: `<link rel="stylesheet" type="text/css" href="http://www.mscaspian.com/store/wp- content/themes/blaszok/login/login- styles.css" />` above the page instead of applying to the page.


Migrated site redirects to localhost after successful login

I have copied a site to a non-public demo server to make some edits. I transferred the files and the database (having disabled permalinks beforehand), updated `wp-config.php` with the new database info, and ran a PHP script to replace the old URL with the new one in the database. The index page loads fine (except for a few missing photos) but every single link results in a DNS error and a successful login redirects to a non-existent localhost folder. I'm not sure what version of WordPress/plugins/themes as I cannot login. My site can be found at http://iamshawnrice.com/demo/casestudies/ Any ideas are greatly appreciated.


datetime picker, timestamps and meta queries

I have a custom meta box with a datepicker. The datepicker outputs 2013-01-17 10:00 in my database for an event that is 01-17-2013 at 10pm PST.               $eventlist = new WP_Query(array(         'post_type' => 'events',         'posts_per_page' => 5,         'order' => 'asc',         'orderby' => 'meta_value',         'meta_key' => 'datetime',         'meta_query' => array(             array(                 'key' => 'datetime', // Check the start date field                 'value' => date("Y-m-d H:i:s"),                   'compare' => '>=',                  'type' => 'DATETIME'              )         ),     ));      The issue is, at 4pm PST the event disappears, leading me to believe somewhere it is thinking its UTC and making the post go bye bye. Where would i Find this issue and how can i solve it?


Can't see why my scripts aren't loading when I register and enqueue them

I'm trying to replace "hardcoded" calls in my header.php by registering and enqueueing them in functions.php. JQuery 1.8.3 loads as desired, but the other scripts don't. Here's what I'm using:               function puckpros_load_my_scripts() {           wp_deregister_script( 'jquery' );           wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js');           wp_enqueue_script('jquery');           wp_register_script('menu', get_stylesheet_directory_uri().'/js/menu.js', array('jquery') );           wp_enqueue_script('menu');         wp_register_script('kwicks', get_stylesheet_directory_uri().'/js/jquery.kwicks.js', array('jquery') );           wp_enqueue_script('kwicks');         wp_register_script('equalheights', get_stylesheet_directory_uri().'/js/jquery.equalheights.js', array('jquery') );           wp_enqueue_script('equalheights');     }            add_action('wp_enqueue_scripts', 'puckpros_load_my_scripts');       It's a child theme, so I'm using get_stylesheet_directory_uri() and the paths to the files are correct. I'm sure it's something simple, but I can't see what I'm doing wrong. Thanks. **EDIT** As suggested below by Chip, I changed my functions.php to eliminate the call to jquery and remove the register calls. I now have:               function puckpros_load_my_scripts() {                 wp_enqueue_script('kwicks', get_stylesheet_directory_uri().'/js/jquery.kwicks.js', array('jquery') );               wp_enqueue_script('equalheights', get_stylesheet_directory_uri().'/js/jquery.equalheights.js', array('jquery') );               wp_enqueue_script('wslaunch', get_stylesheet_directory_uri().'/js/wsLaunch.js', array('jquery') );     }            add_action('wp_enqueue_scripts', 'puckpros_load_my_scripts');       But my script equalheights won't execute, tho it does if I load in directly in the header like this:               <script type="text/javascript" src="<?php bloginfo('stylesheet_directory');?>/js/jquery.kwicks.js"></script>     <script type="text/javascript" src="<?php bloginfo('stylesheet_directory');?>/js/jquery.equalheights.js"></script>     <script type="text/javascript" src="<?php bloginfo('stylesheet_directory');?>/js/wsLaunch.js"></script>      Now I'm stumped again. I'd like to "do it right" and enqueue, but I can't get it to work. Thanks for any help.


Error establishing a database connection error on a site that was working fine previously

A site that was working fine previously is now getting an error,               Error establishing a database connection      I have dealt with this error while creating new wordpress sites(when there was something wrong with the `config` file). This time, the error occurred when the user upload a file to `public_html` folder. Can anyone suggest me **what would have gone wrong** and **how to fix it**? Thanks in advance.


Help need making decision. Ads rotating site on wordpress

Okey guys, I am little confused here. I am building a ads rotating site (specifically for jpgs/gif banners) for my client where people can add banners and create code to put in there site. **My Plan So Far:**   1. Individual Ads will be a custom post type.   2. Each ads will have a specific banner size.   3. Ads Group: A group of ads where couple of same size ads can be added. The rotating code will be associated with the group not a single ads. So you see the **Ads Group** will be something that will contain the post id of the ads that associated in that group. Also i need to validate the banner size of the group (two different banner size can't be in a same group). **Now what I am confused about is** should i use custom post type for groups too? or i should use only taxonomy? Custom post type looks too bigger for the purpose because I only need to save the Group Ads size (125x125, 468x60 etc) and the post ids in a group item. And when i think of using taxonomy it is easy to use store the post ids (wordpress will handle that!) but how come I save the Group ads size? Is it possible to add meta values for taxonomy items? I hope you get my whole idea? Let me know if you are not clear.


query_posts not working after wordpress 3.7 update

I recently updated to wordpress 3.7 and all of a sudden my posts page stopped working . it shows nothing and opens up a blank page . there is small code on that page and it stopped working . It was using `query_posts` to get the posts but now a bank page shows up . the code                   <? query_posts ('cat=-103&posts_per_page=1') ?>           <? while (have_posts ()) { the_post ();  ?>

<a href="<? the_permalink() ?>"><? the_title (); ?> &nbsp <?= get_post_meta (get_the_ID(), 'sub-title', true); ?>

                      <? //the_content ('[More]'); ?>
<a href="<? the_permalink() ?>"><img src="<?= get_post_meta (get_the_ID(), 'image', true); ?>"/>

<a href="<? the_permalink() ?>"><img src="<?= get_post_meta (get_the_ID(), 'image2', true); ?>"/>

<a href="<? the_permalink() ?>"><img src="<?= get_post_meta (get_the_ID(), 'image3', true); ?>"/>

          <?php }  ?>


Settings API - how to update multiple options manually?

I'm storing all my options using Settings API:               function registerSettings() {          register_setting('XX_theme_settings', 'XX_theme_settings', 'setting_validate' );          add_settings_section('theme_options', 'Theme Options', 'theme_options_generate', 'page1' );      add_settings_field( 'XX_Option1', 'Option 1', 'text_input', 'page1', 'theme_options', 'XX_Option1' );     add_settings_field( 'XX_Option2', 'Option 2', 'text_input', 'page1', 'theme_options', 'XX_Option2' );           };          add_action('admin_init', 'registerSettings');      Let's say I want to update all the options manually (not using forms, but via PHP), how should I do that? That's how this update looks like for one setting:               $my_options= get_option('XX_theme_settings');//retrieve all options     $my_options['XX_Option2'] = 'my new value'; //amend value in array(s)     update_option('XX_theme_settings', $my_options); //update option array      I have absolutely no idea how to make it work for multiple (originally I have over 50) setting fields. I've been trying this way:               $current_options = get_option('XX_theme_settings');     $imported_options = array_merge($current_options , array_intersect_key($_POST["import"], $current_options ));     // $imported_options = $_POST["import"]; - simplified     update_option('XX_theme_settings', $imported_options);      And it does not work, of course "import" is not a string but an array. Here's a related (my own) question: Settings API - how to update options manually? I guess I still do need to create a PHP foreach loop and loop through all the settings, then list them, ten add every single one via update_option? How to? Would it be slow, because it sounds like it? **UPDATE** This code doesn't seem to update the settings:               $current_options = get_option( 'XX_theme_settings', array() );     $desired_options = array("existing_field" => "new value");     // $desired_options = array("XX_theme_settings" => array("existing_field" => "new value")); tried this one, but also no luck     $merged_options = wp_parse_args( $current_options, $desired_options );     update_option( 'XX_theme_settings', $merged_options );      **UPDATE II** This is even stranger. I put the above code at page.php (just for testing reasons):                   $current_options = get_option( 'XX_theme_settings', array() );         $desired_options = array("existing_field" => "new value");         $merged_options = wp_parse_args( $current_options, $desired_options );         update_option( 'XX_theme_settings', $merged_options );      I refresh one of the pages. Nothing happens. Then I change the code to this:                   $current_options = get_option( 'XX_theme_settings', array() );         $desired_options = array("existing_field" => "new value");         $merged_options[] = wp_parse_args( $current_options, $desired_options ); //here's the change         update_option( 'XX_theme_settings', $merged_options );      Another refresh, "existing_field" is now emtpy. Then I once again paste the first code and refresh for the third time and it works. Hint: maybe I should remove fields value before updating them?


Can't pull posts of a Custom Post Type based on the custom taxonomy of the CPT

My question is about retrieving custom post types via get_posts, when custom post types also have a custom taxonomy. I can use get_posts to retrieve all posts of a custom post type, but when I attempt to filter posts by category, I get no results. Therefore, I think that there is either something wrong with 1) the way I am registering the custom taxonomy for the custom post type, or 2) that I have categories and taxonomy confused, or both. To retrieve random posts of the custom post type "books" my code looks like this:               $posts = get_posts(array(         'numberposts' => -1,         'orderby' => 'rand',         'post_type' => 'books'     ));          if($posts)       {          foreach($posts as $post)         {         // output various things          }            }      However if in the list of parameters I add               'category' => 3,      ... nothing shows up. And I know there are "books" with a tag or category of 3 assigned to them and that the tag_id = 3. When I hover over the term in the custom taxonomy area I get this as its link: http://ourwebsite.ca/wp-admin/edit- tags.php?action=edit&taxonomy=books_taxonomy&tag_ID=3&post_type=books This seems to me like it should work perfectly unless categories and custom post taxonomy are two different things. But, if they are, I don't know how to pull custom posts based on taxonomy. Here is how I've registered the custom taxonomy for "books"               function books_taxonomy() {        register_taxonomy(         'books_taxonomy',         'books',         array(             'hierarchical' => true,             'label' => 'Books Set',             'query_var' => true,             'rewrite' => array('slug' => 'books')             )         );     }      Is anyone able to advise me on filtering a listing of "books" by a taxonomy term? Thanks so much in advance!


How to save an array with one metakey in postmeta?

I have an array saved in postmata, each array key become a metakey. I want to change the code to save the whole array with one metakey. How to do that? Thanks!               $poddata = Array(     'pod_id' => $this->pod_id,     'url' => $this->url,     'name' => $this->name,     'description' => $this->description,     'service' => $this->service,     'status' =>$this->status,     'price' => $this->price     );          foreach ( $poddata as $k => $v ){          if ( get_post_meta( $this->id, $k ) == '' )     add_post_meta( $this->id, $meta_box, $v, true );          elseif ( $v != get_post_meta( $this->id, $k, true ) )     update_post_meta( $this->id, $k, $v );          elseif ( $v == '' )     delete_post_meta( $this->id, $k, get_post_meta( $this->id, $k, true ) );          }


Enable automatic plugin update for certain plugins

It seems there's only a global option where users can enable it. Is there a way to bypass this for only a certain plugin? So I can move this to either to my plugin options or enable it by default (only for my plugin of course)


wpdb->insert not inserting first variable

I have a strange error here. im trying to write to the wordpress db but `$wpdb->insert` does not write the variable first name. Can any one spot the error in this code?               function pay_record_register( $first_name = "NA",                                  $last_name = "NA",                                  $payer_email = "NA",                                  $item_name = "NA",                                  $gross = "NA",                                  $currency = "NA",                                  $payment_status = "NA",                                  $payment_date = "NA",                                  $address_street = "NA",                                  $address_zip = "NA",                                  $address_city = "NA",                                  $address_country = "NA",                                  $address_status = "NA"  ) {          global $wpdb;          $table_name = $wpdb->prefix . 'pay_record';          $wpdb->insert($table_name, array( 'last_name' => $last_name,                                          'first_name' => $first_name,                                         'payer_email' => $payer_email,                                          'item_name' => $item_name,                                          'gross' => $gross,                                          'currency' => $currency,                                          'payment_status' => $payment_status,                                          'payment_date' => $payment_date,                                          'address_street' => $address_street,                                          'address_zip' => $address_zip,                                          'address_city' => $address_city,                                          'address_country' => $address_country,                                          'address_status' => $address_status                                     ));      } In my DB every variable is printed with the default (i dident send any values) except first_name. first_name is left empty... Here is a picture of my table structure: ![enter image description here](http://i.stack.imgur.com/sYq2R.png) I'm great full for any tips, tricks or answers :)


Where to find the code that redirects requests on the static page URL to the home page

As an example, let's say I set my "About Us" page (slug: about-us) as my home page static page. Upon doing this, when someone requests mysite.com/about-us, WordPress does a nice redirect to the home page so that I don't end up with duplicate content of having two pages pointing to the same content. I'm trying to find where in the core code that this redirect code appears, because I'm trying to emulate the same behavior when using a sticky post as the home page.


Show latest custom post types on dashboard

I am using this code which shows latest posts on my dashboard but it doesn't work for custom post types. Would appreciate how to modify code.               function wps_recent_posts_dw() {     ?>
          <?php               global $post;               $args = array( 'numberposts' => 5 );               $myposts = get_posts( $args );                     foreach( $myposts as $post ) :  setup_postdata($post); ?>
 (<? the_date('Y / n / d'); ?>) <a href="<?php the_permalink(); ?>"><?php the_title(); ?>
               <?php endforeach; ?>
     <?php     }     function add_wps_recent_posts_dw() {            wp_add_dashboard_widget( 'wps_recent_posts_dw', __( 'Recent Posts' ), 'wps_recent_posts_dw' );     }     add_action('wp_dashboard_setup', 'add_wps_recent_posts_dw' );      In terms of database performance is this function going to be a strain or I shouldn't worry that much?


Shortcode return is printing a 1 afterward

function build_total_search_method( $atts ) {              $shorcode_php_function = include( dirname(__FILE__) . "/includes/total_search.php" );              return $shorcode_php_function;          }     add_shortcode( 'total_search', 'build_total_search_method' );      I've created a shortcode that returns an included PHP file instead of a string ... however, after the returned statement, there is a `1` printed. Two questions:               1) What is the `1` all about and how do I remove it?          2) Am I doing this properly?


Ajax load more button in Recent posts widget

I create Recent posts widget and i trying to create load more button for it to get more Recent posts links by ajax ,is there any tutorial for how to make it?


Change the link of 'Howdy' at the top right

I'd like to change where the 'Howdy' link gets you when you click on it. I have a website with buddypress and instead of getting users to their profile page I want to get them to their 'Activity' tab. How can I change the link? Thanks, Kat


Prevent redirect on custom wordpress login form

I'm having a little trouble with a custom login form that I've created.               <?php if (!(current_user_can('level_0'))){ ?>
         <form action="<?php echo get_option('home'); ?>/wp-login.php" method="post" target="_blank">
             Username         <input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="20" />

             Password             <input type="password" name="pwd" id="pwd" size="20" />
             <input type="submit" name="submit" value="Login" class="button" />
             <input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> Remember me             <input type="hidden" name="redirect_to" value="<?php bloginfo('url');?>/login-tournament/tournaments/"/>
         </form>

<a href="<?php echo get_option('home'); ?>/wp-login.php?    action=lostpassword">Recover password

<a href="<?php bloginfo('url'); ?>/register">Not registered yet?
     <?php } else { ?>
You're already logged in.
Click here to view the Tournaments page or you can <a href="<?php echo wp_logout_url( get_permalink() ); ?>" title="Logout"> Logout
     <?php }?>      A successful login will redirect the user to a custom URL and open the custom url in a new window. (this is working fine) The problem I have is that if the user enters the incorrect credentials, they are redirected to the default `wp-login.php` form. I need the user to stay on the current page and display an error message. I did find this snippet to prevent the redirect and it does work but it opens up the same page in a new window. Is it possible to prevent the new window opening when the incorrect details are entered. (I still need the new window to open on successful logins) Further to this, if no login details are entered at all when the login button is clicked, it will also send the user to the default `wp-login.php` page. Is it possible to prevent this also?


Multiple Values stored as array in Meta Query

I'm a little confused as to best practise for saving multi-select values in meta fields. Assuming               <select multiple name="_casestudypost[]">      is my form field if I store $_POST['_casestudypost'] in a meta_key of the same name? (which returns an array) - how can I find out when 281 is in that array. I've tried:               $args = array(                 'meta_query'=> array(                     array(                         'key'=>'_casestudypost',                         'value'=>  281,                         'compare' => 'IN',                         'type' => 'NUMERIC'                     )                 ),                 'post_type'=>'case_studies',                 'post_status' => 'publish'             );      However the generated SQL that Wordpress generates under the hood seems to ask, is meta_value (13,281,45) in 281, rather than is 281 in meta_value (13,281,45).


Sliding-Doors Child Theme

I'm trying to make a child theme for Sliding-Doors, a Wordpress site. I'm following all the right steps but the child theme is not showing up on my admin panel to activate it. Is it because I am using an index.html to show a "coming soon" page while I am still building the WP site? If you type http://www.examplesite.com, you'd get the "coming soon" page. If you type http://examplesite.myname.com/php, you'd see the Sliding-Doors WP site I'm working on. Guess I'm not sure what to put in after Theme "URI" and "Author URI". I've tried several combinations but to no avail. Any help? Thanks. (here's the style.css)               /*     Theme Name: Sliding Door Child     Theme URI:     Description: Child Theme for Sliding Door     Author: Your name!     Author URI:     Template: sliding-door     Version: 0.1     */          @import url("../sliding-door/style.css");     @import url("../sliding-door/dark.css");     @import url("../sliding-door/light.css");     @import url("../sliding-door/imagemenu/imageMenu.css");          /* Place new css code below here */


Finding the page id

I'm not sure if I'm blind here, but short of digging directly into the database tables, where would I find the database id for a post or a page?


Add_menu_page() error message -> "You do not have sufficient permissions to access this page"

I'm currently building a website for a friend and have assigned him the user role of editor. I don't want to give him an administrator role in case he breaks the layout. Anyway, I am using 'add_menu_page()' to add the Appearance > Menus page as an option for the Editor and it is showing up when I log in as an editor role, but when I click on it it says "You do not have sufficient permissions to access this page. Here is my code:               add_action( 'admin_menu', 'register_my_custom_menu_page' );          function register_my_custom_menu_page(){         add_menu_page( 'custom menu title', 'custom menu', 'edit_others_posts', 'nav-menus.php' );      }      I saw something in the codex that says if you see this message you have hooked in to early. I'm not very familiar with hooks and filters though, so I'm not sure what that means.


How to customize custom taxonomy url?

I have a Custom Post type "Data" with a custom Taxonomy "data-category". Currently my site url when I visit a 'data-category' shows like this : www.mysite.com/data-category/home-loan Here **Home-Loan** is a child of **Personal Loan** data-category. I need my url to show like this : www.mysite.com/personal-loan/home-loan Yes I need to get rid of 'data-category' from my url. Thanks


Login form in popup

I'm using WP3 with the defaul theme. I would like people to register before submit a comment. What I'm trying to do is having a link instead of the comment form that says something like "Leave a comment". Clicking this link would open a popup window with a login/register form or the comment form if people already signed in. Is this even possible? Thanks


Color Picker Showing Twice When Widget Added to Sidebar

I'm trying to create a plugin that is basically just a WordPress widget. I'm having great difficulty getting the WordPress color picker to function correctly when my widget is first added to the sidebar. I've followed these instructions for integrating the picker. However, this causes two color pickers to show in the sidebar when the widget is first added, only one of which is functional. Once the settings are saved, the second color picker is removed and everything works as expected. I've also tried adding the color picker after the `ajaxComplete` event fires instead of `ready`, but that produces the same result - two color pickers. I then uncovered this WordPress bug that has been marked as being invalid. When I tried the recommended approach of using the `sortstop` event, I had even worse results - duplicate color pickers, none of which actually functioned. I'm looking for solutions to this problem as I've reached a dead-end and can't release this plugin with a known bug. Is there perhaps a way to force a save when the widget is first added? Or is there some other way that I haven't considered in which to address this problem? Thx! Update - Here's the relevant code related to the color picker:               function load_color_picker_style() {         wp_enqueue_style('wp-color-picker');     }     function load_color_picker_script() {         wp_enqueue_script('wp-color-picker');     }     add_action('admin_print_scripts-widgets.php', 'load_color_picker_script');     add_action('admin_print_styles-widgets.php', 'load_color_picker_style');          function form( $instance ) {         $defaults = array(             'text_color' => '#000',         );         $instance = wp_parse_args( (array) $instance, $defaults ); ?>              <script>             //This shows two color pickers. So does using ajaxComplete or sortstop.             jQuery(document).ready(function($) {                 $('.color-picker').wpColorPicker();             });         </script>              <p>             <label for="<?php echo $this->get_field_id( 'text_color' ); ?>"><?php _e( 'Text Color', 'date-time' ) ?>:</label>             <input id="<?php echo $this->get_field_id( 'text_color' ); ?>"  name="<?php echo $this->get_field_name( 'text_color' ); ?>" type="text" value="<?php echo esc_attr( $instance[ 'text_color' ] ); ?>" class="color-picker" />         </p>     <?php     }


How to replicate some of Drupal Views functionality in WordPress?

I admit, I still think in Drupal. (In choosing between developing in WordPress and Drupal, I still tend to favor Drupal, because I haven't yet figured out a few things on the WordPress side.) **Can you help to figure out how to achieve in WordPress at least some of the Views functionality I know and love?** I can see that plugins that work with Custom Post Types are the WordPress equivalent of CCK. Now, is there a way (either through a UI or code) to: 1. display custom fields in columns and rows 2. Expose filters, that is, create drop-downs at the top, to allow the end user to select Here's a sample image of a single exposed field. http://www.packtpub.com/sites/default/files/Article-Images/drupalviews- article1-timage18.png (from my book) Variations would include filtering by more than one topic or custom field, being able to select multiple options, selecting on fields that are not just categories or tags, etc. There's one argument to be made that if I like Drupal so much, I should use it. But I think I could be a happy WordPress user too, if I could figure out how to display custom fields,and how to allow end-users to select through exposed filters. Any guidance welcome. * * * UPDATE: I'm studiously working my way through two answers so far. And so far I've been able to create custom fields, and display them, one post at a time. This is what I've added to my single.php. (It's somewhat messy, and I welcome ideas for improvement.) But what I still have to do is **get this out of the single.php context, so that I can display ALL post fields** , and not just the current ID. **(Also, my current css yields .meta_items displaying under the wrong .meta_table_header** if there are blank fields. Seems setting the width doesn't work if the element is empty, so somehow I have to populate it with a nobreak-space.) I also installed the Custom Field Template plugin: http://wordpress.org/extend/plugins/custom-field-template/, and figured out how to comma-delimit the results of multiple checkbox selections. (I haven't played much with Custom field Template yet, but I have the feeling I'm going to like it.)
       <?php        $div_meta_row =  '
';       $div_meta_item ='
 ';       $div_meta_table_header='
';       $div_end='
';             echo $div_meta_row;        echo $div_meta_table_header, "Breakfast", $div_end, $div_meta_table_header, "Currently Reading", $div_end, $div_meta_table_header, "Hours of Sleep", $div_end, $div_meta_table_header,'Favorite Fruits', $div_end;        echo $div_end;             echo $div_meta_row;           $meta_values = get_post_meta($post->ID, 'Breakfast', $single);           echo  $div_meta_item, $meta_values, $div_end;           $meta_values = get_post_meta($post->ID, 'Currently Reading', $single);            echo $div_meta_item, $meta_values, $div_end;           $meta_values = get_post_meta($post->ID, 'Hours of Sleep', $single);           echo $div_meta_item, $meta_values, $div_end;           $meta_values=implode(get_post_meta($post->ID, 'Favorite Fruits', 0), ', ');           echo $div_meta_item, $meta_values, $div_end;         echo $div_end;      ?>
      Here's the accompanying style sheet, which I placed in header.php.                     Once I get all the posts' fields to display in a separate URL, I'll work on the "custom fields parameters of query_posts." So, I know more than I did when I first asked the question. Still a ways to go. (Drupal Views offers a powerful UI, and so far this is almost all coding, but I'll wait until I truly have this figured out in WordPress before making any pronouncements about which is easier. I'm hoping in the end to enable the user to filter by multiple custom fields in WordPress. Here's what this looks like so far. ![Progress so far...](http://i.stack.imgur.com/ecqJM.png) Aiming for something more like: ![Goal](http://i.stack.imgur.com/xEj3G.jpg)


How to set admin login page as home page

How can I set the backend admin login page as the homepage of my wordpress application? When the user types in art.com, I really want to let me go to art.con/wp- admin. Is this done on worse press or the server configurations?


Is a true MiniSite possible with WordPress?

I am creating a website that needs to have separate custom “portals” or “Sections” depending on which market you are in. Example situation:   1. user lands on the home page.   2. User looks at the top-level horizontal menu next to the company logo in the header for the main menu item labeled “VEHICLES” which has 2 sub menu items:     1. SUV     2. SEDAN   3. User chooses “SUV” because that is what he/she needs information or products for.   4. User is taken to the “SUV” landing page that has its own custom left sidebar for “SUV” information and products specifically. Keep in mind that the same top-level horizontal menu next to the company logo in the header will be the same throughout the entire site as well as the footer. My question revolves specifically around the sidebar.   5. So far so good, but now from the custom “SUV” sidebar menu found on the left side of the page - User clicks on a menu item called “SERVICING.” This is where my question starts: The “SERVICING” page is a general information page that will be categorized/found in multiple places. For instance under SEDANS >> SERVICING, SUVS >> SERVICING, MOTORCYCLES’s >> SERVICING, etc.) – but since I entered through: www.sample.com >> VEHICLES >> SUV I would like for WordPress to always display to me the custom “SUV” sidebar that has been made for my type of vehicle whis is an “SUV” – no matter what page I navigate to from this point on, (unless of course I pick something from the top-level horizontal menu next to the company logo in the header – which would take me out of the “VEHICLES >> SUV” section/portal). So my questions are:   1. Is this possible in WordPress without duplicating pages. (i.e. having a global “SERVICING” page and then having to duplicate that page just so I can have a “SERVICING” page under “SUV.”   2. Can this be solved with a plugin? Or by some other means as simple.   3. Does this warrant a WP multsite? I would say no, as far as my experience goes, since this is just one company, with one website, that is controlled and edited by one webmaster. The header/branding area to include the main menu, blog material, and footer is global for all users despite which portal/section they are in. This Webmaster just wants different user experiences (sidebar menus) based on what the users vehicle is. If the user comes through the SUV portal then he just wants to show this user SUV related information and products in the left sidebar until the user chooses to leave the SUV portal. Any help you can provide would be helpful, as I haven’t been able to find a solution to this with WordPress yet. Thank you in advance!


rewrite_rule() not preserving the query string

We have added a custom rewrite_rule to our site to allow for a pretty inbound link to be parsed and handled properly. Links are constructed as `domain.com/meetings/faculty/someIDnumber`               add_action( "init", "pleasing_permalinks" );     function pleasing_permalinks() {         add_rewrite_tag( '%hash%', '([^&]+)' );         add_rewrite_rule(             'meetings/faculty/([^/]+)/?$',             'index.php?p=1598&hash=$matches[1]',             'top'         );         //flush_rewrite_rules();     }      Rewrite Analyzer approves of the above but when we test with actual links in the browser, the embedded ID number is not preserved. What are we missing here?


How to save the state of a drag and drop jQuery UI Sortables front end layout editor?

I am building a front end post layout editor using jQuery UI Sortable. The posts are laid out in 300px by 250px boxes over a background image. The posts are created and edited using the WordPress admin but I want to allow the sites administrator to adjust the order of the boxes using a drag and drop interface on the front end. I've got the drag and drop sortable part working but need to come up with a way to save the state (order) of the boxes. Ideally I would like to be able to save the state as an option and build it into the query. The query for the posts is a simple WP_Query that also gets data from custom meta boxes to determine the individual box layout.:               $args= array(           'meta_key' => 'c3m_shown_on',            'meta_value'=> 'home' );         $box_query = new WP_Query($args);  ?>
                 <?php         while ($box_query->have_posts()) : $box_query->the_post(); global $post; global $prefix;                    $box_size = c3m_get_field($prefix.'box_size', FALSE);         $box_image = c3m_get_field($prefix.'post_box_image', FALSE);         $overlay_class = c3m_get_field($prefix.'overlay_class', FALSE);              if ( c3m_get_field($prefix.'external_link', FALSE) ) {         $post_link = c3m_get_field($prefix.'external_link', FALSE);         } else                 { $post_link = post_permalink();          } ?>               <li class="<?php echo $box_size;?>  ui-state-default">             <article <?php post_class() ?> id="post-<?php the_ID(); ?>">                 <?php echo  ''; ?>                     <div class="post-box <?php echo $overlay_class;?>">                     <?php if ( c3m_get_field( $prefix.'text_display', FALSE) ) { ?>
<a href="<?php echo $post_link?>"><?php the_title();?>

<?php echo substr($post->post_excerpt, 0, 90) . '...'; ?>
                                 <?php } ?>

                       <?php endwhile; ?>

      The javascript is just the basic default sortable instructions               jQuery(document).ready(function() {         jQuery("#sortable").sortable();       });      There are methods available using cookies to save the state but I also need to disable the sortable drag and drop for non admin users so I really need to save to the database. I'm looking for the most creative and usable method and will award a 100 point bounty to the best answer. ### Update: I got somatic's answer working with one minor change. ajaxurl doesn't return the value on non admin pages so I used `wp_localize_script( 'functions', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );` to define the value and changed the javascript line under options to:   `url: MyAjax.ajaxurl,` To limit access to arranging the order to only admins I added a conditional to my wp_enqueue_script function:                   function c3m_load_scripts() {          if ( current_user_can( 'edit_posts' ) ) {             wp_enqueue_script( 'jquery-ui' );             wp_enqueue_script( 'functions', get_bloginfo( 'stylesheet_directory' ) . '/_/js/functions.js', array( 'jquery', 'jquery-ui' ), false);             wp_localize_script( 'functions', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );         }     }      I'm going to do a little more testing and mark this question as solved and award the bounty.


How can one utilize a variable as a callback function name for add_settings_field

I'm trying to cut down on the amount of code that is in my theme options function. I'm adding my settings like so: add_settings_field($k,$v,$callback,$the_options,$the_group,$args); This works for me in every way as long as I write out the name of the function. For example, if $callback = 'awesome_callback' - and I create a function called               awesome_callback(){ echo 'something'};       there are no issues whatsoever. The following loop also works and loops through the array of options to create the settings fields.. and grabs all the necessary data. it also echoes out exactly what I think my callback should be named. However, right now i have a gagillion callback functions outside of this loop that all look exactly the same except for the name of the function. :(               foreach($theOptions as $k=>$v) {              add_settings_field($k,$v,$callback,$the_options,$the_group,$args);         echo $callback;          }      Bare with me. I hope someone has faced this issue before and will let me know I'm missing something obvious. The following also works within my wordpress environment outside of the same loop.               $callback = 'awesome_callback';     $callback = function() {         echo 'awesome callback';     }     $callback();      However, the following returns an error to unknown callback function even though when I echo out the $callback variable, it echoes out the exact string I am referencing in the callback function. I guess I am over-riding the callback value... ???               foreach($theOptions as $k=>$v) {              $callback = $k.'_callback';         add_settings_field($k,$v,$callback,$the_options,$the_group,$args);                   $callback = function() {             echo 'Testing the callback !!! <br>';         };          }      Can anyone explain a solution for looping through an array of options in a way that will allow to call the callback function within the loop, without having to hard-code it? Is this something that could be solved using a class? I can't squeeze my head around it.


Style product detail page with custom CSS in woocommerce

I am trying to style a single product page with custom CSS in WooCommerce. I managed to get the categories styled with the conditional tag is_product_category in my header file and an php IF statement. Up to there its fine, I have a category called "Her" and all the pages to do with that category are pink. But then, when I go to an individual product in the "Her" category, it reverts to the default CSS. I checked and there are no conditional tags to address a single product. I've spent hours researching and reading everything I can find but I cant find a solution. I need the product page to have the same styling as the parent category. Any thoughts as to how I can achieve this? Many thanks in advance


Custom header images won't appear when set to random

I'm using a custom theme, developed from Boilerplate (some time ago). I noticed that the header images work fine when set statically, but fail to appear when set to random. I tried switching themes, and realized the same issue happens with Boilerplate, as well as Twentytwelve. Twentyten worked though, so I copied its code to my theme, and STILL it doesn't work! My functions.php contains:                   // The custom header business starts here.          $custom_header_support = array(         // The default image to use.         // The %s is a placeholder for the theme template directory URI.         'default-image' => '%s/images/headers/starkers.png',         // The height and width of our custom header.         'width' => 760,         'height' => 280,         // Don't support text inside the header image.         'header-text' => false,         // Callback for styling the header preview in the admin.         'admin-head-callback' => '',     );          add_theme_support( 'custom-header', $custom_header_support );          if ( ! function_exists( 'get_custom_header' ) ) {         // This is all for compatibility with versions of WordPress prior to 3.4.         define( 'HEADER_TEXTCOLOR', '' );         define( 'NO_HEADER_TEXT', true );         define( 'HEADER_IMAGE', $custom_header_support['default-image'] );         define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );         define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );         add_custom_image_header( '', $custom_header_support['admin-head-callback'] );         add_custom_background();     }          // We'll be using post thumbnails for custom header images on posts and pages.     // We want them to be 940 pixels wide by 198 pixels tall.     // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.     set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );          // ... and thus ends the custom header business.               // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.     register_default_headers( array(         'berries' => array(             'url' => '%s/images/headers/starkers.png',             'thumbnail_url' => '%s/images/headers/starkers-thumbnail.png',             /* translators: header image description */             'description' => __( 'Boilerplate', 'boilerplate' )         )     ) );     }     endif;      Basically copied verbatim. And my header.php:               <?php         // The header image         // Check if this is a post or page, if it has a thumbnail, and if it's a big one         if ( is_singular() &&                 has_post_thumbnail( $post->ID ) &&                 ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_WIDTH ) ) ) &&                 $image[1] >= HEADER_IMAGE_WIDTH ) :             // Houston, we have a new header image!             echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );         elseif (get_header_image()) : ?>         <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />     <?php endif; // end check for featured image or standard header      ?>      I'm JUST about out of my mind with it now—is there something I'm missing, maybe? Or a conflict I haven't noticed?


Unable to delete custom post types, confusion around capabilities

So I'm working on a plugin for creating a questions/answers system that's as simple and well-integrated as possible (not unlike this site) but am stuck at the creation of the custom post types. You can see my current code here: http://pastebin.com/MXjPVuPQ The key is in allowing all users (down to "subscribers") to post questions and answers, edit their own posts, etc., whilst admins can manage and moderate these. So following a tutorial, I've got the basics going. Subscribers can create their own questions and answers and edit their own, but not others'. However, these can't be deleted. Using the "Members" plugin I've given the appropriate capabilities (reference?) but not even an admin can delete their own or others' posts. I'm not really sure why this is happening, any obvious hints or something I'm missing?


Secure WordPress paid plug-in

I want to create a WordPress plug-in but also want to ensure that the plugin can only be used after it has been activated with a serial key that should be unique for each domain. What is the best way to go about it assuming:   1. I have to give the actual source code to the users and cannot have a VideoPress type of security - which is just a JavaScript wrapper for the actual content that comes from the plugin's server.   2. I want to ensure that a novice to average PHP developer will not be able to cirumvent the security easily.


Printing out JSON array returned

I have the following JSON array:               [{"occurences":"1","post_title":"Test 1","ID":"16"},          {"occurences":"1","post_title":"Test 2","ID":"19"},      {"occurences":"1","post_title":"\u543b\u60a8\u7684\u5c41\u80a1","ID":"21"}]       And I use this js to parse and print it:               success:function(data){          $.each(data, function(i, post){          content = '';          content += '
' + post.post_title + '
';        });             $(content).appendTo("#search-results");             }      But the display only showed "Undefined", and the Console showed no errors. In case you ask, this is the HTML part:               <form id="search" action="">

Search
         Back

<input type="text" name="search-text" placeholder="Search" id="search-text" />

Results

     </form>      Any clue why? Many thanks in advance!


What is an "Options Framework" for Wordpress

I am exploring a couple options frameworks for wordpress like the Redux Framework. As a non-developer interested in maintaining my own Wordpress based web app, when would an options framework like Redux be useful? Most sites for options framework market their tool to the wordpress developer community. I have not found a simple explanation geared toward non-developers or newbies that clarifies when an options framework should be used. http://reduxframework.com/ Thanks,


Echoing Categories only if they're a child of a given category

I've got posts that I want to echo after the post content the categories only if they're a child of a given parent category. ### Example: Parent category: Goal   Child categories of "Goal": brand awareness, brand engagement If a post is categorized, I want it to echo out those category or categories:               <?php         $categories = get_the_category();         $seperator = ' ';         $output = '';         if($categories)         {             foreach($categories as $category)              {                 $output .= 'term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.''.$seperator;             }             echo trim($output, $seperator);         }     ?>      I'm using this, but it obviously outputs all categories, rather than just the ones that are children of the "goal" slug. Edit: Current setup looks like this, but doesn't seem to be working. If I use the ID, it's fine:               <?php             $categories = get_the_category();             $seperator = ', ';             $output = 'GOAL: ';             $category = get_category_by_slug('goal');             if($categories)             {                 foreach( $categories as $category )                  {                 if ( $category->parent == $category->term_id )                     $output .= 'term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.''.$seperator;             }             echo trim($output, $seperator);     }     ?>


submenu item edit a specific post

I'd like to have a submenu item in the admin section link directly to the edit form for a specific post ID, a custom post type at that. Basically looking at using the add_submenu_page function to add the menu item http://codex.wordpress.org/Function_Reference/add_submenu_page which is easy. Any ideas how to write a callback function to display the edit form for a specific post ID (which, in this case, happens to be a custom post type)?


Get Post ID as a separate RSS feed item

I am looking for a way to display or echo each post ID within my RSS feed. Basically when I access my RSS feed site, I get the following XML items: `<title>`, `<link>`, `<comments>`, `<category>`, `<pubDate>`, `<guid isPermaLink>`, `<description>`. When I use this Google function in my code               var url = 'http://howtodeployit.com/category/daily-devotion/feed/';             $.ajax({             type: "GET",             url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=1000&callback=?&q=' + encodeURIComponent(url),             dataType: 'json',      the returned Objects are title, link, author, publishedDate, contentSnippet... What I also want returned is the Post ID but not sure how to get my WordPress to include that in the XML.


alternative to the_content filter

"i am using the_content filter on the category pages like cat=1" I am appending --N in the content. But due the the theme functionality it strip the content after some number of characters therefore in post with the less content i can see the "--N" string but with the large content i cant see "--N" string as the "content" is being stripped. I want to append the '--N' string every time. Is there is any other way to append the content? ![enter image description here](http://i.stack.imgur.com/8Slct.png) Code               function rate_post_content($content) {         if(is_category()){             global $post;             return $content."---N"; // here any test can come         }         return $content;     }          add_filter('the_content', 'rate_post_content');


How to customise the height of automatic embed using $GLOBALS['wp_embed']->autoembed( )

Is there a way to customise the height of embedded media using embed function? I did a bit of research in wordpress codex but there isn't any elaborate documentation for this function. Related Question: Advanced Custom Fields plugin : displaying a YouTube video


How to reconnect to the wordpress database after the connection has timed out

I am writing a plugin that uses the database a lot to store product details from the Amazon Product API and I'm getting a lot of MySQL Server has gone away errors. The server that I'm working on is really slow and it must be that the default database timeout is really low so it simply times out before the whole page has even loaded. I've tried this as the solution: http://wordpress.org/plugins/wordpress-database-ping/ It works but it doesn't seem to be a good practice. According to the guys from here: http://stackoverflow.com/questions/14381276/php-mysql-connect-set-wait- timeout and here: http://stackoverflow.com/questions/3103969/should-i-ping- mysql-server-before-each-query Basically its not good for performance since the database is pinged before executing a query whether or not the connection has already timed out. The other solution is setting the timeout but its not good practice either. So my question is how do I catch these mysql server has gone away errors and try to reconnect to the database from the plugin then re-execute the query again? Thanks in advance.


Failed to import Media

When I generate XML file with [Tools > Export] and use [Tools > Import] on another WordPress website I get "Failed to import Media" for each attachment post type. And images that failed to load are hotlinked from the previous server which consumes the transfer of that previous server... But when I download "Unit Test" from http://codex.wordpress.org/Theme_Unit_Test then this problem doesn't exist. Some images still have "Failed to import Media" but it's only like 5 out of 30 images. They have URLs to their own server in their XML but somehow [Tools > Import] manages to download their media and replace these URLs with new locations (it is not hotlinked anymore). What's the trick to make it work properly without "Failed to import Media"? Why even "Unit Test" has a few "Failed to import Media" messages?


How do I count how many top level categories there are?

I need to calculate some dynamic CSS based on how many top level categories exist. (NOT how many posts are in a category, or how many categories a post belongs to... Nothing about posts at all, just how many top level categories there are) I am new to PHP, but I couldn't find any WP functions that would return the number I'm looking for. Thanks in advance for any help.


Multiple post queries -category,posts per page,orderby

I originally had this query on a posts category page:                       <?php $page_query = new WP_Query('post_type=post&cat=145'); ?>      Which worked, but it only displayed the first 4 posts. So I wanted to display all the posts from the category, as well as change the posts per page limit, as well as set the orderby for good measure. However, this query returns EVERY post on my site, regardless of category:                       <?php $page_query = new WP_Query('post_type=post&cat=145'. '&posts_per_page=-1&cat' . '&orderby=date&order=asc'); ?>      Seems like it should work in theory. Any ideas what I'm doing wrong?


Help on Custom Post Types

I am using custom post types on a new site I am setting up as follows. One Custom Post Type is STORES with multiple taxonomies (eg Location, Category, Brands, Payment Types etc) and also some custom fields (address, phone) Other custom post types are DEALS also with taxonomies (brand, deal type, discount etc) which I was hoping to link to the STORES post type. For example Store 1 has its own listing with all the information about that store. Then I create deal 1 which is a deal offered by Store 1. Is this possible? What would be the best way to achieve this? In future I might also add reviews or products as a custom post type also linked by store. Hope this makes sense!!! Richard


get post type plural

Currently I'm trying to get the post type labels plural. In detail:               $GLOBALS['wp_post_types'][ get_current_screen()->post_type ]->labels->name      This is how I'm trying to retrieve it - in the admin UI - using the public wp API functions:               $post_type_name = get_current_screen()->post_type;     $post_type_obj = get_post_type_object( $post_type_name );     get_post_type_labels( $post_type_obj );      The result is the following Error: > `Fatal error: Cannot use object of type stdClass as array in > D:\development\xampp\htdocs\wp_inst\wp-includes\post.php on line 1209` The problem is that the post type objects labels is also an object, while `get_post_type_labels()` calls `_get_custom_object_labels()` internally and seems to expect an array. Fun are the last two lines of the `_get_custom_object_labels()` function:               $labels = array_merge( $defaults, $object->labels );     return (object)$labels;      So, am I using the wrong functions? Is the core function wrong? Is this core function only meant to be used during custom post type registration? * * * _Note: Currently on WP version 3.3.2._


Add to cart option to have multiple of 6

I am building a wholesale store with wordpress and woocommerce and having a strange problem with the requirement. The client wants to sell the products in multiple of 6 like 6/12/18/24, so when a user reach product page , he can select 6/12/18/24 as product quantity. I have tried variation of product but the problem is this will hide the orignal price of product and will show the price of 6 products at least. For example: I have created variations for a product priced at 1$ with multiples of 6 and then it will show the price as "from 6$" rather than orignal price of product and its seems too much work to add variations in 500+ products manually. How to add only multiples of 6 in the add to cart quantity selection?


How can I style a certain element only when wptouch is active?

I just installed the wptouch plugin for auto-styling my blog in mobile devices. How can I style a certain element on my page to be hidden when this view is active? I.e., in particular, on my blog Under My Hat, I have a WP Follow Me plugin which behaves rather annoyingly on mobile devices, which is why I'd like to hide it. But other elements are custom tables and source code examples that I would like to style differently.