Using WordPress Multisite to manage multiple projects?

I currently use WordPress for most of my projects, the way I manage them is creating a folder for each in my local environment each containing a WP install which in times makes it a paint to maintain, upgrade and takes more space. I was looking at WP Multisite and I was wondering if I could use it to create multiple projects with the same WP installation but ran into a problem, when I finish a project using my current method I just send my client a SQL Dump of my DB, tell them to replace the URL and install all the files/folders to his server and it works fine. But WP Multisite creates an unique folder and DB structure which makes it difficult to do this since most of my clients won't be using MU but regular Wordpress installations. So is there an easy way to "export" a WP MS site to use it on a regular WP install? Or should I stick to having multiple WP copies? Thanks in advance!


How can I create a loop with specified category include pages with custom field

I created a loop for list all post with specified category               $args = array(             'cat' => "category",             'showposts' => "5"         );     // The Query     $narga_query = new WP_Query( $args );          // The Loop     if ( $narga_query->have_posts() ) {         while ( $narga_query->have_posts() ) {             $narga_query->the_post();             // do something         }     } else {         // no posts found     }          // Restore original Post Data     wp_reset_postdata();      It's working flawlessly. I want include one or some page with custom field name "active" with value "true" by add more conddition                       $args = array(             'meta_query'             => array(         array(             'key'       => 'slide',             'value'     => 'true',             'compare'   => '=',                     ),                     'post_type'              => 'any',             'cat' => narga_options('featured_category'),             'showposts' => narga_options('number_slide')         ));      But the loop not working, can you help me?


how to grab first link in post... and of course call it

I have been trying to get the answer to this for ages now and wondered if anyone here could help. I would like to 'grab' the first link in a post and attach it to a button/image. I have tried the numerous options available here: http://wpquestions.com/question/show/id/873 I have had greater success with the last suggestion in the post of the link above, HOWEVER, it only works in Safari... I have tried with Chrome, Opera, IE and Firefox and none of them can even see the image let alone the link. My website is here: http://www.officialiphoneapp.com When you click on an app to see more, you should see an 'Available on iTunes' button above the post picture and a 'Download on iTunes' button below the post but unless you're using Safari you won't see either. Any and all suggestions welcome. Marcus


Is it legal to use a white label plugin on wordpress?

I was wondering if it is legal to use a white label plugin, like White Label CMS, on Wordpress without violating their terms and agreements. Thank you so much for your help and support!!


Display Posts Only with Specific Tag

I'm trying to only display posts with the tags `Movie Trailers` and `Gaming Trailers` but my loops are still displaying everything under the category /videos/ heres what I have category-videos.php:               <?php if ( have_posts() ) : ?>     <?php  ?>     <?php add_action( 'pre_get_posts', 'display_gaming_trailers' ); ?>     <?php while ( have_posts() ) : the_post(); ?>     <?php     get_template_part( 'content-videos', get_post_format() );     ?>     <?php endwhile; ?>     <?php else : ?>     <?php get_template_part( 'no-results', 'index' ); ?>     <?php endif; ?>      and in the functions.php i have:               //Display Movie Trailers     function display_movie_trailers( $query ) {         if ( $query->is_home() && $query->is_main_query() ) {             $query->set( 'tag', 'movie trailers' );         }     }     add_action( 'pre_get_posts', 'display_movie-trailers' );          //Display Gaming Trailers     function display_gaming_trailers( $query ) {         if ( $query->is_home() && $query->is_main_query() ) {             $query->set( 'tag', 'gaming trailers' );         }     }     add_action( 'pre_get_posts', 'display_gaming-trailers' );      I made some mistakes in the `functions.php` code above, and corrected them with the code you suggested but nothing is appearing in the loop. The category is `videos` so I now have:               //Display Gaming Trailers     function display_gaming_trailers( $query ) {         if ( $query->is_category() && $query->query_vars['category_name'] == 'videos') {             $query->set( 'tag', 'gaming trailers' );         }     }     add_action( 'pre_get_posts', 'display_gaming_trailers' );      **Edit:** i tried `gaming trailers and the slug`gaming-trailers` without any luck.. anything that could be stopping this from working?


Category pie diagram meta box in post editing page

I am trying to build a plugin for showing a pie diagram based on the number of those categories which have maximum posts. This diagram is a meta box in post editing page. Here is my source of inspiration: jquery charts Most of the way the function works is same but I added some hooks to add it into meta box. Here is my code:               add_action( 'add_meta_boxes', 'category_meta_box_add' );          function category_meta_box_add() {       add_meta_box( 'my-meta-box-id', 'Category by Percentage', 'categories', 'post', 'normal', 'high' ); }            function categories($atts,$content = '') { }        //full function is defined in link above     add_shortcode('mycategories', 'categories');     echo do_shortcode('[mycategories]');      This plugin on installing shows meta box without data, also gives error: > The plugin generated 721 characters of unexpected output during activation. > If you notice “headers already sent” messages, problems with syndication > feeds or other issues, try deactivating or removing this plugin. How to resolve this? Thanks Full plugin here


wp-load.php redeclares classes

I am trying to load WordPress options within a standalone PHP file. The file is located in `/wp-content/plugins/plugin-name/file.php`. I have used the following to open wp-load.php:               if (file_exists('../../../wp-load.php')) {         require_once ('../../../wp-load.php');     }      Doing so outputs the following error: > Fatal error: Cannot redeclare some_plugin_function() (previously declared in > /var/www/vhosts/domain.com/httpdocs/wp-content/plugins/plugin-name/class- > frontend.php:5) in /var/www/vhosts/domain.com/httpdocs/wp- > content/plugins/plugin-name/class-frontend.php on line 12 Removing all code from `class-frontend.php` does solve the issue, but of course I need that file. `class-frontend.php` is not called within the standalone PHP file so am unsure why this is happening.


How to remove custom post type archive

I have a custom post type called "recipe" with the `has_archive` parameter set to true. Visiting mysite.com/recipe/ gives a basic archive list of all the recipes posted and a page title of "Recipes". So far so good. Now I'm looking to disable that recipe archive page (but keep individual recipe links working). My first thought was to try setting `has_archive` to false, which sounds like it should do the trick. Nope. The only difference this makes is the page title which for some reason becomes the name of the site. The actual archive is still displayed. What is the best way to actually remove that archive completely? Is there a parameter of `register_post_type` that will achieve this or is it impossible and a case of a custom page template with a redirect in it? Thanks.


unable to save post meta on single field with multiple selects

I set up two select boxes in one meta field by putting two arrays inside the 'options' array of my callback. The HTML is outputting fine, but the meta is not being saved to the database... Here is a pic of the meta box setup (for whatever random reason that make me think it would be helpful): ![](http://designerbyfate.com/up/pics/multiselectmeta.gif) ...aaaaaaaaaaaaaaaaaaand here's my code:               add_action( 'add_meta_boxes', 'event_infobox_add' );                                                             add_action( 'save_post', 'event_infobox_save' );     function event_infobox_add() {     add_meta_box(      'event_infobox', // $id      'Event Date, Time, and Venue Info', // $title      'event_infobox_call', // $callback     'events', // $page     'normal', // $context      'high' // $priority        );     }          // Time options for dropdowns in the HTML     $times = array(  'hour00' => '12AM' ,'hour01' => '1AM' ,'hour02' => '2AM' ,'hour03' => '3AM' ,'hour04' => '4AM' ,'hour05' => '5AM' ,'hour06' => '6AM' ,'hour07' => '7AM' ,'hour08' => '8AM' ,'hour09' => '9AM' ,'hour10' => '10AM' ,'hour11' => '11AM' ,'hour12' => '12PM' ,'hour13' => '1PM' ,'hour14' => '2PM' ,'hour15' => '3PM' ,'hour16' => '4PM' ,'hour17' => '5PM' ,'hour18' => '6PM' ,'hour19' => '7PM' ,'hour20' => '8PM' ,'hour21' => '9PM' ,'hour22' => '10PM' ,'hour23' => '11PM' );          // Meta Box fields HTML     $event_infobox_fields = array(     array(          'label' => 'Event Time Frame'         ,'desc' => 'Enter time frame of the event here'         ,'id' => 'event_timeframe'  //values stored with this key         ,'class' => ''         ,'type' => 'select'         ,'options' => array(             'timestart' => $times,             'timeend' => $times         )     )     );          function event_infobox_call( $post ) {     global $event_infobox_fields, $post;       // Use nonce for verification       wp_nonce_field( plugin_basename( __FILE__ ), 'event_infobox_nonce' );     echo '<input type="hidden" name="event_infobox_box_nonce" value="'.wp_create_nonce(basename(__FILE__)).'" />';            // Loop it up     echo '
';          foreach ($event_infobox_fields as $field) {           $meta = get_post_meta($post->ID, $field['id'], true);          echo '
                      '.$field['label'].'             '.$field['desc'].'         	         ';         switch($field['type']) {                  case 'select':                  // Event Timeframe Select Dropdowns             if ( $field['id'] == 'event_timeframe') {                 foreach ($field['options'] as $key => $value ){                     echo $meta;                     $keyhead = str_replace('time','',$key);                     echo ''.$keyhead.'                                 <select style="width:200px; display:block;" name="'.$key.'" id="'.$key.'">';                     $total = count($field['options'][$key])-1;                     for ($i=0; $i<=$total; $i++){                         if($i<10) {                             $i="0$i";                         }                         echo '<option style="width:200px; display:block;" value="'.$field['options'][$key]['hour'.$i].'"', $meta == $field['options'][$key]['hour'.$i] ? 'selected="selected"' : '','>'.$field['options'][$key]['hour'.$i].'</option>';                     }                     echo '</select>';                 }             }                  ////////////                  break;                } //end switch       echo '
';       } // end foreach          echo '
'; // end table       }          // $ave $ave $ave     function event_infobox_save( $post_id ) {      global $event_infobox_fields;            // verify nonce       if (!wp_verify_nonce($_POST['event_infobox_box_nonce'], basename(__FILE__)))               return $post_id;       // check autosave       if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)               return $post_id;       // check permissions       if ('page' == $_POST['post_type']) {               if (!current_user_can('edit_page', $post_id))                       return $post_id;               } elseif (!current_user_can('edit_post', $post_id)) {                       return $post_id;       }         // loop through fields and save the data       foreach ($event_infobox_fields as $field) {           $old = get_post_meta($post_id, $field['id'], true);         $new = $_POST[$field['id']];               if ($new && $new != $old) {                   update_post_meta($post_id, $field['id'], $new);          }              elseif ('' == $new && $old) {                   delete_post_meta($post_id, $field['id'], $old);           }       } // end foreach       }


Incorporating the Settings API in WordPress Themes - by Chip Bennet

I am using the code by Chip Bennett to create a settings options page for my plugin. The problem is that I am getting a Warning error as indicated below that I cannot figure it out. Any help is appreciated. > Warning: call_user_func(ch_settings_defaults_style_section_text) > [function.call-user-func]: First argument is expected to be a valid callback > in /home/loc123/public_html/domaindvb.com/wp-admin/includes/template.php on > line 1083                   <?php     function ch_admin_options_page() {         global $pagenow;      ?>
     <?php             /* Calls function to add tabs */             ch_admin_options_page_tabs ();                  /* adds the "updated" admin notice */             if ( isset( $_GET['settings-updated'] ) ) {                 echo "

Custom Header settings updated successfully.

";             }     ?>             <form action="options.php" method="post">                    <?php                 settings_fields('mycustom_options');                 do_settings_sections('mycustom');                 ?>             <?php             if ( 'themes.php' == $pagenow && isset( $_GET['page'] ) && 'ch-settings' == $_GET['page'] ) :                  if ( isset ( $_GET['tab'] ) ) :                       $tab = $_GET['tab'];                  else:                       $tab = 'general';                  endif;                  switch ( $tab ) :                       case 'general' :                     require ('options-register-defaults.php') ;                      break;                       case 'Home Page' :                     require( 'options-register-homepage.php' );                     break;                  endswitch;             endif;               ?>

                  <input name="mycustom_options[submit-<?php echo $tab; ?>]" type="submit" class="button-primary" value="<?php esc_attr_e('Save Settings', 'default'); ?>" />                  <?php /* Add a Reset Button */ ?>             <input name="mycustom_options[reset-<?php echo $tab; ?>]" type="submit" class="button-secondary" value="<?php esc_attr_e('Reset Defaults', 'default'); ?>" />                  </form>
     <?php     }     ?>          <?php     add_action('admin_init', 'chr_settings');     function chr_settings() {              /*  register_setting( $option_group, $option_name, $sanitize_callback )- Associates an option group passed to settings_fields with database entry */         register_setting( 'mycustom_options', 'mycustom_options', 'ch_options_validate' );          add_settings_section('ch_settings_defaults_style', 'Style Options', 'ch_settings_defaults_style_section_text', 'mycustom');          }     ?>      **File:** `options-register-defaults.php`               <?php     function ch_settings_defaults_style_section_text() { ?>
<?php _e( 'Manage Header options for the Oenology Theme. Refer to the contextual help screen for descriptions and help regarding each theme option.', 'mycustom' ); ?>
     <?php      }     ?>


search.php file not pointing where it should

Hi I have I started to create my first wordpress template yesterday and today I have gotten to the point where I have to create the search page result.From what I found online that should be search.php file.But for some reason it seems Wordpress is not pointing to that page when I try to search.I also created the searchform.php.Here is my code for it:                   <form id="searchform" method="get" action="<?php bloginfo('url'); ?>">             <input type="text" value="type your search"/>              </form>      What am I doing wrong?Do I have to activate the search page in functions.php?


How do I only load js on the post-new.php and post.php pages in admin?

I have some script that is loading in the admin. I only need it to load on the new post and edit posts screens. What is the best way to do this?


How to find meta_values to call

This thing has really confused me, when writting a custom query with `wp_query` we have pass multiple arguments. But i am using woocommerce, and i found this part of query on some form, which is               $args = array(       'post_type' => 'product',       'meta_key' => '_featured',       'meta_value' => 'yes',       'posts_per_page' => 10        My question is, how to find out, the `meta_key`, do i look into database? or backend? suppose i want to find out about a product information, lets say how many grams or lets says colors of a shirt. How and where do i look for it, to pass it along with `meta_key`? Do i look into database or where? and after i get the meta_key, how do i display it in the loop, like we say `the_title()`


Fancybox plugin: triggering on href attribute

I want to show a pop up when clicking on an anchor with a specific url. I've tried the following code in the extra calls tab but it doesn't work.               jQuery("a[href='http://www.everytrail.com/view_trip.php?trip_id=2027383']").fancybox({      'transitionIn': 'elastic', 'transitionOut': 'elastic', 'speedIn': 600, 'speedOut': 200, 'type': 'iframe', 'height': 800 }); I assume the problem is in the selector since I have another script where the code beyond the selector is identical to the above, and it works perfectly. I tested the syntax of the selector at W3 schools doing a simple add class test and the syntax appears to be correct. Any suggestions as to the source of the problem? Syntax, perhaps Fancybox has trouble with certain selectors? Any advice would be appreciated. Thanks.


Memory errors with media upload, Wordpress can't use more than 96M (while there's 512 available!)

I'm aware that this is a known problem but I was unable to address it using information found in WPAnswers and Wordpress support forums. In my Worpdress single site installation the media uploader is always throwing an error at me                   out of memory (allocated 99614720) (tried to allocate 3760 bytes)       the amount of allocated memory is more or less always the same - that should be about 96M... but in my server the php memory limit was set to 512M, post size is 12M, max upload size 8M it's a VPN server and there's 1.5GB memory on it! Wordpress throws the error also on images as small as 300-400K and under. I tried using                   define('WP_MEMORY_LIMIT', '128M');      or                  define('WP_MAX_MEMORY_LIMIT', '128M');      but neither of these (alone or together) worked, in fact the error thrown was always the same and I had the impression Wordpress was disregarding both - I tried other settings too, the error was always the same and the amount of memory allocated more or less the same I tried to change the php settings, like lowering the memory limit to 128M or bringing back again to 256M, restarting http service (apache) and restarting the whole server, but nothing changes I proceeded to disable plugins, but the only way they don't seem ultimately responsible for the problem. I decided to edit line 257 of media.php inside wp-includes folder, since the errors were always coming from line 258 which was executed thereafter                  @ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) );      I've replaced WP_MAX_MEMORY_LIMIT with values above 96MB for instance 128M or 256M but no matter what, the allocated memory never exceeded 96MB. I tried lowering the WP_MAX_MEMORY_LIMIT to values such as 16M, 32M... anything below 96. Well! In that case the allocated memory resulted lower as in fact I was setting a lower limit - but how come it can't be more than 96? Still, I don't understand why wordpress takes so much, but nevertheless, why I'm not able to set to 128 and see if the problems are finally fixed? I'm only experiencing issues with the image uploader. I've even tried to use                   @ini_set( 'memory_limit', '128M' );      in my wp-config but again it doesn't change the 96M limit... however it's able to lower it if I set to anything below 96 (resulting memory errors will state corresponding values) I've run phpinfo from where my Wordpress installation is and the available memory is indeed that which is set on the server... 512M! so I don't understand why Wordpress seem to use less than that no matter what any clues? thank you


I can't change the body background-color through style.css

Using a child of Twenty Twelve, I've been adding color to all the major containers (#main, #content, #secondary, etc.) using               #arbitrary-id {      background-color: #dedede;     }      This works for everything but body. I should be more clear: it changed the body background color until I messed with the background color in "Appearance -> Background". Now no matter what I try, I can't override that. Looking in the HTML of the page and inside the `<head>` I see:               <style type="text/css" id="custom-background-css">     body.custom-background { background-color: #e6e6e6; }     </style>      Naturally, I tried to change the color using that selector, but since it's generated internally, that trumps the external CSS. I'm at a total loss for how to do this. How do I change the background color of the body using CSS?


publish posts immediately when updating

i'm looking for a way (maybe a plugin) to have a choice of just updating an **already published** post, and updating and republishing it with a current date and time basically, two options when editing: the standard **[Update]** and something like **[Update and republish immediately]** any ideas? thanks in advance!


How to add photos to WooCommerce gallery product

I tried to add it as attachment to the post but it doesn't appear. How to do this by code?               $attachment = array (             'post_mime_type' => "image",             'guid' => $url,             'post_parent' => null,             'post_title' => $imageTitle,             'post_content' => ''      );          $thumb_id = wp_insert_attachment ( $attachment, $file, $post_id );      i'm trying to add products by code and there photos from remote server but i cant find how do i add photo to the product gallery


List only child categories a post is in, of a specific parent category

Either this is harder than it needs to be or I am just not understanding WordPress/PHP very well :( All I want to do is show the child/sub categories of a specific parent category...but only if the post is in those subcategories. Specific example: I am building a wine reviews website and these are the categories:   * **Brand**     * Subcategory 1     * Subcategory 2     * etc.   * **Region**     * Subcategory 1     * Subcategory 2     * etc.   * **Grape**     * Subcategory 1     * Subcategory 2     * etc. The parent categories will never change, and every post will have at least 1 subcategory selected under each parent, so in the LOOP I can just list the parents by name. But I am needing to dynamically output the subcategories, something like this:               Brand: <?php list_post_subcategories_of('brand'); ?>     Region: <?php list_post_subcategories_of('region'); ?>     Grape: <?php list_post_subcategories_of('grape'); ?>      Is there any easy way like this? It seems like this should be a basic function in Wordpress? I've looked at the functions 'get_categories' and 'in_category' but they don't seem to be able to do this.


Category/Taxonomy Template not loading

I read countless topics and searched alot of codex pages for that problem but I just don't get it. My category template isn't being loaded. Instead, only the index.php comes up. It doesn't matter if I change the filename to category-{id}.php or category-{slug}.php. Even with it being called archive.php only the index.php comes up. (btw., on a different note, I have a specific archive template for the later mentioned custom post type type called archive-arbeit.php that works, but if I rename that file to archive.php it doesn't...just if that helps) I use a WIP theme I built from scratch with a custom post type that I register in functions.php. Relevant args are 'has_archive' => 'arbeiten' ('arbeit' is the name of the post type) and 'taxonomies' => array('category'). I have a set of sample entries of that post type that are assigned to one or multiple of the categories in the std. 'category'-taxonomy. Just so you know, I also hard-flushed the rewrite rules by calling the appropriate function in header.php. Didn't help. Here's my .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 WordPress      Just to give you a good idea of how I want this to work:               / -> frontpage     /arbeiten/ -> archive for my cpt     /arbeiten/categoryxy -> all posts of cpt within categoryxy     /arbeiten/postname or arbeiten/categoryxy/postname -> single post


unlink() doesn't delete the uploaded file

I'm using this code in my plugin to add an extra field to the user profiles so that the user can upload an image. It uploads the file perfectly but the only problem is the part that has to delete the previous uploaded image doesn't work. This is my code:               <?php      add_action( 'show_user_profile', 'my_show_extra_profile_fields' );     add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );          function my_show_extra_profile_fields( $user ) {      ?>

             Upload your profile photo
                 <input type="file" name="profile_photo" id="profile_photo" />                 <input type="hidden" name="action" value="save">                 <input type="submit" name="submitprofilephoto" id="submitprofilephoto" class="button" value="بارگذاری">
                                  <?php                 $author_profile_photo = get_author_profile_photo($user->ID);                 if(is_array($author_profile_photo)):                 ?>                     <a href="<?php echo $author_profile_photo["url"];?>" target="_blank">                         <img src="<?php echo $author_profile_photo["file"];?>" height="100" width="100" />                                      <?php                 endif;                 ?>

          <?php      }          function get_author_profile_photo($user_ID) {          $author_data = get_the_author_meta( 'profile_photo', $user_ID );     $uploads = wp_upload_dir();     $author_data["file"] = $uploads["baseurl"] . $author_data["file"];     return $author_data;     }          add_action( 'personal_options_update', 'my_save_extra_profile_fields' );     add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );          function my_save_extra_profile_fields( $user_id ) {          if ( !current_user_can( 'edit_user', $user_id ) )         return false;          $upload=$_FILES['profile_photo'];     $uploads = wp_upload_dir();     if(isset($_POST) && $_POST['submitprofilephoto']!='') {          if ($upload['tmp_name'] && file_is_displayable_image( $upload['tmp_name'] )) {                      // handle the uploaded file                 $overrides = array('test_form' => false);                 $file=wp_handle_upload($upload, $overrides);                 $file["file"] = $uploads["subdir"]."/".basename($file["url"]);                      // Setup the array of supported file types. In this case, it's just Images.                   $supported_types = array( 'image/jpeg', 'image/pjpeg', 'image/png' );                        // Get the file type of the upload                   $arr_file_type = wp_check_filetype(basename($upload['name']));                   $uploaded_type = $arr_file_type['type'];                        // Check if the type is supported. If not, throw an error.                   if( $file && in_array($uploaded_type, $supported_types) ) {                       if($upload['size'] > 204800) {                          wp_die('ERROR: Maximum size allowed is 200KB.');                     }                          //remove previous uploaded file                     $author_profile_photo = get_author_profile_photo($user_id);                     @unlink($author_profile_photo["file"]);                     // I even tried unlink without the @ and it still doesn't delete the file!                          update_user_meta( $user_id, 'profile_photo', $file );                  } else wp_die('ERROR: Allowd image formats are JPEG, JPG and PNG.');              } elseif (!file_is_displayable_image( $upload['tmp_name'] )) wp_die('ERROR: The file you selected is not an image!');     }     }     ?>      Where or what is the problem?


User is not being deleted from wordpress admin dashboard

I have a wordpress blog and I'm trying to delete a certain user from my admin dashboard. But when I delete this specific user and refresh the page, he remains on the users list. The only thing that changes is his role (changes from editor to none). This is the only user with this behavior, I can delete all the other users normally. Does anyone know anything about this? Thanks a lot!


Wordpress Custom post query sorting does not work

I created a custom WP query to collect products that have 3 different taxonomy values in them and sorted them by price using the following:               $my_products = new WP_Query(                 array(                     'orderby' => 'meta_value',                     'meta_key' => 'regular_price',                     'order' => 'ASC',                     'paged' => $paged,                     'post_type' => 'product',                     'tax_query' => array(                         'relation' => 'AND',                         array(                             'taxonomy' => 'pa_width',                             'field' => 'slug',                             'terms' => $width),                         array(                             'taxonomy' => 'pa_aratio',                             'field' => 'slug',                             'terms' => $aratio),                         array(                             'taxonomy' => 'pa_dia',                             'field' => 'slug',                             'terms' => $dia)                     )));      The query returns results and is mostly fine but some the products appear out pof place - take a look at http://www.tyrebroker.ie/your- search/?width=245&aratio=40&dia=18 I dont know how to resolve this as I have trawled through the database and product details to see what could be causing the issue. Any suggestions - thanks


How to query posts of standard post format. For real

So, I have been looking EVERYWHERE. I tried every kind of combination. So far, nothing. I have to query two posts to show on my front page, of post post- type, not in one category but, most importantly, of the standard post-format. I work with wp 3.9.1. This is the syntax I use:               $query = new WP_Query( array(                 'post_type' => 'post',                 'cat' => '-1',                 'posts_per_page' => 2,                 array(                     'taxonomy' => 'post_format',                     'field' => 'slug',                     'terms' => array( 'post-format-gallery', 'post-format-video' ),                     'operator' => 'NOT IN'                     )             ) );      It just does not work. I get two results, but the video and gallery formats are not processed out. I tried also the use of `tax_query => array (.....)` with no result at all. In the first case the `$query->have_posts` returns all posts of all formats. In the second case it returns no content at all.


Is it good practice to import/export a blog to test a redesign?

I am working on redesigning a fairly high profile blog. I suggested the best way to do that, rather than mockups, is to just upload their wordpress export to a new WP install on domain. That way they could see how any changes reflect the blog "live". Once they are good with design, they can just upload and use the theme. Is this recommended? Any potential issues I may be unaware of? The other issue is this particular blog has about 500 posts but the categorization and tagging is a mess and needs to be re-done to be effective. If I did this on my side with an export, it might take a week or so. They client would then have to import the fixed export... right? Any issues with that? What would happen to the content that was created in the previous week? Would a next export have to be created and the previous weeks content be joined to the older, fixed, export?


WP_Query display next custom post from today's date

I have a calendar plugin that uses custom posts types to create events. There are several custom fields that allow me to create various and seemingly unlimited post queries. The one I'm currently focus on is the field containing the "event start date", titled = evcal_start_date. What I need to do is display the next upcoming event from today, and this has become a bit of a challenge. Current WP_query;               <?php         $currentdate = date("m/d/Y",mktime(0,0,0,date("m"),date("d"),date("Y")));              $my_query = new WP_Query(  array ('showposts' => 1,         'post_type' => 'ajde_events',         'meta_query'=> array(         array(         'key' => 'evcal_start_date',         'meta_compare' => '>',         'value' => $currentdate,         'type' => 'DATE',         )),         'meta_key' => 'evcal_start_date',         'orderby' => 'meta_value',         'order' => 'ASC'         )         );              while ($my_query->have_posts()) : $my_query->the_post();         $title = get_the_title();         $date = get_post_meta($post->ID, 'evcal_start_date', true);              endwhile;      ?>
<?php echo $title; ?>
     <?php echo $date; ?>
      I've made sure that the formatting of $currentdate matches that of evcal_start_date. It is stored as "5/25/2012". I can't guarantee my client will always create posts in order and that is why it's imperative to use the custom field of the event's start date. I would really appreciate any help. Have a wonderful Memorial Day weekend!


Search form not finding content in template page

I created some template pages on my wordpress theme and when I'm trying to do search for some words it returns Nothing Found. When I tried to search for words from the posts or normal pages(Not template pages) it founds it normally. I added php file to the theme folder and I coded in:                <?php     /*     Template Name: example.php     */     ?>      Now whatever I write in this file example.php (links or paragraph) can't be found by the search form. What do I need to do?


Redirecting to new URL structure and 301

I had links like `example.com/?location=boston` on my site. These were indexed by Google. Due to obvious SEO reasons, I had to change the URL structure to `example.com/deals/boston`. The old URLs are there on Google results and redirect correctly to new URL. What I want to know is: while doing the redirect, is WordPress also doing a 301 header so that Google can update its indexes or there is something that I am supposed to do? Basically, I want Google to update its indexes i.e. replace `example.com/?location=boston` with `example.com/deals/boston`


exclude categories from search results

I have the following function, I need to exclude categories from it because it works across the site in several different places. How can I do that?               // allCategories(): return an array of categories to browse in heirarchy     public function allCategories() {         $return = array();         if ($this->category) {           $return = $this->catList($this->section->term_id);         }            return $return;       }                }      Thank you in advance.


Checking for 'gallery' shortcode using strpos always returns false

I want to conditionally enqueue a script and stylesheet depending on whether the `[gallery]` shortcode is used in posts. Here is how I am doing it (based on):               function doraemon_scripts() {              if( is_single() ) {                  if (strpos($post->post_content,'[gallery') === false){             } else {                 wp_enqueue_style( ... );                 wp_enqueue_script( ... );             }              }          }     add_action( 'wp_enqueue_scripts', 'doraemon_scripts' );      But the problem is, the stylesheet and script aren't being enqueued, as it seems, `strpos` is always returning false. What could I be doing wrong here?


cleaning up safely wordpress wp_postmeta table

In a effort to facilitate maintenance of my site, optimise page loading , and also helping out db migration , i am trying to cleanup the wordpress database of my site. i ahve realised the wp-postmeta table itself weights 240 Mo !! How could i clean this out, distinguish what is required to what is not and safely remove useless content?


Getting custom post type info using get_adjacent_post

This is an example of how I'm grabbing images from my custom post type now, using `query_posts();`               // query_posts stuff made up here.     $my_array = get_custom_field('image:to_array', 'to_image_array');      // $my_array is now all my images from that post.      What I want to do is pull out an image from a custom post type using get_adjacent_post(). When I print out the adjacent post's info, I don't see anything useful for pulling out my images from this post type. Here is a print_r of the adjacent post.               (         [ID] => 185         [post_author] => 1         [post_date] => 2012-04-11 18:51:22         [post_date_gmt] => 2012-04-11 18:51:22         [post_content] => content         [post_title] => the title         [post_excerpt] =>          [post_status] => publish         [comment_status] => open         [ping_status] => closed         [post_password] =>          [post_name] => the-title         [to_ping] =>          [pinged] =>          [post_modified] => 2012-04-12 17:37:49         [post_modified_gmt] => 2012-04-12 17:37:49         [post_content_filtered] =>          [post_parent] => 0         [guid] => http://thewebsite.com/?post_type=photo_group&p=185         [menu_order] => 0         [post_type] => photo_group         [post_mime_type] =>          [comment_count] => 0     )      Is there a way to pull out my custom post type's images this way?


Need idea: custom post type and custom meta

I'm working for a WordPress Plugin. The plugins is for library management, for my university. I created custom post types with taxonomies for keeping books information stored. Now I want to create another post type which will keep records for books and and users. For instance, I'll create new post type called "Issue". There should have three fields. One would be title. Another two will be dropdown, one will show all book (I've already created custom post type called books, I want to use those here, automatically) lists as dropdown. Another dropdown field will show list of students (for this I've created a new user role called student, I want to use those user who are registered as student). So my questions are   1. How can I show all users (selected role) as dropdown in custom meta box and    2. How can I show all books (Custom post type I created) as dropdown in custom meta box How can these be done? I can code, need instruction ;)


Echoing function into Wordpress NextGen gallery

Is there anyway to echo a function into a wordpress shortcode? heres my code:               <div id="subscription">     <?php echo do_shortcode('[nggallery id=$ID]');?>     </div>        $ID is a function that grabs a number generated in the url Thanks


How to group meta boxes on the post edit page

I suspect that this is not possible right now, but oh well.. I'll ask, maybe one of you has some intersting thoughts to share. So let's say we have the following taxonomy terms meta-boxes on our post edit page :   * Team accounting   * Team supergurus   * Countries   * Team developers   * Favorite ice cream Wouldn't it be nice to be able to groupe the three "Team" meta-boxes into one "container" box called "Teams" ? This would be just and empty meta-box with a title, containing the three taxonomy meta-boxes. The goal is to be more user friendly and keep the similar meta-boxes grouped together (it can become really confusing when you have a lot of taxonomies) Do you think this is doable ?


Plugin that resets database and deletes all content, plugins

Is there any plugin that can immediately return a site to how it looked when just installed, including removing all extra db entries, themes and plugins installed etc?


Change Metabox Title

Anyone know of a way to change the title of the core Wordpress metaboxes on a post edit screen? I'm trying to alter the title of the "Featured Image" metabox and have found a way to edit the contents (via *admin_post_thumbnail_html*) but not the title itself.


If you were to start using a Wordpress framework today, which one would you use?

Today, there are a ton of WP frameworks out there. When I first started using one, there were only 3 or 4, and I picked Hybrid. My (yearly) hybrid license expired again, so I decided to take a look around. There are way more options now. I am not concerned with drag and drop child theme building capacity. I dont mind paying. Most important is standards compliance, HTML5, SEO, mobile version and an active community. Decent availability of child themes is a plus. We dont always have the resources/desire to build everything from scratch. I already know Hybrid, and I am taking a like to Genesis. **What are your experiences with the frameworks out there and which one would you recommend?** PS: Sorry, there is no need to cite Thesis: I have an aversion to the way it is marketed. Please dont try to convince me otherwise, ok?


Loading scripts on specific page

I tend to place my wp_enqueue_scripts hooks on my functions.php but this ends up piling up scripts across my site. Which makes more sense? # 1:               function load_slider(){       global $post;       if($post->ID == 11746){ //  Load slider on home page         wp_register_script('start-slidorion', get_bloginfo('stylesheet_directory') . '/js/slidorion/start.js', array('slidorion', 'jquery','easing') );         wp_enqueue_script('start-slidorion' );       }     }      add_action('wp_enqueue_scripts', 'load_slider');      # 2:               function load_slider(){         wp_register_script('start-slidorion', get_bloginfo('stylesheet_directory') . '/js/slidorion/start.js', array('slidorion', 'jquery','easing') );         wp_enqueue_script('start-slidorion' );     }      global $post;     if($post->ID == 11746){ //  Load slider on home page         add_action('wp_enqueue_scripts', 'load_slider');     }


Adding custom field and querying from post table

I've been trying to figure this out for a while now. So I'm trying to add a custom field call "counter" to every single post. I try simply inserting the field "counter" to the post table. Every time a user clicks a button on the post, it increments the counter So far so good. But now the tricky part is being able to get back the information with WP_Query. I want to do a custom query for posts where the counter is greater than 0, loop through the posts, and display them with template tags. If i were to write an sql stamens it would look like this               $query = "SELECT * FROM $wpdb->post WHERE counter > 0";      But I can't do a normal SQL query because then I won't have access to template tags such as Wordpress's "show next page | show older page" template tags. I'm not looking for a plugin but I'm trying to find a way that i can add a field to the post table and be able to query the posts base on the custom fields, loop through the result, and display the information about the post. If you guys have any suggestions, I would really appreciate it. Note: Am i suppose to add the custom field to post meta? Looking at the SQL table, it doesn't seem like a right place to do it...


Limit the amount of main pages

Hay, i have a site which has been designed to only have 8 main pages across the main navigation, however these pages can have as many subpages as they want. Is there a way to limit the amount of main pages an admin can create?


Can someone (Support of my themeprovider) get access to my server If I send them my admin login?

I have bought a WP theme from a huge provider (themeforest). But it has a lot of bugs. The support asked me to send my WP Admin Login/Password. What risk does this have? I know the supportstaff will have full access to the WP installation, with the WP admin credentials. this is ok for me. But what about the server this instances is running on? Are there any changes that they would theoretically get access to the server? This is a no-no. As the sever hosts a lot of confidential stuff. My Guess: Most likely yes, they could get access? (As far as I can tell they could input some php code in the wp-code-editor that opens up a shell or reads some files in the system?) Or am I wrong? thanks!


How to order posts by one custom field and filter them by another one?

In my WordPress blog I have events I want to order and filter by custom fields. The order should be done by the custom field "event_date_end" which means that every event that is still running should be displayed. To order the events I use a second custom field "event_date_start". So an event, that start on the 10th and ends on the 20th it should be displayed until the 20th but should be order next to all other events starting at the 10th. I use Thematic as a parent theme and so I use the query_posts() function adding both rules as parameters. This is how I use it in the index loop:               function my_index_loop($content) {         global $query_string;         query_posts($query_string         // filter by event_date_end         ."&meta_key=event_date_end&meta_compare=>=&meta_value=".date('Y-m-d')         // order by event_date_start         ."&meta_key=event_date_start&orderby=meta_value&order=ASC");      }     add_filter('thematic_indexloop', 'my_index_loop');      Now the posts are correctly ordered, but also the filter will be done on the "event_date_start" value. So an event, that has been started yesterday and still going on, will not be displayed. If I switch the order of the "filter" and "order" parts, I will see all events, but an event starting at the 10th and ending at the 20th will be placed to all event on the 20th. I know I can create queries in SQL myself, but will they work with Thematic? And how do I have to write statements for archive, category, tag listing? **The solution** : After reading the mentioned pages, I found the following solution. I had to use some raw SQL and add them through filters within the specific loop filter. These are the functions I added:               function my_loop_where($where){         global $wpdb;         $where .= " AND pm_where.meta_value >= '".date('Y-m-d')."'";         return $where;     }          function my_loop_join($join){         global $wpdb;         $join .= " LEFT JOIN " . $wpdb->postmeta . " AS pm_order ON (" . $wpdb->posts . ".ID = pm_order.post_id AND pm_order.meta_key = 'event_date_start')";         $join .= " LEFT JOIN " . $wpdb->postmeta . " AS pm_where ON (" . $wpdb->posts . ".ID = pm_where.post_id AND pm_where.meta_key = 'event_date_end')";         return $join;     }          function my_loop_order(){         return 'pm_order.meta_value ASC';     }      And than I simply added filter to these functions within the e.g. index loop:               function my_index_loop($content) {         global $query_string;         add_filter('posts_where', 'my_loop_where' );             add_filter('posts_join', 'my_loop_join' );         add_filter('posts_orderby', 'my_loop_order' );         query_posts($query_string . "&meta_key=event_date_end&meta_compare=>=&meta_value=".date('Y-m-d')/*."&meta_key=event_date_start&orderby=meta_value&order=ASC"*/);     }     add_filter('thematic_indexloop', 'my_index_loop');      Now I can easily use that filter and order on the index and category loops but keep the default "log style" filter and orders on the archive pages.


greater flexibility in targeting images attached to page

Right now I have several images attached to my page, but I only want four of them to display in a slideshow, and then the other ones are referenced within the page's visual/html box. The problem is currently all my images attached to the page have a post type of "attachment", and this code iterates through all of them:                   <?php if ( have_posts() ) : while ( have_posts() ) : the_post();              $args = array(          'post_type' => 'attachment',          'numberposts' => -1,          'orderby'=> 'menu_order',          'order' => 'ASC',          'post_mime_type' => 'image',          'post_status' => null,          'post_parent' => $post->ID         );               $attachments = get_posts( $args );           if ( $attachments ) {            foreach ( $attachments as $attachment ) {             echo wp_get_attachment_image($attachment->ID , 'full','',array('rel' => $attachment->post_name));            }           }         endwhile; endif; ?>      My question is how can I distinguish the attachments so that it only queries some of them? For example, I tried adding the post_name attribute to the $args array but that didn't do anything. Second, when I add img tag to the visual/html content editor, and then I add a src attribute, and then I go into the visual content editor, I want a non- programmer to click on the img box, which prompts them to edit the image, and then under source it is requiring them to add the full url path, and I dont think that's intutive to a non-programmer. Is there an easier way for them to add image via content editor?


Plugin for sharing on social sites?

I'm looking for a plugin that enables sharing an article on sites like Facebook, Twitter and LinkeIn. One catch is that I want a plugin that respect the privacy of the user and doesn't include trackware/spyware on the page. Can anyone recommend a good plugin for this? Thank you!


Who are the most trusted plugin developers?

_Note: Please vote on the question, and any answers you find useful by clicking on the UP arrow on the left hand side of the question or answer._ There are so many plugins out there. Whose plugins can we always trust? Please share a list of completely reliable plugin authors, along with links to their plugins pages. This question is modeled on http://wordpress.stackexchange.com/questions/1567/best-collection-of-code-for- your-functions-php-file


Including Custom Post Types in "Recent Posts" Widget

I'm able to easily include my custom post types into my main loop by making small adjustments with `query_posts()`, but I'm not sure how I would go about including custom post types in the "Recent Posts" sidebar widget (or any of the other widgets, for that matter). How should I go about expanding "Recent Posts" scope to include more than just the native post type?


Create a widget that allows text input

I need to create a simple widget that has a text input field. I need the widget to create the markup below...

CONTENTS OF THE TEXT INPUT HERE

       I've started the process of stubbing out the widget with the code below. I'm just not shure how to code the my_avatar() function...               function my_avatar()     {     //Widget markup goes here. How to pull the widget text entry?          }          register_activation_hook(__FILE__, 'my_avatar');          class My_Widget_Avatar extends WP_Widget {         function My_Widget_Avatar() {             $widget_ops = array( 'classname' => 'widget_avatar', 'description' => __( "My Avatar Widget" ) );             $this->WP_Widget('my_avatar', __('My Avatar'), $widget_ops);         }     }          add_action('widgets_init', create_function('', "register_widget('My_Widget_Avatar');"));


WordPress author.php template does not work with custom permalink structure! Help!

I just discovered a weird problem in my WP. The author archive (author.php) returns 404 error ONLY if i use custom permalink structure like /%postname%/ it shows up fine when I use the Default permalinks. What could be causing that please?


Plugin from WordPress.com for comment notification...available?

WordPress.com has a rather cool feature when you add comments. The two features are:                  [x] Notify me of follow-up comments via email.        [x] Notify me of new posts via email.      Is this plugin available somewhere so that I can include it on my privately hosted blog?


Link to the next/prev posts in index loop in same category?

Is it possible to link to the next/prev posts in index.php with `query_posts('cat=56');` before loop?               <?php query_posts('cat=56');      if (have_posts()) : while (have_posts()) : the_post(); ?>          next post title          <?php the_title(); ?>          previous post title          <?php endwhile; ?>     <?php endif; ?>      next/previous_post_link with TRUE doesn't work..               <?php next_post_link('« %link','%title', TRUE) ?>     <?php previous_post_link('%link »','%title', TRUE) ?>      **UPDATE** I need to show in home page only selected post (selected category) with next/prev title of post in the same category (selected).![enter image description here](http://i.stack.imgur.com/JuKwj.png) In this image you can see the slider with caption. In this case, the next post is PIAZZALI PUBBLICI, but it does not belong to a selected category: the next image post in the slider it's another one.


Is there an atomic way to update_option in Wordpress (to ensure data integrity)?

I want to update an option which is an array by adding a new value, but there's no atomicity or guarantee of data integrity. **EXAMPLE**               //Get the option value (an array)     $val = get_option( "some-option" );          //Add to the array     $val[] = "something";          /** Here, another session might already have it and is calling "update_option" */          //Save back (this overwrites whatever that other person did)     update_option( "some-option", $val );      Is there anything in wordpress that offers atomicity?


Retrieving 3 latest post from each of 5 different custom post types

I have 5 different custom post types. I am showing 15 latest post from them on my home page using following query:               $query = new WP_Query( array (                  'posts_per_page'   => 15,                  'post_type' => array ( 'cpt1', 'cpt2', 'cpt3', 'cpt4', 'cpt5' )                )      );      It works fine, shows latest 15 posts from these 5 custom post types. But problem is, there are too many updates on **cpt1** and **cpt3** (around 8-10 posts per day on each post type). So on home page, I rarely find posts from **cpt2/4/5**. So I want to show latest 3 posts from each post type (total 15 posts) using date as order by (sorting). So 3 posts from each post type will be visible and sorted based on date among all 5 post types. But I could not find any good solution for this. What came so far in my mind is, running 5 queries and saving them to an array, and then sort them. Is there anyway I can do this using only one query, instead of 5 queries?


Php file that doesn't recognize wordpress functions

I have a custom contact form that I am trying to process in other file: The form:               <form method="post" action="<?php echo get_template_directory_uri() . '/templates/contact.php' ?>" name="contactform" id="contactform">
                         <fieldset>                             <input name="name" type="text" id="name" size="30" value="" placeholder="Name" />
                             <input name="email" type="text" id="email" size="30" value="" placeholder="Email" />
                             <input name="phone" type="text" id="phone" size="30" value="" placeholder="Phone" />
                         </fieldset>

                         <fieldset>                             <textarea name="comments" cols="40" rows="8" id="comments" placeholder="Message"></textarea>                             <button type="submit" class="btn btn-green-border btn-lg" id="submit" value="submit">Send Message</button>                             <input type="hidden" name="address" value="<?php echo $t_one_opt['contact_email'] ?>">                         </fieldset>
                 </form>      But in the processing file I can achieve to get options values. I am using the Redux Framework, and work fine in all the site. I have put the global varible, too. contact.php               <?php     if(!$_POST) exit;          global $t_one_opt;          $name     = $_POST['name'];     $email    = $_POST['email'];     $phone   = $_POST['phone'];     $comments = $_POST['comments'];               if(trim($name) == '') {         echo '
Please enter your name.
';         exit();     } else if(trim($email) == '') {         echo '
Please enter a valid email address.
';         exit();     } else if(trim($phone) == '') {         echo '
Please enter a valid phone number.
';         exit();     } else if(!is_numeric($phone)) {         echo '
Phone number can only contain digits.
';         exit();     } else if(!isEmail($email)) {         echo '
You have enter an invalid e-mail address,please try again.
';         exit();     }          if(trim($comments) == '') {         echo '
Please enter your message.
';         exit();     }           if(get_magic_quotes_gpc()) {         $comments = stripslashes($comments);     }               // Configuration option.     // Enter the email address that you want to emails to be sent to.     // Example $address = "joe.doe@yourdomain.com";          //$address = "example@themeforest.net";     //global $t_one_opt;     $address = $t_one_opt['contact_email'];               // Configuration option.     // i.e. The standard subject will appear as, "You've been contacted by John Doe."          // Example, $e_subject = '$name . ' has contacted you via Your Website.';          $e_subject = 'You\'ve been contacted by ' . $name . '.';               // Configuration option.     // You can change this if you feel that you need to.     // Developers, you may wish to add more fields to the form, in which case you must be sure to add them here.          $e_body = "You have been contacted by $name with regards to $subject, their additional message is as follows." . PHP_EOL . PHP_EOL;     $e_content = "\"$comments\"" . PHP_EOL . PHP_EOL;     $e_reply = "You can contact $name via email, $email or via phone $phone";          $msg = wordwrap( $e_body . $e_content . $e_reply, 70 );          $headers = "From: $email" . PHP_EOL;     $headers .= "Reply-To: $email" . PHP_EOL;     $headers .= "MIME-Version: 1.0" . PHP_EOL;     $headers .= "Content-type: text/plain; charset=utf-8" . PHP_EOL;     $headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL;          if(mail($address, $e_subject, $msg, $headers)) {              // Email has sent successfully, echo a success page.              echo "<fieldset>";         echo "
";         echo "
Wohoooo ! Well done
";         echo "
Thank you $name, your message has been submitted to us.
";         echo "
";         echo "</fieldset>";          } else {              echo 'ERROR!';     }      Neither it doesn't recognize Wordpress functions. Why is this file "out" of WordPress?


Change locale at runtime?

I wonder, is there a way to change the locale at runtime using WordPress ? What I mean, is, I have create a custom URL in order to create an XML file with data for integration with another web application. The URL has also a language portion. Lets say this is my URL http://www.mysite.com/custom/url/en where last portion of the URL is the english language. In that case what I like is the WordPress to generate an English XML. But how can I instruct the WordPress to change the locale in that point of the execution ? Note that I have to change the locale because I use also system variables that are translated, such us __(), _e() and so on.


Do I need a nonce field for every meta box I add to my custom post type admin?

I'm currently working on the admin page of my custom post type, and I got stuck on deciding whether to add a nonce field again for the second metabox or not. I'm very new to custom post types, and searching online about this doesn't really yield that many results. Any thoughts? Thanks.


Custom Single Page Portfolio Theme

I'm thinking about creating single page portfolio theme, but I'm a little confused on how this would be done based on the different sections on the single page. I'll explain what I would like to do and hopefully someone can help me figure this out. I'm just looking for guidance on what I should do to handle the different sections (maybe custom post types?)   1. Slider   2. Portfolio ( 4 Columns -- -- -- -- )   3. About ( 2 Columns -- ------)   4. Contact ( 2 Columns ------ -- )   5. Footer / Social Links If it is too much work for me I'll just pay to have this created, so if interested please leave a contact email and I will get back to you Thanks!


What is the name of the theme/plugin used for Wordpress Answers

What is the name of the theme/plugin that is used here for "WordPress answers"? thanks!


subscribe to wp through a Faceboo app

Has anyone heard of a way to get allow people to subscribe to a wp blog, while in Facebook, such as through a Facebook app? Basically, I am looking for a widget or similarly functioning feature that I can embed into a page of a Facebook application that has an subscribe form for a particular wordpress blog.


Custom Field, add gallery id

Is it possible to add a gallery id like [gallery ids="9"] to custom field using the media editor in wordpress? I have attached a media function to a specific custom field but are not able to insert galleries, only pictures are possible. I've tried to look at the wp.media.editor but can only see "attachment" and "link" as alternative functions.               (function() {       jQuery(function($) {         return window.trigger_media_upload = function(id) {           var $container;           window.wpActiveEditor = null;           $container = $('#' + id + '_container');           $('#trigger_upload_' + id).off('click');           $('#trigger_upload_' + id).on('click', function(e) {             var send_attachment_bkp;             e.preventDefault();             send_attachment_bkp = wp.media.editor.send.attachment;             wp.media.editor.send.attachment = function(props, attachment) {               $container.find('.custom_media_image').attr('src', attachment.url).removeClass('none');               $('#' + id).val(attachment.url);               return true;             };             return wp.media.editor.open();           });           return true;         };       });          }).call(this);


Select from wp_post and multiple meta_value from wp_postmeta

My lack of SQL skills has stopped me in my tracks here. I'm trying to select post_id, post_title and two postmeta values - the first has the meta_key of 'search_country' and the second a meta_key of 'search_region'. I think I have a working solution for retrieving just the search_country:                $querystr = "            SELECT $wpdb->posts.ID as id, $wpdb->posts.post_title as title, $wpdb->postmeta.meta_value as country            FROM $wpdb->posts, $wpdb->postmeta            WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id             AND $wpdb->postmeta.meta_key = 'search_country'             AND $wpdb->posts.post_status = 'publish'             AND $wpdb->posts.post_type = 'films'            AND $wpdb->postmeta.meta_value IS NOT NULL            ORDER BY $wpdb->posts.post_title ASC         ";              $festivals = $wpdb->get_results($querystr, OBJECT);      However, I dont know how to change this to get the search_region also? I've never got on with SQL :)


Call Featured Image from Parent Page

I am working on a site and each page group has its own featured image. I am trying to do a conditional statement in the header but not sure how to check for the parent page's featured image.               <?php      if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.       the_post_thumbnail();     } else{?>              <img src="<?php bloginfo('template_url')?>/images/BANNER-DEFAULT.jpg"/>               <?php     }     ?>      I want it to preform like:               <?php      if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.       the_post_thumbnail();     }           if ( ?????? { // check if the parent page has a Post Thumbnail assigned to it.       the_post_thumbnail();          }else{?>              <img src="<?php bloginfo('template_url')?>/images/BANNER-DEFAULT.jpg"/>               <?php     }     ?>      Can anyone help with this? I am also considering calling in the banner on the page templates and not the header, but I still need a way to call in the featured image on the Parent Page.


using html as shortcode attribute

I have created a shortcode that retrives and displays top recommended posts based on a meta_key. There are different attributes, which all work, except for once where the content of the attribute is HTML. Complete code is:               function dot_irt_top_posts ( $atts ) {          // get our variable from $atts     extract(shortcode_atts(array(         'before' => '
',         'after' => '
',         'number' => '10',         'post_type' => 'post',         'year' => '',         'monthnum' => '',         'show_count' => '1',     ), $atts));          global $wpdb;          $request = "SELECT * FROM $wpdb->posts, $wpdb->postmeta";     $request .= " WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id";          if ($year != '') {         $request .= " AND YEAR(post_date) = '$year'";     }          if ($monthnum != '') {         $request .= " AND MONTH(post_date) = '$monthnum'";     }          $request .= " AND post_status='publish' AND post_type='$post_type' AND meta_key='_recommended'";     $request .= " ORDER BY $wpdb->postmeta.meta_value+0 DESC LIMIT $number";     $posts = $wpdb->get_results($request);          $return = '';               foreach ($posts as $item) {         $post_title = stripslashes($item->post_title);         $permalink = get_permalink($item->ID);         $post_count = $item->meta_value;              $return .= $before;         $return .= '' . $post_title . ' ';              if ( $show_count == '1') {             $return .= '' . $post_count . ' ';         }              //$return .= get_the_post_thumbnail($item->ID, 'showcase-thumbnail');         $return .= $after;          }     return '
' . $return . '
';           }      add_shortcode('irt_top_posts','dot_irt_top_posts');      Now if I use a shortcode as below, the data is returned properly as list.:
          [irt_top_posts post_type='showcase' number='10']
      But if I set 'before' & 'after' attributes then they are displayed as content instead of being executed as html:
          [irt_top_posts post_type='showcase'  before='
' after='
' number='10']
      Do I need some other functions to disable escaping HTML?


How to get all unique categories for posts in loop?

I'm looking to get a plain list of the unique categories in a custom loop (only categories for the posts in the loop). I've been fumbling with some code for a bit and here's what I've got:               <?php         $args = array(             'post_status'=>'publish',             'post_type'=>'post',             'posts_per_page'=>-1         );         $get_posts = new WP_Query();              $get_posts->query($args);         if($get_posts->have_posts()) {              $cats = array();         while($get_posts->have_posts()) { $get_posts->the_post();                      $post_categories = wp_get_post_categories( get_the_ID() );                 $i = 0;                 foreach($post_categories as $c){                     $cat = get_category( $c );                     $cats[$i] = $cat->slug ;                     $i++;                 }                  } //endwhile             $result = array_unique($cats);            print_r($result);              } //endif         wp_reset_postdata();     ?>      This will put each posts categories into an array and I can print that out. But I want to merge each posts array of categories, remove duplicates (so there's only one instance of each unique category), and then be able to print it out. Essentially what I'm wanting to accomplish is to have a drop down for these categories to use for being able to sort by a particular category by refreshing the loop with that selected category. I can handle the rest, I just need to get this list of unique, unduplicated categories for all posts in a loop. Anybody have any ideas? Many thanks, Jonah


Complex meta query with 3 keys

I think the problem essentially relates to sql query structure and I am not an expert.... I need to search for posts (custom post type) by 2 parameters:   1. pd_city   2. pd_country Please note that meta_query relation is 'OR' so if either of above two is LIKE we should have some results. Third key (is_sponsored) is used to sort posts! It can be 1 or 0 and posts whose "is_sponsored" value equals to 1 should be listed on top. So here's the WordPress thing:                   $sfp_query_args = array(             'sfp_complex_search' => 'yeap',              'tax_query' => array( array( 'taxonomy' => 'sfp_post_category', 'terms' => $term_id ) ),             //'meta_key' => 'is_sponsored',             'post_type' => 'sfpposts',             'post_status' => 'publish',             'showposts' => (int)$per_page,             'paged' => $paged,              'meta_query' => array( 'relation' => 'OR',                      array( 'key' => 'pd_city', 'value' => $sfp_search_meta, 'compare' => 'LIKE' ),                      array( 'key' => 'pd_country', 'value' => $sfp_search_meta, 'compare' => 'LIKE' ),                      array( 'key' => 'is_sponsored' )                     )         );     $sfp_search = new WP_Query( $sfp_query_args );      I also need to filter results with "posts_orderby" in order to get those sponsored to the top:               add_filter( 'posts_orderby', 'sfp_modify_search' );     function sfp_modify_search( $orderby ) {         if( !is_admin() && is_page( $this->options[ 'sfp_page_entries_search' ] ) ) {             global $wpdb;             $orderby = " CASE WHEN mt2.meta_value = 0 THEN 1 END, $wpdb->posts.post_date DESC ";         }         return $orderby;     }      The real problem relies in fact that with this query ALL POSTS from "sfp_post_category" are returned, not only those who match "pd_city" or "pd_country" because ALL POSTS HAVE "is_sponsored" meta key (and value set to 1 or 0). Once again: "is_sponsored" is needed for sorting! When var_dump               var_dump( $sfp_search->request );      ...WordPress' sql looks like this:               SELECT SQL_CALC_FOUND_ROWS wp_posts.ID      FROM wp_posts      INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)      INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)      INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id)      INNER JOIN wp_postmeta AS mt2 ON (wp_posts.ID = mt2.post_id)      WHERE 1=1      AND ( wp_term_relationships.term_taxonomy_id IN (77) )      AND wp_posts.post_type = 'sfpposts'      AND (wp_posts.post_status = 'publish')      AND ( (wp_postmeta.meta_key = 'pd_city'      AND CAST(wp_postmeta.meta_value AS CHAR)      LIKE '%something%')      OR (mt1.meta_key = 'pd_country'      AND CAST(mt1.meta_value AS CHAR)      LIKE '%something%')      OR mt2.meta_key = 'is_sponsored' )      GROUP BY wp_posts.ID      ORDER BY CASE WHEN mt2.meta_value = 0 THEN 1 END, wp_posts.post_date DESC      LIMIT 0, 10      How do I eliminate all posts that do not match "pd_city" or "pd_country" from results?


Simple form validation for custom post type in front end. Not working

So everything is working fine except for the validation. The error messages don't display when the form is submitted empty and you can still submit the form when empty. I must be missing something really obvious. I've already spent a few hours scouring the web and have tried several fixes myself to no avail. Any help would be really appreciated.               <?php add_shortcode('testimonial-form', 'testimonial_form_sc') ?>          <?php function testimonial_form_sc(){ ?>

Send Us Your Testimonial
     <form id="add_testimonial" name="add_testimonial" method="post" action="" enctype="multipart/form-data">                        Name:         <input type="text" value="" name="username" style="display-block" />                   Testimonial:         <textarea id="description" tabindex="15" name="description" cols="80" rows="10"></textarea>              <input type="file" name="thumbnail" id="thumbnail">              <input class="small-button" type="submit" value="Send" id="submit" name="submit" style="display:block;"/>          <input type="hidden" name="action" value="add_testimonial" />     <?php wp_nonce_field( 'new-post' ); ?>     </form>
           <?php          if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&     $_POST['action'] == "add_testimonial") {          // Do some minor form validation to make sure there is content     if (isset ($_POST['username'])) {         $title =  $_POST['username'];     }      else {         echo 'Please enter your name';     }     if (isset ($_POST['description'])) {         $description = $_POST['description'];     }      else {         echo 'Please enter your testimonial';     }          // add the form input to $new_testimonial array     $new_testimonial = array(     'post_title'    =>   $title,     'post_content'  =>   $description,     'post_status'   =>   'publish',           // Switch this to draft if you want to moderate posts     'post_type' =>   'testimonial'  //post type to insert the post into     );          //SAVE THE POST     $pid = wp_insert_post($new_testimonial);          // Upload image for post thumbnail           if (!function_exists('wp_generate_attachment_metadata')){                 require_once(ABSPATH . "wp-admin" . '/includes/image.php');                 require_once(ABSPATH . "wp-admin" . '/includes/file.php');                 require_once(ABSPATH . "wp-admin" . '/includes/media.php');             }              if ($_FILES) {                 foreach ($_FILES as $file => $array) {                     if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) {                         return "upload error : " . $_FILES[$file]['error'];                     }                     $attach_id = media_handle_upload( $file, $pid );                 }                }             if ($attach_id > 0){                 //and if you want to set that image as Post  then use:                 update_post_meta($pid,'_thumbnail_id',$attach_id);             }          include 'validate-image-size.php';          //Redirect to the new post on save     $link = get_permalink( $pid );     wp_redirect( $link );          }} // End of the if statement that started the form and the end of the shortcode     [testimonial-form]          //post the post     do_action('wp_insert_post', 'wp_insert_post');`


How to populate custom field dropdown box based on prior selection?

I have two dropdown boxes for a search that uses custom fields and I need the second dropbown box to be populated depending on the results of the first box. So far I have:               <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">             <input type="text" name="s" id="s" value=""/>             <select id="stocktype" name="StockType">                 <?php                   //$make = $_GET['Make'];                   $metakey = 'StockType';                        $stocktypes = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = %s ORDER BY meta_value ASC", $metakey) );                   if ($stocktypes) {                     foreach ($stocktypes as $stocktype) {                       echo "<option value=\"" . $stocktype . "\">" . $stocktype . "</option>";                     }                   }                   ?>             </select>             <select id="make" name="Make">                 <?php                   //$make = $_GET['Make'];                   $metakey = 'Make';                        $makes = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = %s ORDER BY meta_value ASC", $metakey) );                   if ($makes) {                     foreach ($makes as $make) {                       echo "<option value=\"" . $make . "\">" . $make . "</option>";                     }                   }                   ?>             </select>             <select id="model" name="Model" onChange="handleSelection(value)">                 <?php                   //$make = $_GET['Make'];                   $metakey = 'Model';                        $models = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = %s ORDER BY meta_value ASC", $metakey) );                   if ($models) {                     foreach ($models as $model) {                       echo "<option value=\"" . $model . "\">" . $model . "</option>";                     }                   }                   ?>             </select>              <input type="hidden" name="post_type" value="vehicle" />             <input type="submit" id="searchsubmit" value="Search" />         </form>      I that works fine but right now the "Model" dropdown box is being populated with every model. I need it to only be populated with the models on the selection of the first dropdown box. For example, if the user selects "Toyota" than only the Toyota models will be shown in the second dropdown. I know I need to use ajax for this but I don't know how to set up the file that will be requested by ajax so that it contains logic. As far as js goes, I can do something like this:               <script>         jQuery(document).ready(function(){           $("#make").change(function() {             if ($(this).val() == 'TOYOTA') {                 $.ajax({                     url: "<?php bloginfo('template_url'); ?>/getModel.php",                     success: function(msg){                         $("#results").html(msg);                     }                });             }           });         });     </script>      How would I format the getModel.php file with specific database queries?


redirect to custom php template in wordpress plugin directory

i create a plugin that contain :   * index.php   * includes : index.php style.css i wanna create a plugin that when user active it , it redirect user to includes/index.html i wrote somthing like this               if(!function_exists(theme_redirect)) {      function theme_redirect () {        $options = get_option('option');         if(isset($options['redirect'])) {          $redirect = $options['redirect'];          }         else {          $redirect = false;          }               if($options['redirect'] == 1) {            include_once 'includes/index.php';            exit;          }         }        add_action (wp_header,'theme_redirect');       }      but when it redirected , it shows just html tag style never include i attached styles in includes/index.php with "> anyone can help me to include with another way?


Adding Media button to only pages

I have created a media button as such:                   // Create a media button for pages     function aisis_page_button_link(){         global $post_ID, $temp_ID, $iframe_post_id;         $iframe_post_id = (int) (0 == $post_ID ? $temp_ID : $post_ID);         $url = admin_url("/admin-ajax.php?post_id=$iframe_post_id&codes=aisis-page-codes&action=aisis_page_codes&TB_iframe=true");         echo "         ";     }          if(!empty($_GET['codes']) && $_GET['codes'] == 'aisis-page-codes'){         add_action( 'parse_request', 'parse_wp_request' );         echo parse_aisis_page_request($wp);         add_action( 'wp_ajax_asisi_page_codes', 'parse_aisis_page_request' );     }          function parse_aisis_page_request($wp){         aisis_require_page_code_display_page();         exit;     }          function aisis_require_page_code_display_page(){         require_once(CORETHEME_SHORTCODES . 'PageCodes.phtml');     }          add_action('media_buttons', 'aisis_page_button_link', 999);      Which then creates the desired effect of: ![enter image description here](http://i.stack.imgur.com/sQJ7i.png) **Note:** The above code is for the second "page" like icon. What I want to do is only have the above code run on pages, and only pages. that is edit and add new page. I know I would edit the `aisis_page_button_link()` function, and I can figure out how to make it appear for adding a new page, how ever how do you make it appear for editing a page?


Query & Sort Comments by custom comment meta

I added a basic "favorite/recommend" functionality for posts and comments to a wordpress site I'm working on. I'm storing the total numbers of comment "likes" in a custom comment meta field (update_comment_meta). Now I would like to query and sort comments based on this custom meta key and the corresponding values in order to display popular comments. Ideally I would like to be able to use parameters like "meta_key" and "order_by=meta_value_num" similar to WP_Query, but apparently comment queries don't support those. Do I have to use a custom written query to the database? If so, could anybody give me an initial push as to how to approach this?


Wrapping x posts in html without leaving empty html

So I'm trying to spit out unlimited numbers of posts for this wp_query, 6 at a time, each one being wrapped in `<dd>` so that it functions with my jQuery slider. The problem is, if I have exactly 6 posts, or 12 posts, I wind up with one empty `<dd></dd>` at the end. Am I doing this wrong, or is this a limitation to Wordpress?

             <?php $our_work1 = new WP_Query(array(             'post_type' => 'our-work',             'posts_per_page' => -1,             'meta_key' => 'featured_work',             'meta_value' => 'yes',             ) ); ?>                  <?php $count = 1; while ($our_work1->have_posts()) : $our_work1->the_post(); ?>

                  <?php if ($count % 6 == 0){ ?>

             <?php } $count++; ?>             <?php endwhile; ?>


Category related -> excerpt, title and thumb in sidebar on article page

I've done some research and tried different solutions but this snippet gets me the actual post content in sidebar, when on a single/article page, from the category the post belogs to. But I need to show the excerpt instead of the whole text and also a thumbnail and can't figure out how to add them. Any suggestions please?               <?php     $categories = get_the_category();     echo '

';     foreach ($categories as $c) {         if (strpos(get_permalink($post->ID), $c->slug) !== false) {             echo 'slug . '/">' . $c->name . '';             $current_cat = $c->cat_ID;         }     }     $posts = get_posts(array('cat' => $current_cat));     if (!empty($posts)) {         echo '
';         foreach ($posts as $p) {             echo '
ID) . '">' . $p->post_title . '
';             echo $p->post_content;         }         echo '
';     }     echo '

';     ?>       Or another approach maybe? Thank you.


margins in between pagination links

Any ideas how I could increase the spaces between the pagination links on my site? http://guvno.com/ I'm guessing adding some padding code to the custom.css maybe? I'm a beginner. Thank you for any advice.


Custom field as Slug

I would like to ask if it's possible for a custom field to become a slug. Like if I have a custom field of "when" whose value is "today", I would like the address of the post to be example.com/taxonomy/today I know slug is editable via permalink portion, but I plan on doing a frontend user posting, I want to try WP User Frontend Pro but it seems like it doesn't have the slug feature, but it has the custom field feature.. that's why I'm asking if it's possible for a custom field to become a slug. I've tried suggestions on other posts, nothing seemed to work.


Custom WP_Query with SQL directives for getting posts by authors and terms

I am making a custom page where I need to display posts from authors and terms (categories). I tried with the built in WP_query arguments but I am not getting the result I want. So I want to know how I can get all posts from X authors AND Y Categories (terms) using SQL directives and WP_Query. I already read the codex http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query but I still dont quite get how SQL works. I know the basics but I dont know how to link terms and categories, etc... Thanks in advance.


Infinite scroll repeats posts in custom loop in single.php

I'm feteching recent posts with infinite scroll in single.php. My single.php code looks like:               <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>     ...     <?php endwhile; /* end loop */ ?>     <?php wp_reset_query(); ?>     <?php get_template_part( 'recent-posts'); ?>      The recent-posts.php code is:               <? $page = (get_query_var('paged')) ? get_query_var('paged') : 1;     $this_post = $post->ID;     query_posts(array('post__not_in' => array($this_post), 'posts_per_page' => 9, 'paged' => $paged,));     ?>     <?php if (have_posts()) : ?>     <?php while (have_posts()) : the_post(); ?>     ....     <?php  endwhile; endif; ?>      Everythinhg thing is working except the infinite scroll repeats the first set of 9 posts again and againt when I scroll down. I check the course code and found that pagination has a problem. It put the paging the end of post url. I've tried by adding Wp_reset_query in single.php as you can see in above mentioned code, but it didn't work either.               <a href="http://mysite.com/2013/07/current-post-example/page/2/" class="next">


Remove W3 Total Cache minified files on custom page outside of WordPress

I have created a page outside my WP network install (following this info from css-tricks) The output of which is used for a Facebook business page tab as a Facebook app. It is working just fine, however I use W3 Total Cache on the site and noticed the output contains redundant (in this instance) minified JS files, is there a way to stop The W3 Total Cache plugin from hooking in & including these files? The output is minified, which is a good thing so ideally i'd like to keep the minified output without the js files as they are not required. Any help, tips or links appreciated, thanks in advance, Aaron :)


media_sideload_image with rewritten urls?

When I try to use media_sideload_image with a path like this http://placekitten.com/300/200, it gives me an error. That is because it don't know the filetype or the filename. Best way to upload the image?


Custom posts per page does not work with pagination

I have one page in my template where I would like to set a custom posts_per_page. Here is the code I have used:               <?php     global $query_string;     query_posts($query_string . '&posts_per_page=4');      if ( have_posts() ) : while ( have_posts() ) : the_post();     ...      Now this code limits only 4 items per page and shows pageinate_links below as I have written. However clicking on any other page will lead to a 404. If I take out the global and query_posts line then it works fine. This is the paginate_links function I am using:               echo paginate_links( array(         'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),         'format' => '?paged=%#%',         'current' => max( 1, get_query_var('paged') ),         'total' => $wp_query->max_num_pages,         'prev_text' => 'Previous',         'next_text' => 'Next',       ) );


Conditional tag in Widget Logic for checking if top level page or if subpage

I'm using the Widget Logic plugin to show widgets on certain pages using Wordpress Conditional Tags (or any general PHP code). What I would like to do is only show a widget on child pages, not top level pages. I tried both of the following but they both return true on all pages (so the widget shows on all pages):               global $post; return ($post->post_parent != 0);      and               global $post; return ( is_page() && $post->post_parent );      Note I tried this for testing and the widget displays on page ID 61 and its children, not just on its children as I was expecting:               global $post; return ($post->post_parent=="61");      Any tips? Thanks!


Horizontal drop down category with hover effect working

It will be difficult to explain what I need in words, so please see a live demo of the horizontal navigation menu here, http://cn.wsj.com/gb/index.asp I want to replicate it for wordpress categories. The top menu should always show parent categories, and the drop down should show children of the parent category currently highlighted. So far I have this code.
         <li <?php if(is_home()) {echo 'class="current_page_item"';}?>><a href="<?php bloginfo('url'); ?>">Home
         <?php wp_list_categories('orderby=name&depth=1&title_li='); ?>
     <?php         $cat = get_query_var('cat');         $category = get_category ($cat);         $categories = get_the_category();              $subcat = get_the_category();         $parentCatName = get_cat_name($subcat[0]->parent);         $category_id = get_cat_ID( "$parentCatName" );              function post_is_in_descendant_category( $cats, $_post = null )         {             foreach ( (array) $cats as $cat ) {                 // get_term_children() accepts integer ID only                 $descendants = get_term_children( (int) $cat, 'category');                 if ( $descendants && in_category( $descendants, $_post ) )                     return true;             }             return false;         }              if ($category->cat_ID) {             if($category->category_parent) {                 //Displays subcategories on subcategory index                 $children = wp_list_categories("orderby=id&hide_empty=0&title_li=&child_of=".$category->category_parent."&echo=0");             }                 else {                     //Display subcategories on parent category index                     $children = wp_list_categories("orderby=id&hide_empty=0&title_li=&child_of=".$category->cat_ID."&echo=0");                 }             if ($children) { ?>
                   <?php echo $children; ?>
             <?php }         }         elseif (is_single() && (post_is_in_descendant_category($category_id)) && $categories[0]->category_parent == $category_id ) { ?>
                 <?php                                 $category = get_the_category();                     $cat_term_id = $category[0]->term_id;                     $cat_category_parent = $category[0]->category_parent;                     $listcat = wp_list_categories('echo=0&child_of='.$cat_category_parent.'&title_li=');                     $listcat = str_replace("cat-item-".$cat_term_id, "cat-item-".$cat_term_id." current-cat", $listcat);                     if ( in_category( $cat_term_id ) || post_is_in_descendant_category( $cat_category_parent )) {                         echo $listcat;                     }                 ?>
     <?php } ?>      But the issue is how to make the hover thing work. Please help. Thanks.


How to use more than 256MB of memory in the admin?

I'm building a site for a photographer who uploads pictures that are normally large for todays digital cameras. Images are quite memory intensive, especially the image operations like creating thumbnails. So I wanted to raise the memory limit in the admin above 256MB - how can this be done? I allowed CGI and PHP to use up to 1 Gigabyte but wordpress always decreases the memory to 256MB. Any idea how to fix that on a client side that needs to be able to auto-update? **UPDATE:** From Wordpress 3.2 ongoing the maximum memory limit in Wordpress will be configure-able again.


How to add default images for custom backgrounds?

The custom header feature allows (in some code I have found) to suggest several default images to use in the custom header. Could the same be built in the custom background? The idea is to have already some textures available for the user to choose from in the theme. Any ideas?


How to get IDs for objects in menu branch?

Is it possible to print content of all menu items, when displaying menu (or branch of menu as in question about displaying menu branches) ? ![enter image description here](http://i.stack.imgur.com/Eom4e.png) Once I click on `About Us` I wish for new page to display content of all it's children links. So basically I am looking for a way to get IDs of those posts/pages and use them inside my WP Query.


get_image_tag() html output : empty src attribute

I'm trying to use the `get_image_tag()` function to alter the html output of an image, like so :               add_filter('get_image_tag', 'kh_image_attachment', 10, 5);     function kh_image_attachment($html, $id, $alt, $title, $align) {         $html = '<img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="' . esc_attr($img_src) . '" id="'.esc_attr($id).'" alt="' . esc_attr($alt) . '" title="'.esc_attr($title).'" class="'.$class.'" onload=lzld(this) onerror=lzld(this) />';         return $html;     }      Unfortunately, the `src` attribute remains empty (the class attribute as well, but I couldn't care less about that). I can't for the life of me figure out why. Can you help me out here? Thank you.


Is there a method to get a RSS element that is not covered by fetch_feed

Is there a method to get a RSS element that is not covered by current methods, for example:               $item->get_title()      when using fetch_feed? Thanks Kaiser, I found the solution:               if ($enclosure = $item->get_enclosure())          {              foreach ((array) $enclosure->get_thumbnails() as $thumbnail)                    {                          echo $thumbnail;                    }          }


wp_insert_post iframe missing

In my install, I used one custom page. Here I put one text field and the fck editor. This is for the title and the content. I need to insert this into a page. I used the following code               $my_post = array(         'post_title'    => $_POST['title'],         'post_content'  => $_POST['content'],         'post_type'       => 'page',         'post_status'   => 'publish',         'post_author'   => 1,         'menu_order'    => 10,     );          // Insert the post into the database     $post_ID = wp_insert_post( $my_post );        In the content field, I insert the content with some `iframe` videos. The page inserted successfully, but the iframe tags are not updated. They are deleted while update or insert the content.


Confused about image sizing business in Wordpress

I'm creating my first Wordpress theme and I've got everything working fine, and by following this tutorial and few others I've understood how to add custom image sizes by using add_image_size() function. However, I just don't know what image size to choose when. For example, in my theme I have created a blog template that shows blog thumbnails in 3 columns. Each column is around 400px wide. So my first guess is that I should create a 400px wide image size, so that image is loaded whenever the blog page is loaded. My confusion here is first of all, how much height should I set? Should I have:               add_image_size('blog-grid', 400, 300, true), // Or     add_image_size('blog-grid', 400, 500, true), etc. // Or     add_image_size('blog-grid', 400, 'auto', true), etc. // Can I set it to 'auto'?      Because really, how am I supposed to know what height would the images be, I would rather just set the width and let the height be automatically adjusted to the proportion, so I won't even have to crop the images. Also having different heights in the grid won't break my layout or anything, might even look good if I choose a masonry layout. My second confusion is that when the browser re-sizes, the columns stack on one another (I'm using Bootstrap), so the displayed image increases. Would this be a factor in choosing the custom image size? Another concern that I have is that I have given the user an option to choose between 2 column, 3 column and 4 column grid layouts. Should I create 3 different image sizes for these or it would be better if choose an average of the three. Also, I've inspected a theme and found out that it uses images double the size of the ones required. So for example, in a blog where a column is 400px wide(and so the image), the image size used for this is more than 800px wide. Is this to do with retina display? As I believe I've already taken care of that in my theme by using retina.js and by following this tutorial. Do I still need to worry about retina display, when adding custom sizes? I know these questions probably sound really stupid, but I would really appreciate any help regarding this. Thanks!


How to change color of registered widget areas in admin?

Right now they are all gray. How to change the color? I mean, how to add a class or id to the registered widget area that are shown in the admin area? This is how you register the admin areas in my functions.php right now:               register_sidebar( array(             'name' => __( 'Main Sidebar', 'twentyeleven' ),             'id' => 'sidebar-1',             'before_widget' => '',             'after_widget' => "",             'before_title' => '
',             'after_title' => '
',         ) );      How can I add some attribute to add class in the admin, so I can style it later via CSS?


Output only the 3rd level of menu

Currently I use `wp_nav_menu` to output the first and second level of the menu in the header of the page. However the menus have more depth than that and I need the third level to be shown at a different place. I was hoping that `wp_nav_menu` had some kind of "level" parameter that shows only the appropriate level of the menu – but it hasn't. Note: I'm aware of `wp_list_pages`, which I can't use since there are not only pages involved.