Custom profile field with birthday. Troubles with <select>

I made custom profile fields for birthday data.                       function my_user_field( $user ) {                 $birthday_day = esc_attr( get_the_author_meta( 'birthday_day', $user->ID ) );                 $birthday_month = esc_attr( get_the_author_meta( 'birthday_month', $user->ID ) );                 $birthday_year = esc_attr( get_the_author_meta( 'birthday_year', $user->ID ) );             ?>
<?php _e('More About You'); ?>

                                                      <?php _e('Birthday'); ?>                         	                                                    <?php _e('When is your birthday?'); ?>
                             <form action="">                             <select name="birthday_day" id="birthday_day">                                 <?php                                 for ($i=1; $i<=31; $i++)                                 {                                     echo '<option value="';                                     echo $i;                                     echo '"';                                      if ($birthday_day == $i ) {                                           echo 'selected';                                         }                                     echo' >';                                     echo $i;                                     echo'</option>';                                 };                                 ?>                             </select>                             <select name="birthday_month" id="birthday_month" onchange="updateDays();">                                 <option value="1" <?php if ($birthday_month == '1') { ?>selected<?php }?> >January</option>                                 <option value="2" <?php if ($birthday_month == '2' ) { ?>selected<?php }?> >February</option>                                 <option value="3" <?php if ($birthday_month == '3' ) { ?>selected<?php }?> >March</option>                                 <option value="4" <?php if ($birthday_month == '4' ) { ?>selected<?php }?> >April</option>                                 <option value="5" <?php if ($birthday_month == '5' ) { ?>selected<?php }?> >May</option>                                 <option value="6" <?php if ($birthday_month == '6' ) { ?>selected<?php }?> >June</option>                                 <option value="7" <?php if ($birthday_month == '7' ) { ?>selected<?php }?> >July</option>                                 <option value="8" <?php if ($birthday_month == '8' ) { ?>selected<?php }?> >August</option>                                 <option value="9" <?php if ($birthday_month == '9' ) { ?>selected<?php }?> >September</option>                                 <option value="10" <?php if ($birthday_month == '10' ) { ?>selected<?php }?> >October</option>                                 <option value="11" <?php if ($birthday_month == '11' ) { ?>selected<?php }?> >November</option>                                 <option value="12" <?php if ($birthday_month == '12' ) { ?>selected<?php }?>>December</option>                             </select>                             <select name="birthday_year" id="birthday_year" onchange="updateDays();">                                 <?php                                  for ($i=2010; $i>1930; $i--)                                 {                                     echo '<option value="';                                     echo $i;                                     echo '"';                                      if ($birthday_year == $i ) {                                           echo 'selected';                                         }                                     echo' >';                                     echo $i;                                     echo'</option>';                                 };                                  ?>                             </select>                  </form>

             <?php              }                       function my_save_custom_user_profile_fields( $user_id ) {                 if ( !current_user_can( 'edit_user', $user_id ) )                     return FALSE;                      update_usermeta( $user_id, 'birthday_day', $_POST['birthday_day'] );                 update_usermeta( $user_id, 'birthday_month', $_POST['birthday_month'] );                 update_usermeta( $user_id, 'birthday_year', $_POST['birthday_year'] );               }                  add_action( 'show_user_profile', 'my_user_field' );             add_action( 'edit_user_profile', 'my_user_field' );             add_action( 'personal_options_update', 'my_save_custom_user_profile_fields' );             add_action( 'edit_user_profile_update', 'my_save_custom_user_profile_fields' );      And it normaly saves to db, but there is a fail. I can choose for example "31 of February" and this is bad. How can I make any verification for these? I want if user selected "31 of February" and submited form, then his date would be saved as "28 of February", but if selected year is leap year, then "29 of February". I know that is posible to make more flexible form using javascript, but how to make this using PHP?


Listing comment author role code problem

I use the following code on comments template:               <?php $user = get_userdata($comment->user_id);                      echo $user->roles[0];                     ?>      But the weird thing is that it is not displaying the comment author role for everyone... just for a few users (even with different roles), and for the rest it is not showing anything. Any clue? what am I doing wrong? thank you!


Multiple Single Installs of Wordpress with a central user base

Im sorry that I am asking this but I have been searching for ages and for some reaseon the suggested custom user table dosn't work, it just gives me a username error. This is the code I am taking about:               define('CUSTOM_USER_TABLE','new_user_table');     define('CUSTOM_USER_META_TABLE', 'new_usermeta_table');      So I have a main Single install of Wordpress, Lets say I have another on a subdomain (Subdomain A) and a different WordPress site which IS a Sub Directory MU Install on Sub Domain B. I only want people to create an account at the top, main site however they can log in on any of the domains. I would use MU but one of the sub sites is using MU so I cant. Single Sign on is not important but if possible then that would also be really good. Any Ideas would be appreciated! Cheers, Joe


How to get Tags with specific post id

I have created one post and post ID is 34 and added some Tags and Now I want to retrieve all tags with post ID. ![enter image description here](http://i.stack.imgur.com/lLG9B.png) Any Idea?


get recent 12 days post then random in wordpress

I want to show recent 12 days post then totally random post showing i have done my almost done my work but my problem is i want to show only 12 post in a page then pagination will start. In my code problem will comes for next page if recent post count is more then 12 like 15 then remaining 3 post will showing in next page then random . Please see below my all code.               $limit = 12;               $total_pages = $wpdb->get_var($select);              $page = mysql_escape_string(get_query_var('page'));              if($page)         {             $start = ($page - 1) * $limit;                         print_r($start);         }         else{             $start = 0;          }                 if(!empty($searchcountry) || !empty($searchresort) || !empty($searchresortresponse))         {             $query = "SELECT `".$wpdb->prefix."posts`.* FROM `".$wpdb->prefix."posts` JOIN `".$wpdb->prefix."postmeta` ON  `".$wpdb->prefix."postmeta`.post_id = `".$wpdb->prefix."posts`.ID $where LIMIT $start, $limit";             $record = $wpdb->get_results($query);              }         else         {                          $days = "post_date > '" . date( 'Y-m-d H:i:s', strtotime( '-12 days' ) ) . "'";                   //echo "SELECT * FROM `".$wpdb->prefix."posts` WHERE `post_type` = 'custompost' and `post_status` = 'publish' and $days order By `post_date` DESC LIMIT $start, $limit";                   //echo "SELECT * FROM `".$wpdb->prefix."posts` WHERE `post_type` = 'custompost' and `post_status` = 'publish' and $notin order By RAND() LIMIT $start, $checklimit";                    echo  $select_query = "SELECT * FROM `".$wpdb->prefix."posts` WHERE `post_type` = 'custompost' and `post_status` = 'publish' and $days order By `post_date` DESC LIMIT $start, $limit";                     $record1 = $wpdb->get_results($select_query);                     $count = count($record1);                    // print_r($count); die();                       if($count <= 12)                     {                         $checklimit = 12-$count;                             // print_r($checklimit); die();                         $ids=array();                         foreach($record1 as $key => $id){$ids[] = $id->ID;}                              $notin= "`ID` NOT IN (".implode(',', array_map('intval', $ids)).")";                         $select =  "SELECT * FROM `".$wpdb->prefix."posts` WHERE `post_type` = 'custompost' and `post_status` = 'publish' and $notin order By RAND() LIMIT $start, $checklimit";                           $record2 = $wpdb->get_results($select);                         $record = array_merge($record1, $record2);                          }                     else {                         $record = $record1;                     }                                  }      can we resolve from one query.i have used 2 queries and it will create problem. Please check.


How to stop loading multiple copies of jquery

My wordpress header.php and function.php is given below.please help me to modify my php code to stop problems due to loading jquery multiple times. My plugins and themes are loading jquery multiple times. My files   Header.php   Function.php * * * All experts are telling that i need to include enqueue script !!! I read different documents related to it. I'm new to coding , i dont know where to add this enqueue script, what type of code I need to add?


wp_mail - Remove sitename from email subject

Can some one tell me how to remove site name from email subject. As of now my email subject looks like this > **[sitename] - Subject goes here** I want it to look like this > **Subject goes here** I checked wp_mail code. There is a filter (wp_mail) available. Can someone tell me how to use that filter to alter my email subject? Thank you


What option do I check to enable a user role to be able to see all plugins?

I want my client to be able to use certain plugins in the admin menu, but they aren't showing up for him. I'm using capability manager to try and work out what I need to check to show the plugins. I have him down as an editor. Does anyone know what I need to check on the role page check options to enable him to see plugins?


How to embed a new string in url?

I am creating a custom tours and travel theme in which I have created custom post type Cities, Locations, Destinations and i am using custom permalink structure. `/%category%/%postname%/` So now I want to append a state name or district name before that city, destination or location name. Let me make it more clear by giving you an example . The current url structure is like this. http://test.com/custom_post_type_slug/post_name_slug And how I want it to be like this. http://test.com/Custom_dynamic_string/custom_post_type_slug/post_name_slug Right now i am doing something like this               function add_places_rewrite_tags(){     add_rewrite_tag('%district%','([^/]+)');     }     add_action( 'init', 'add_places_rewrite_tags' );          add_action( 'init', 'custom_rewrite_rules' );     function custom_rewrite_rules() {     add_rewrite_rule(         "/([^/]+)/hotel/([^/]+)/?",         'index.php?post_type=hotel&district=$matches[1]&p=$matches[2]',         'top'     );     add_filter( 'query_vars', 'custom_query_vars' );     }     function custom_query_vars( $query_vars )     {        $query_vars[] = 'district';        return $query_vars;     }      but it's still not giving me the desired results and i am also using a plugin to analyze the re-wright rules


how do i update version for super skeleton. I have Version 1.8.0 and noticed that there is a updated version. I looked in the available themes and didn't see the super skeleton theme listed. The reason I want to update is my gallery gets an error message when i click the image "Image cannot be loaded. Make sure the path is correct and image exist." the gallery settings link to media files but doesn't fix the problem. sorry if this is a dumb question, I'm a newbie


Rewrite the base-url for single posts

I want to append the URL when viewing a single post. For example when im on a post I want the url to be something like: `example.com/mypage/mypage/single- post-article` The default url is `example.com/single-post-article` I did not find something here on WPSE or the goooglz, but I have read about `wp-rewrite` and tried `add_post_type_support` to the `post` but no luck!               add_post_type_support( 'post', array(        'rewrite' => array('slug' => '/bla/bla/')     ));      Do I need to use `wp_rewrite`? **Update** I did get this to work by run `register_post_type` on the post_type "post" again. But is this the best way?                 register_post_type( 'post', array(             'public'  => true,             '_builtin' => false,              '_edit_link' => 'post.php?post=%d',              'capability_type' => 'post',             'map_meta_cap' => true,             'hierarchical' => false,             'rewrite' => array( 'slug' => '/mypage/mypage' ),             'query_var' => false,             'pages'     => false,             'supports' => array(                  'title',                  'editor',                 'author',                  'thumbnail',                  'excerpt',                  'revisions             ),     ));


Add Sub Nav Menu Item to Buddy Press Menu

I'm having trouble adding sub nav menu items to my parent menu item under Buddy Press. The parent menu item as shown below, named **`TEST`** , shows correctly, but the tabs named **`SUB NAV`** and **`SUB NAV 2`** don’t show at all.               function my_setup_nav() {      global $bp;      $em_link = $bp->loggedin_user->domain . $bp->account->slug . '/';          # - add parent menu item              bp_core_new_nav_item( array(          'name' =>  'TEST',         'slug' =>  $bp->account->slug,          'position' => 10,         )      );           # - add sub nav menu items          bp_core_new_subnav_item( array(          'name' => 'SUB NAV',         'slug' => 'account-sub',          'parent_url' =>  $em_link ,         'parent_slug' => $bp->account->slug,         'position' => 10,         'item_css_id' => 'xx'          )      );      bp_core_new_subnav_item( array(          'name' => 'SUB NAV 2',         'slug' => 'account-sub-2',          'parent_url' =>  $em_link ,         'parent_slug' => $bp->account->slug,         'position' => 20,         'item_css_id' => 'xx-2'          )      );      }           add_action( 'bp_setup_nav', 'my_setup_nav', 99 );      What's the correct syntax for getting the Sub Navigation items to work correctly?


Retrieve default permalink while using seo friendly URLs in WordPress

I have a client site that uses seo friendly URL's (/postname/) Up until yesterday they were using the default permalink structure of ?p=1234 They've had it set like that for years and have had their posts shared on facebook, twitter, and other networks. The problem with changing the permalinks now is that the social media sharing badges on their site have all reset their counts to 0 because the actual URL has changed. I read that Twitter would eventually begin updating itself due to it's use of checking redirected URL's but that is not the case for facebook. I would like to edit the code for the sharing buttons to pull in the original permalink instead of the new one. Is that possible? ie.               $plink = get_permalink($post->ID);     $eplink = urlencode($plink);      What can I use in it's place to pull in the original p=1234 instead of the seo friendly name? Thanks.


Include Category Description in search result

I have pulled Category Description data               <?php                                $taxonomies=  array('taxonomy'=>'area-type');             $terms = get_terms($taxonomies,'orderby=id&hide_empty=0');             $count = count($terms);             if ($count > 0) {                     foreach ($terms as $term) {                              $id =str_replace("#","",$term->slug);                         $term_desc .= '
'. wpautop($term->description) .'
';                         }                                           echo $term_desc ;                }   ?>       And did show hide on click on a Category plus added #categoryName in url so client feel that it's a different page. Sorry for this i am fresher in wordpress. So now problem is that they need Category Detail page which i have display with show hide they want that in search result how can i achieve this Page link e.g : www.sitename.com/PageType On Click of Category it's turn to www.sitename.com/PageType#CategoryName Sorry i was not able to add Category in before page name and now they have added 50 pages and i have to fix this


adding homework to a school's website

I have a school website - pickeringschool.org - that I am changing over to WordPress. This is no problem except that I want to add the functionality that allows the teachers to add daily homework like here> I am a novice developer so any suggestions, tutorials, etc would be appreciated. Thank you


MySql database help for a plugin

I am using a WordPress plugin called MyReview but I want some changes to it. That plugin has feature to review posts, where users will come and give star ratings to the post according to categories, but in that plugin a user can give star rating to a post to as many times as the user wants, which I dont want, what I want is a user can give star rating to a post just a single time, for that purpose I had words with the author of the plugin, and he suggested me something like this, > Query the comments table for any comments by the same email ID, check if > there are any attached ratings, if there are, don't accept the ratings. All > these changes would go in myrp-save.php. If you know PHP and are comfortable > working with phpMyAdmin to understand the database tables, it would not be > difficult to do.               SELECT id FROM myrp_ratings as rat, wp_comments as com WHERE com.comment_ID=rat.comment_id AND com.comment_author_email='whatever@whatever.com' AND rat.value!='0' AND rat.value!='1' LIMIT 1      How can I put this line in that plugin file which is `myrp-save.php`? I think code should be inserted after this line or before this line:               $wpdb->query("INSERT INTO `" . $wpdb->myrp_ratings . "`(`ID`, `category_id`, `post_id`, `comment_id`, `value`, `outof`, `weighted`) VALUES('', '{$name}', '{$postID}', '-1', '{$value}', '{$outof}', '" . ($value/$outof) . "')");      How can this be done?               <?php              function myrp_save_comment_fields($commentID)         {             global $wpdb;                  $fields = $wpdb->get_results("SELECT * FROM " .$wpdb->myrp_comment_fields." ORDER BY `order`");                  $rq = get_option("myrp_comment_fields_required");             foreach($fields as $f)             {                 $puniqid = str_replace(".", "_", $f->uniqid);                 if(!isset($_POST[$puniqid])) continue;                 $postdata = $_POST[$puniqid];                      switch($f->type)                 {                     case "date":                         if(strlen($postdata) > 2)                         {                             $date = strtotime($postdata);                             if($date > strtotime($f->minimum))                             {                                 add_comment_meta($commentID, $f->uniqid, $date, true)                                     or                                 update_comment_meta($commentID, $f->uniqid, $date);                             } else {                                 if($rq)                                 {                                     wp_die(__("Field {$f->name} is required and must be after {$f->minimum}!", "myrp") . " Click here to continue...");                                 } else {                                     continue;                                 }                             }                         }                     break;                               case "short": case "long":                         if(strlen($postdata) > 0)                         {                             $text = ($postdata);                             if(strlen($text) > intval($f->minimum) && strlen($text) < $f->maximum)                             {                                 add_comment_meta($commentID, $f->uniqid, $text, true)                                     or                                 update_comment_meta($commentID, $f->uniqid, $text);                             } else {                                 if($rq)                                 {                                     wp_die(__("Field {$f->name} is required and must be between {$f->minimum} and {$f->maximum} characters!", "myrp") . " Click here to continue...");                                 } else {                                     continue;                                 }                             }                         }                     break;                          case "number":                         if(strlen($postdata) > 0)                         {                             $text = intval($postdata);                             if(($text) > intval($f->minimum) && strlen($text) < $f->maximum)                             {                                 add_comment_meta($commentID, $f->uniqid, $text, true)                                     or                                 update_comment_meta($commentID, $f->uniqid, $text);                             } else {                                 if($rq)                                 {                                     wp_die(__("Field {$f->name} is required and must be between {$f->minimum} and {$f->maximum}!", "myrp") . " Click here to continue...");                                 } else {                                     continue;                                 }                             }                         }                     break;                          case "select": case "radio": case "check":                         if(strlen($postdata) > 0)                         {                                 add_comment_meta($commentID, $f->uniqid, $postdata, true)                                     or                                 update_comment_meta($commentID, $f->uniqid, $postdata);                         }                     break;                 }             }         }          // myrp_require_rating_comment, myrp_require_all_rating_comment         function myrp_save_ratings($commentID)          {             global $wpdb; global $myrp_type_outof;             $post_id = $_POST['comment_post_ID'];             $rating_categories = get_post_meta($post_id, "_myrp_rating_categories", true);                  if(is_array($rating_categories) && count($rating_categories) > 0)             {                 $submit_count = 0;                 foreach($rating_categories as $rc)                 {                     $type = $wpdb->get_var("SELECT `type` FROM `" . $wpdb->myrp_categories . "` WHERE `ID`='{$rc}' LIMIT 1");                     $outof = $myrp_type_outof[$type];                          if(isset($_POST[$rc . "_input"]) && $_POST[$rc."_input"] != "")                     {                         $submit_count++;                         $value = $_POST[$rc . "_input"];                                       if(!empty($value))                             {                                 if($value < 1) $value = 1;                                 if($value > $outof) $value = $outof;                                 $value = round($value*2)/2;                             } else {                                 $value = 0;                             }                              $sql =<<< SQL     SELECT       id     FROM       myrp_ratings AS rat,       wp_comments AS com     WHERE 1=1       AND com.comment_ID = rat.comment_id       AND com.comment_author_email = '%s'       AND rat.value != '0'       AND rat.value != '1'     LIMIT      1     SQL;     $sql = $wpdb->prepare($sql,'whatever@whatever.com');     $id = $wpdb->get_var($sql);                         if (is_null($id)) {       $wpdb->query("INSERT INTO `" . $wpdb->myrp_ratings . "`(`ID`, `category_id`, `post_id`, `comment_id`, `value`, `outof`, `weighted`) VALUES('', '{$name}', '{$postID}', '-1', '{$value}', '{$outof}', '" . ($value/$outof) . "')");         }                     }                 }                           if(                     (                         get_post_meta($post_id, "_myrp_no_allow_comments_without_ratings", true) == 1 && $submit_count == 0                     )                         ||                     (                         (                             (get_option("myrp_require_rating_comment") == 1 && $submit_count == 0)                                 ||                             (get_option("myrp_require_all_rating_comment") == 1 && $submit_count != count($rating_categories))                         )                             &&                         (                             get_post_meta($post_id, "_myrp_allow_comments_without_ratings", true) != 1                         )                     )                 ) {                     //$wpdb->query("DELETE FROM `".$wpdb->myrp_ratings."` WHERE `comment_id`='{$commentID}' LIMIT {$submit_count}");                     wp_delete_comment($commentID);  // should clean up ratings on its own.                     wp_die(__("Ratings are required! Please select star ratings for this review.", "myrp") . " Click here to continue...");                 }                  }             if(get_post_meta($post_id, "_myrp_automatically_approve_comments", true) == 1) $wpdb->query("UPDATE `" . $wpdb->comments . "` SET `comment_approved`=1 WHERE comment_ID='{$commentID}' AND `comment_approved`=0");             wp_update_comment_count($post_id);             do_action("myrp-savingratings");             update_option("myrp_notChanged",0);                  return true;         }              function myrp_save_post($postID)          {             global $wpdb;             global $myrp_type_outof;                  myrp_save_hides($postID);             if(isset($_POST['myrp_affiliate_link'])) {                 $affiliate_link = trim($_POST['myrp_affiliate_link']);                 if(!empty($affiliate_link))                 {                     $link = parse_url($affiliate_link);                     $scheme = $link['scheme'];                     if($scheme == "")  $affiliate_link = "http://" . $affiliate_link;                 }                      add_post_meta($postID, "_myrp_affiliate_link", $affiliate_link, true)                     or                  update_post_meta($postID, "_myrp_affiliate_link",$affiliate_link);             }                  if(isset($_POST['myrp_icon_image'])) {                 $icon_image = $_POST['myrp_icon_image'];                 if(!empty($icon_image))                 {                     $link = parse_url($icon_image);                     $scheme = $link['scheme'];                     if($scheme == "")  $icon_image = "http://" . $icon_image;                 }                      add_post_meta($postID, "_myrp_icon_image",$icon_image, true)                     or                  update_post_meta($postID, "_myrp_icon_image", $icon_image);             }                  $checked = array();             $rating_categories = array();             if(isset($_POST['myrp_save_categories_please']))             {                 if(count($_POST['myrp_checked_categories']) > 0)                 {                     foreach($_POST['myrp_checked_categories'] as $cid)                     {                         if(@$_POST["myrp_value_" . $cid] != "")                         {                             $rating = (@$_POST["myrp_value_" . $cid]);                         }                         else                         {                             $rating = "";                         }                                   $checked[] = array($cid, $rating);                         $rating_categories[] = $cid;                     }                 }                 add_post_meta($postID, "_myrp_rating_categories", $rating_categories, true)                     or                 update_post_meta($postID, "_myrp_rating_categories", $rating_categories);                           if(count($rating_categories) > 0)                 {                     update_option("myrp_previously_checked", $rating_categories);                 } else {                     update_option("myrp_previously_checked", array());                 }                      $wpdb->query("DELETE FROM `" . $wpdb->myrp_ratings . "` WHERE `post_id`='{$postID}' AND `comment_id`='-1'");                      foreach($checked as $rating)                  {                     $name = $rating[0];                     $value = $rating[1];                          $type = $wpdb->get_var("SELECT `type` FROM `" . $wpdb->myrp_categories . "` WHERE `ID`='{$name}' LIMIT 1");                     $outof = $myrp_type_outof[$type];                          if($outof == 1)                     {                         if($value == "Yes") $value = 1;                         if($value == "No") $value = 0;                     }                          if($outof == 40)                     {                              $value = myrp_translate_letter_to_number($value);                          }                     $value = floatval($value);                          $wpdb->query("INSERT INTO `" . $wpdb->myrp_ratings . "`(`ID`, `category_id`, `post_id`, `comment_id`, `value`, `outof`, `weighted`) VALUES('', '{$name}', '{$postID}', '-1', '{$value}', '{$outof}', '" . ($value/$outof) . "')");                 }             }                       update_option("myrp_notChanged",0);              }              function myrp_save_hides($postID)         {                  if(isset($_POST['_myrp_hide_set']))             {                 add_post_meta($postID, "_myrp_hide_float_left", $_POST['_myrp_hide_float_left'], true)                     or                 update_post_meta($postID, "_myrp_hide_float_left",$_POST['_myrp_hide_float_left']);                      add_post_meta($postID, "_myrp_hide_float_right", $_POST['_myrp_hide_float_right'], true)                     or                 update_post_meta($postID, "_myrp_hide_float_right",$_POST['_myrp_hide_float_right']);                      add_post_meta($postID, "_myrp_disable_traffic_tracking", $_POST['_myrp_disable_traffic_tracking'], true)                     or                 update_post_meta($postID, "_myrp_disable_traffic_tracking",$_POST['_myrp_disable_traffic_tracking']);                      add_post_meta($postID, "_myrp_disable_advanced_excerpts", $_POST['_myrp_disable_advanced_excerpts'], true)                     or                 update_post_meta($postID, "_myrp_disable_advanced_excerpts",$_POST['_myrp_disable_advanced_excerpts']);                      add_post_meta($postID, "_myrp_hide_microformats", $_POST['_myrp_hide_microformats'], true)                     or                 update_post_meta($postID, "_myrp_hide_microformats",$_POST['_myrp_hide_microformats']);                      add_post_meta($postID, "_myrp_allow_comments_without_ratings", $_POST['_myrp_allow_comments_without_ratings'], true)                     or                 update_post_meta($postID, "_myrp_allow_comments_without_ratings",$_POST['_myrp_allow_comments_without_ratings']);                      add_post_meta($postID, "_myrp_automatically_approve_comments", $_POST['_myrp_automatically_approve_comments'], true)                     or                 update_post_meta($postID, "_myrp_automatically_approve_comments",$_POST['_myrp_automatically_approve_comments']);             }         }     ?>


How to perform a frontend HTTP call with AJAX when plugin save the new settings?

I use a function to "pass" the data with get_num_queries from the front to the back end (to a plugin options page).               function get_queries_wpse_143544() {       $dbq = get_num_queries();       update_option('page_queries',$dbq);     }     add_action('wp_footer', 'get_queries_wpse_143544', 999);      (*thanks to @s_ha_dum for the function) The problem is retrieving the data with `get_option` will not display any data until the front end page is not visited at least once. My question is obviously: how to perform a hidden frontend HTTP call with AJAX after clicking "Save Settings" button so that the `get_option` to display the value from the above function after the options page will be reloaded? Thank you!


Restrict Viewing of post on both front and backend?

Any ideas to restrict viewing of posts to post author only? The twist: Restrict both back AND frontend. I'd like to avoid the role scoper plugin. Example: The author creates a post, and can now view live on the site, as well as in the admin panel. They can edit, trash, whatever. But only admins and the author can see the post. (Looking for task/project/helpdesk/use.


Creating a Page to View the List of Posts for a Custom Post Type?

_( **Moderator's Note:** The original title was "viewing custom post types")_ I've setup a custom post type called `'recordings'` with a custom taxonomy called `'themes'`:               add_action('init', 'recordings');     function recordings() {       $args = array(         'label' => __('Recordings'),         'singular_label' => __('Recordings'),         'public' => true,         'show_ui' => true,         'capability_type' => 'post',         'hierarchical' => false,         'rewrite' => true,         'supports' => array('title', 'editor', 'thumbnail', 'custom-fields')       );       register_post_type( 'recordings' , $args );     }     register_taxonomy("Themes", array("recordings"), array(       "hierarchical" => true,        "label" => "Themes",        "singular_label" => "Theme",        "rewrite" => true     ));      I've read that I should now make a copy of `page.php`, rename it `recordings- page.php` and season to taste (code is as follows):               <?php     /*     Template Name: recordingsPage     */     ?>     <?php get_header(); ?>

       <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>         <?php $recent = new WP_Query('post_type=recording&posts_per_page=10&meta_key=Date&orderby=meta_value&order=ASC'); ?>         <?php while($recent->have_posts()) : $recent->the_post();?>           <?php the_title( '
', '
'            ); ?>
             <?php the_content(); ?>             <?php wp_link_pages( array(                'before' => '
' . __( 'Pages:', 'twentyten' ),                'after' => '
'              ) ); ?>             <?php edit_post_link(                __( 'Edit', 'twentyten' ),                '', ''              ); ?>
           <?php comments_template( '', true ); ?>         <?php endwhile; ?>

      But this is where I'm stuck. I'm not sure how I should call my recordings- page? I've added a new page called recordings, but all that shows up is the header/nav and the sidebar. I'm working with a fresh install using the TwenyTen theme. I'm sure I'm missing something here but I don't know what.


the_post_thumbnail do 2 queries. How to optimize

I have query:               <?php           $args =  array( 'post_type' => 'post',                          'post_status' => 'publish',                          'orderby' => 'post_date',                          'order' => 'DESC',                          'showposts' => 10                          );           $recent = new WP_Query($args);           $TopnewsIndex1 = 0;           while($recent->have_posts()) : $recent->the_post();              array_push($index_posts, $recent->post->ID);              $ptitle = esc_attr( get_post_field( 'post_title', $post_id ));              $pdesc  = esc_attr( get_post_field( 'sub_desc', $post_id ));     ?>
 <a href='<?php the_permalink() ?>' rel='bookmark'> <?php echo $ptitle ?>

<?php echo $pdesc; ?>
          <?php      endwhile; ?>      And after that get_num_queries() = 1 queries (for 10 posts) If I wont to show thumb images for each posts I add string:               <?php echo the_post_thumbnail( 'medium' ); ?>      And after that get_num_queries() = 21 queries (1 + 10*2) If in one page I wont to show 50 post with thumb then num queries = 101 queries!!! Do you have any idea why? How to optimize this code?


how to know if admin is in edit page or post

I use this after I checked if the user is admin                  if ( isset($_GET['action'])  && $_GET['action'] === 'edit' )      is there better way?


Problem setting up wordpress multisite with subdomains

I have an add-on domain mydomain.com on which I want to set up a wordpress multisite with subdomains enabled. I have created a sudomain *.mydomain.com to enable wildcard dns. I have set the document root to public_html/mydomain.com(since it is an addon domain). I have edited wp- config.php and .htaccess files accordingly as per the instructions. Everything is set up. But when I create a new sub-domain abc.mydomain.com under Mysites,the site is created but when I visit it it says 'Problem loading page'. Can anyone help?


How to make sense of the active_plugins option_value to enable and disable certain plugins from the database?

Can anyone explain how to interpret and make sense of the active_plugins option_value string in WordPress. And then use this string/ array to disable and activate specific plugins? Here is an example:               a:8:{i:0;s:21:"adrotate/adrotate.php";i:1;s:19:"akismet/akismet.php";i:2;s:33:"better-related/better-related.php";i:3;s:17:"clicky/clicky.php";i:4;s:49:"custom-post-permalinks/custom-post-permalinks.php";i:5;s:32:"disqus-comment-system/disqus.php";i:6;s:33:"export-to-text/export-to-text.php";i:7;s:36:"google-sitemap-generator/sitemap.php";}


Getting attachment post using wp_get_attachment_link

The WordPress codex on wp_get_attachment_link says you can use the $permalink parameter to link to the page, not the image. But I would like to link to the post instead. I'm trying to get a list of images using the following (updated, see answers below):               <?php $new_query = new WP_Query('&showposts=1'); ?>                             <?php while ($new_query->have_posts()) : $new_query->the_post(); ?>                             <?php $args = array (                                    'post_type' => 'attachment',                                    'numberposts' => 18,                                    'orderby' => 'date',                                    'status' => 'publish',                                    'post_mime_type' => 'image',                                    'parent' => $post->ID                             ); ?>                             <?php $attachments = get_posts($args);                                    if ($attachments) {                                        foreach ($attachments as $attachment) {                                            echo '
';                                            echo 'ID ) . '">';                                            echo wp_get_attachment_image($attachment->ID, 'thumbnail' );                                            echo '
';                                             }                                    };                                         endwhile;                                         ?>         Having trouble getting the images to link to the post. I'm not sure how to filter this to get the post, not the page.


Wordpress switch_to_blog

I'm using Wordpress switch_to_blog on a subdomain in a multisite network. I've been able to switch_to_blog and echo the URLs of a post within a category on the main site, however these just link back to the main site. What I'm looking to do is echo the posts and their content onto a permalink within the subdomain so... domain.com/cat/postname echos to sub.domain.com/cat/postname


How to append a query string to pagination?

I would like to append 2 variables from page 2 onwards in my loop. **This is my normal category page**               www.example.com/category/news/      **This is what I would like on pages: 2, 3, 4, 5 etc**               www.example.com/category/news/page/2/?var1=one&var2=two      The Loop:               $args = array     (        'category_name' => 'news',        'posts_per_page' => 5,        'paged' => $paged     );          $news_loop = new WP_Query($args);     while ($news_loop->have_posts()) : $news_loop->the_post();              // posts          endwhile;     wp_pagenavi(array('query' => $news_loop)); ?>


Static front page with recent posts pagination

Is it possible to include index pagination on a static front page? I have a child theme of twenty eleven and I am attempting to have a home page where there is a slider for sticky posts followed by the recent posts with a custom query, that I would like to be paginated. I created a page template, and set that page template to be the static front page. For some reason, pagination only works when I am logged in to WordPress. If I visit the site as an anonymous visitor, I get a 404 and the URL looks like "example.com/2011/09/268" instead of "example.com/page/2". **Am I going about this the completely wrong way?** Below is the code for the page template:               <?php     get_header(); ?>

                          <?php the_post(); ?>                          <?php                         $sticky = get_option( 'sticky_posts' );                              // Proceed only if sticky posts exist.                         if ( ! empty( $sticky ) ) :                              $featured_args = array(                             'post__in' => $sticky,                             'post_status' => 'publish',                             'posts_per_page' => 10,                             'no_found_rows' => true,                         );                              // The Featured Posts query.                         $featured = new WP_Query( $featured_args );                              // Proceed only if published posts exist                         if ( $featured->have_posts() ) :                              $counter_slider = 0;                              ?>

<?php _e( 'Featured Posts', 'twentyeleven' ); ?>

                     <?php                         // Let's roll.                         while ( $featured->have_posts() ) : $featured->the_post();                              if ( has_post_thumbnail()) : ?>
                             <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >                                <?php the_post_thumbnail(); ?>
<a href="<?php the_permalink(); ?>"                                 title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ),                                 the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">                                 <?php the_title(); ?>

                         <?php                         endif; // End check for post thumbnail ?>                     <?php endwhile; ?>

                          <?php //endif; // End check for more than one sticky post. ?>
                     <?php endif; // End check for published posts. ?>                     <?php endif; // End check for sticky posts. ?>                          <?php                         // Display our recent posts                         // Setup for pagination of custom loop                         $paged = (get_query_var('page')) ? get_query_var('page') : 1;                              $recent_args = array(                             'order' => 'DESC',                             'post__not_in' => get_option( 'sticky_posts' ),                             'category__not_in' => array( 46, 47 ),                             'tax_query' => array(                                 array(                                     'taxonomy' => 'post_format',                                     'terms' => array( 'post-format-aside', 'post-format-link', 'post-format-quote', 'post-format-status' ),                                     'field' => 'slug',                                     'operator' => 'NOT IN',                                 ),                             ),                             'posts_per_page' => 10,                             'paged' => $paged,                         );                              // Our new query for the Recent Posts section.                         query_posts( $recent_args );                              // The first Recent post is displayed normally                         //if ( $wp_query->have_posts() ) : $wp_query->the_post();                         ?>
<?php _e( 'Recent Posts', 'twentyeleven' ); ?>
                         <?php twentyeleven_content_nav( 'nav-above' ); ?>
                         <?php                             if ( $wp_query->have_posts() ) :                             while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
                                 <?php if ( "image" == get_post_format() ) :                                          get_template_part( 'content', 'image' );                                 else : ?>
                                         <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>

                                         <?php twentyeleven_posted_on(); ?>
                                     <?php if( has_post_thumbnail() ) : ?>                                         <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">                                         <?php the_post_thumbnail('excerpt-thumbnail', array('class' => 'alignleft') ); endif; ?>                                     <?php the_excerpt(); ?>
                                             <?php comments_popup_link( '' . __( 'Leave a Comment', 'twentyeleven' ) . '', __( '1 Comment', 'twentyeleven' ), __( '% Comments', 'twentyeleven' ) ); ?>
                                 <?php endif; ?>

                             <?php                             endwhile; ?>                             <?php                             endif; ?>                         <?php                         twentyeleven_content_nav( 'nav-below' );                         // Reset because we used query_posts                         wp_reset_query(); ?>
                           <?php //get_template_part( 'content', 'page' ); ?>                          <?php //comments_template( '', true ); ?>

          <?php get_sidebar(); ?>     <?php get_footer(); ?>


How to create a sub post?

I'm planning to create a TV Streaming site and I want to know how can I make sub posts under a post? I want to make subposts cause they'll act as a mirror post of the episode this is a structure that I plan to use:               Series01 (Category)         - Episode 1 (Post)             - Mirror 01 (Post)             - Mirror 02 (Post)             - Mirror 03 (Post)         - Episode 2 (Post)             - Mirror 01 (Post)             - Mirror 02 (Post)             - Mirror 03 (Post)         - Episode 3 (Post)             - Mirror 01 (Post)             - Mirror 02 (Post)             - Mirror 03 (Post)          Series02 (Category)         - Episode 1 (Post)             - Mirror 01 (Post)             - Mirror 02 (Post)             - Mirror 03 (Post)         - Episode 2 (Post)             - Mirror 01 (Post)             - Mirror 02 (Post)             - Mirror 03 (Post)         - Episode 3 (Post)             - Mirror 01 (Post)             - Mirror 02 (Post)             - Mirror 03 (Post)      If you know a better way to structure this then do tell me. So how can I make subposts?


I use same slug name for category and page

I added one slug and page with the same name and they worked fine, but when creating a second WP forced me to rename the page (being created after the category) with an additional "-2" how to clear the additional "-2". if i delete the category and create new category in same name then it display as "-3"


Displaying only the current category in template page

I'm having a problem displaying filtered category list pages. I want to be able to only show the current category, not all of the posts from "my categories". i.e. www...com/mycategories/category-3/ would only show posts in category page. Here is what I have but it seems to display all the categories in the `taxonomy-mycategories.php` page. **Template page:**                 <?php                  $wp_query = null; $wp_query = $temp;                 $temp = $wp_query;                 $wp_query= null;                 $wp_query = new WP_Query();                 $wp_query->query("post_type=business&category_name=" . $_GET["category"] . "&". $catinclude ."&paged=".$paged.'&showposts=20');                  if ( have_posts() ) while ( have_posts() ) : the_post(); ?>                     <?php the_title() ?>       <?php endwhile; ?>      **`functions.php:`**               /******************     //  Business     ******************/          function my_custom_post_business() {         $labels = array(             'name'               => _x( 'business', 'post type general name' ),             'singular_name'      => _x( 'business', 'post type singular name' ),             'add_new'            => _x( 'Add New', 'book' ),             'add_new_item'       => __( 'Add New business' ),             'edit_item'          => __( 'Edit business' ),             'new_item'           => __( 'New business' ),             'all_items'          => __( 'All business' ),             'view_item'          => __( 'View business' ),             'search_items'       => __( 'Search business' ),             'not_found'          => __( 'No business found' ),             'not_found_in_trash' => __( 'No business found in the Trash' ),              'parent_item_colon'  => '',             'menu_name'          => 'business'         );         $args = array(             'labels'        => $labels,             'description'   => 'Holds our business and business specific data',             'public'        => true,             'hierarchical'      => true,             'show_ui'           => true,             'show_in_nav_menus' => true,             'menu_position' => 5,             'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),             'has_archive'   => true,             'rewrite' => array(                 'slug' => 'business',                 'with_front' => false                 ),             //'taxonomies' => array('category'),         );         register_post_type( 'business', $args );          }     add_action( 'init', 'my_custom_post_business' );                    /** add categories for custom post type */     add_action( 'init', 'build_taxonomies', 0 );     function build_taxonomies() {         register_taxonomy( 'mycategories', 'business', array( 'hierarchical' => true, 'label' => 'Business Categories', 'query_var' => true, 'rewrite' => true ) );     }


wamp server wordprocess whole from begining up on filezilla

Please let me know how to upload a WordPress installation using Filezilla from a local installation. I have created a theme on a WAMP server locally. I have created a lot of pages and it runs successfully on localhost. Now i want to upload the files using FTP and upload the database also. Please help.


Google indexed pages for one page site

I have created a one page site with wordpress. The basic idea used was to combine pages and their templates into index.php. The problem is that when crawlers work on the site, they get the links for the pages which is good, but they display the page as single item and not part of the one page site. How can I redirect these pages into the main site? Is there a plugin or a way to achieve it?


Wordpress Image Editor doesn't update thumbs specified with `add_image_size()`

The title somewhat explains the issue. I have a template using bones. I am not sure if this matters or not. http://themble.com/bones/ In the functions.php file we add some additional thumbnail size options:               add_image_size( 'bones-thumb-400', 400, 300, true );     add_image_size( 'bones-thumb-300', 300, 230, true );     add_image_size( 'bones-thumb-200', 600, 200, false );      So far so good. All thumbnails are created when we upload an image. When someone uses the image editor in the media library - to crop or rotate the image - the image is saved along with the Wordpress preview thumbnail. Unfortunately the custom thumbnails we have specified are not updated. They remain unchanged. Has anyone come across this issue before? How can we get the thumbnails specified in `add_image_size` to update along with the standard Wordpress thumbnails?


which code helps to display new widgets (first font page widgets)?

how to make new widgets(First font page widgets,second..). i found this code .. it shows the default sidebar.               <div id="secondary" class="widget-area" role="complementary">     <?php dynamic_sidebar( 'sidebar-1' ); ?>      I added the 'search' from widget in first font page area,now how can i display the Search-bar on my site.what code is required.


<object data = ... > </object> changes after I save a post

I'm trying to embed an interactive graph by using the code below, and it works great:               <object data="https://www.desmos.com/calculator/wr4nht4qbp" width="800" height="600"></object>      When I save the post and view it it looks fine. The problem occurs when I go from the `Text` tab to the `Visual` tab. As soon as I do that it changes from the above code to the shockwave flash code below:               <object width="800" height="600" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"      codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">     <param name="src" value="https://www.desmos.com/calculator/oobmwtyhdx" />     <embed width="800" height="600" type="application/x-shockwave-flash" src="https://www.desmos.com/calculator/oobmwtyhdx" /></object>      Is there a way to stop this from happening? Or is there another way to embed this graph so that it stays interactive?


Get parent taxonomy's name of custom post?

I have a foreach-loop that looks like this               foreach($selected_courses as $postid) {                 $course = new WP_Post($postid);     }      where $`selected_courses` is an array of ids based on a form submit. For each id I create a post-object (which is a custom post type course) Is there any good/fast way to retrieve the parent custom taxonomy of this course? (I don't create another loop for this if it is not neccessary) (I have custom post types courses which are related to custom taxonomy categorycourses)


Remove <ul> from wp_nav_menu() wordpress

I am using the theme Twenty Thirteen and am using `wp_nav_menu()` to display menu items. I need to remove the container `<div>` and `<ul>` from `wp_nav_menu()`. I tried this:                wp_nav_menu( array( 'container' => '', 'items_wrap' => '%3$s', 'theme_location' => 'primary' ) );       Output recieved:

home

aboutus

services

contactus

testimonials

      But it's not working. How can I fix this?


Current taxonomy name (not term!) given a post ID

I can find everywhere infos on how to get the terms for a specific a post, but I only need the taxonomies names. I mean: tax: Taxonomy1 terms: term1, term2, etc tax: Taxonomy2 terms: term1, term2, term3, etc My post is setted as Taxonomy1.term1, Taxonomy2.term3 OK. What I want is to know that my post is on Taxonomy1 and Taxonomy2, NOT that is on term1 and term3. How can I do it? (and by the way, I'm speaking of custom taxonomies and custom post types)


Where does function_exists() look to decide whether a function exists?

The documentation says: > Checks the list of defined functions, both built-in (internal) and user- > defined, for function_name. ( **SOURCE:** > http://php.net/manual/en/function.function-exists.php) Does the function merely scan the single php document using function_exists, looking for any functions that match? For example if I have `if ( function_exists( 'get_custom_header' )` in header.php, will the function look for `get_custom_header` in header.php? Or does the function look into other directories and/or files, such as functions.php or in other files in the wordpresss core(ie. the wp-admin folder or wp-includes folder)?


How do I query posts and have their related taxonomies returned in the results?

I have created a custom post type that contains television channel data. Each channel has its own post. I have also created a custom taxonomy of channel groups. What I want to do is query all the data and display it all on a table on a single page like so:               Channel # | Channel Name | Basic Package | Delux Package | Elite Package     1         | NBC          | X             | X             | X     2         | ESPN Classic |               | X             | X      What I need is a query that will return the related taxonomies for each post. This is what I have so far:               $args = array(         'post_type' => 'my_channel',         'numberposts' => -1,         'order_by' => 'menu_order',         'order' => 'ASC',         'tax_query' => array(             array(                 'taxonomy' => 'my_channel_package',                 'field' => 'slug',                 'terms' => array('basic', 'delux', 'elite'),             ),         ),     );          $posts_array = get_posts($args);      But the post array does not return the taxonomy data. Is my next option to query the database with custom SQL or am I missing a feature in the WordPress API? Thanks! Jason


Plugin Scripts no loading on options page

I've got this in my main php file, but the scripts aren't loading               function class_table_scripts() {         wp_register_script( 'JavaScript1', plugins_url('js/wcs.js'), array() );         wp_register_script( 'JavaScript1', plugins_url('js/jquery.qtip-1.0.0-rc3.min.js'), array('jquery') );     }     add_action( 'wp_enqueue_scripts', 'class_table_scripts' );      I've never tried to use JS or JQuery on the options page before, this is my first go. Any pointers on where I'm going wrong here? * * * EDIT: Here's what finally worked for me:               function class_table_scripts() {         wp_register_script( 'JavaScript1', plugins_url('js/wcs.js',__FILE__));         wp_register_script( 'JQuery1', plugins_url('js/jquery.qtip-1.0.0-rc3.min.js',__FILE__) );     }     add_action( 'admin_init', 'class_table_scripts' );


Getting custom admin submenu item to highlight when its active

I have a custom post type, Jobs, with 3 taxonomies under it in the Admin menu. One of the taxonomies is Status, which is either Active or Closed. I want a menu item under Jobs for Active Jobs. I created it with this code               add_submenu_page(         'edit.php?post_type=jobs',         'Active Jobs',         'Active Jobs',         'manage_options',         'edit.php?post_type=jobs&jobstatus=67'     );      This works perfectly, except that the Jobs menu item remains highlighted when the Active Jobs menu option is active. See screen shot ![example of submenu display](http://i.stack.imgur.com/wLH0l.jpg) I read in this article Current class on admin menu using add_submenu_page() to not include the parent slug as the first parameter. I don't know how to get the submenu to appear in the correct nav section when I remove the filename slug. At this point I am not using a callback function, I am simply executing the same URL as the default Jobs submenu option, except with query params that filter the posts displayed. If moving this into a callback function will resolve the issue, I can do that. But I don't know what should go in the callback function. I want to display the standard custom post type edit page, just with a taxonomy filter in place. thanks for assistance


404 error on dynamic stylesheet creation

Following this solution to create dynamic css instead of inline css from sorich87 I get an error when requesting the dynamically generated stylesheet. Css is in there but also the default wp error page and a 404 header returned. Solution I used: http://wordpress.stackexchange.com/a/1454 My stylesheet url with 404 error: http://tegelzetbedrijf.net/wp- content/plugins/wp-google-fonts/googlefonts.css?build=20120126 Any suggestions are highly appreciated! Thanks Quokka


How can I establish the credibility of a theme/plugin author?

As prompted by the question "Are WordPress Plugins Necessary?", through what practices can administrators of self-hosted WordPress installations establish the credibility of a theme/plugin author before installing their products? What are the factors that compose an author's credibility?


Function get_home_url appends dot

Does anyone have this problem? When I call this function on my mobile theme, it appends a dot at the end of my home url, so it looks like www.example.com. which makes some other functions work improperly. Any ideas?


How to make subdomain and muti-site but wordpress isn't in root?

my wordpress isn't in root but it is in public_html/home and then I would like make multi-site and subdomain. example when I create subdomain name "foo.domain.com" foo directory is created in public_html which path is public_html/foo. but when I make multi-site in wordpress which Site Address will be started www.domain.com/home and when I enter foo name. I just get path is www.domain.com/home/foo Can I make subdomain and mutisite that they aren't in root webpath?


How to use multiple instances of Deal or Announcement With Countdown Timer Plugin Widget

I have a widget called the _deal or announcement with countdown timer_ I want to use multiple instances of the widget at the same time; however, the widget does not allow multiple instances. Is there a technique or way to use it at the same time? Btw, why are some widgets can't be used at the same time while some widgets can?


How to show more than 5 posts?

I am running code that shows child categories, and all posts in the child categories. But if there are more than 5 posts in a category, only the 5 newest are shown. How can I show all, or at least set a number like 9 posts etc.? My code:               <?php     $args = array(         'child_of' => 1     );     $categories = get_categories( $args );     foreach  ($categories as $category) {         echo '
'.$category->name.'';         echo '
';         foreach (get_posts('cat='.$category->term_id) as $post) {             setup_postdata( $post );             echo '
ID).'">'.get_the_title().'
';         }         echo '

';     }     ?>


Make first inline image an attachment, so the featured image can be set automatically with a plugin?

So it is NOT an attachment yet, it is inline e.g.: `<img src="../pic/logos/rsi.gif" />` in the post. And I want automate that the first occurrence of such an image becomes an actual attachment of this wordpress post. Is there a way to do this? I read related posts and I guess this could be interesting: media_sideload_image()


moving server can not login

I design my site in win7 system, and today before a server rent, I moving my blog from win7 to my another computer witch is installed CentOS 5.5 for a last test, I have reference the article http://codex.wordpress.org/Moving_WordPress moving my site from `d:/www/` to `/var/www/html`, and my site runs well, all the post, comment have no problem. But I can not login into my site. I have two test accounts, one is admin, another is normal user, both account can not login into. when I fill with the username and password, click login button, then page will refresh and do nothing still return to the login page with no error hint. I searched google with a ton of posts, I have tried to rename the plugin folder, clear the web browser's cookies... Sorry for I can not test a password forget and register, because I have't install any mail scripts in localhost. Waiting for a possible solution, regards.


Change All Login/Signup Links in Plugin

I would like to redirect all login and signup links to an external site. I would prefer to do this in a plugin, or somewhere that isn't affected by WordPress upgrades or theme changes. What is the best way? Thanks!


Sort custom field by post

Ok it is pretty simple. Every post of my blog has a specific country. So i have the custom field country and then, when i write the article i add: japan, argentina, usa, italy etc. to the post. Now in home i like to have a box like that: Post By Country: Japan (130 posts) Usa (104 posts) Argentina (90 posts) Italy (46 posts) Uk (23 post) etc, etc. Then, be able to click on a contry and have all the post from that country. I'm not so familiar with php queries, can u help me? Tnx a lot.


Trying to package posts for republishing by partner offsite

I'm wondering if someone may be able to point me in the direction of a tutorial that can help me deliver my last X posts in X category as a javascript snippet to a publishing partner. I want to be able to control the content (html) within the snippet without them having to do anything. We'll be sending them posts and ads. Would this be better accomplished using iframes? Any advice appreciated. A


New User Form - Custom Menu Page

I have a question concerning creating a new user. I'm creating a plugin for this wp site I am working on. I have set up custom roles for these and I'd like to have a separate menu item for the "Owner" role to be able to access and add new staff members. I'd use the add users menu but I'd like to customize it to say "Staff" and "Add New Staff" but I can't do that, I don't think. So, I've opted for this route. Anyway... I've tried copying over the context of the "user-new.php" and "users.php" and change paths but I continue to run into errors. I've tried copying over stuff viewing the source but that hasn't worked either. I'd like pretty much the same exact setup... maybe excluding "Administrator" role from the options. Any pointers on this would be greatly appreciated. Thank you in advance to anyone that can help! **EDIT:** I have my core file with an include `require_once 'includes/plugin_hooks.php';` Then in my plugin_hooks.php I have this written out:               //Eleven34 Studios Staff Manager Menu          function e34s_staff_plugin_menu() {         add_menu_page('Staff','Staff','read','e34s-staff','e34s_staff_list',         '/wordpress/wp-content/plugins/e34s_time_card/includes/images/e34s_staff_icon.png',22);     }          function e34s_staff_list() {             include ('staff/staff.php');     }          add_action('admin_menu','e34s_staff_plugin_menu');          //Submenu items     function e34s_staff_plugin_add_staff() {         add_submenu_page( 'e34s-staff', 'Add Staff', 'Add Staff', 'read', 'e34s_staff_add_staff', 'e34s_staff_add_staff_callback' );      }          function e34s_staff_add_staff_callback() {             include ('staff/add_staff.php');     }          add_action('admin_menu', 'e34s_staff_plugin_add_staff');      Then after the user is added successfully I want it to redirect to the staff page that lists all of the staff members.


Most efficient way to get posts with postmeta

I need to get a bunch of posts with their metadata. Of course you can't get metadata with a standard posts query, so you generally have to do a `get_post_custom()` for each post. I'm trying with one custom query, like this:               $results = $wpdb->get_results("         SELECT  p.ID,             p.post_title,             pm1.meta_value AS first_field,             pm2.meta_value AS second_field,             pm3.meta_value AS third_field         FROM    $wpdb->posts p LEFT JOIN $wpdb->postmeta pm1 ON (                 pm1.post_id = p.ID  AND                 pm1.meta_key    = 'first_field_key'             ) LEFT JOIN $wpdb->postmeta pm2 ON (                 pm2.post_id = p.ID  AND                 pm2.meta_key    = 'second_field_key'             ) LEFT JOIN $wpdb->postmeta pm3 ON (                 pm3.post_id = p.ID  AND                 pm3.meta_key    = 'third_field_key'             )         WHERE   post_status = 'publish'     ");      Seems to work. It trips up if you use any of those meta fields in a way that allows multiple meta values for it on the same post. I can't think of a join to do that. So, question 1: Is there a join, sub-query, or whatever, to bring in multiple- value meta fields? But question 2: Is it worth it? How many `postmeta` table joins do I add before a 2-query approach becomes preferable? I could grab all post data in one query, then grab all relevant postmeta in another, and combine the meta with the post data in one resultset in PHP. Would that end up being quicker than an single ever-more-complex SQL query, if that's even possible? I always think, "Give as much work as possible to the database." Not sure on this one!


A sports wordpress website

Hello wordpressers   Is there a way of joining custom post types? One custom post type for **players** and another custom post type for **results**? What i'm trying to do is use some post from the custom post type **players** on post from custom post type **results** , something like this: man unt 2 - 1 valencia   i have to use players from custom post type **players** to show the line up of Man Unt for example. That way, i can use custom fields from cpt **players** as for example the picture of a player i'll be wait for an answer. Thanks for your help :)


Formating the_terms() function output

This code:               <?php the_terms($post->ID, 'type') ?>      Gives:               Tag        What do to if I want to display only "Tag" word, not link eg.               Tag      Thanks!


Post slider with custom post type

I'm trying to create a post slider, but I'm stuck at this point. I have created a taxonomy named 'slideshow' and a custom post type 'slider'. In this custom post type 'slider' , I have assigned a taxonomy 'slideshow' ![enter image description here](http://i.stack.imgur.com/8uGt0.png) This working fine, but no matter what I've tried for the query, I still cannot get the images which is assigned for homeslide taxonomy ONLY. Is there a better way to create a post slider. Any sugggestions will be appreciated. Here is my code:               <?php          function wms_slider_init() {     $labels = array(     'name' => 'Slider',     'singular_name' => 'Slider',     'add_new' => 'Add Slider',     'add_new_item' => 'Add New Slider',     'edit_item' => 'Edit Slider',     'new_item' => 'New Slider',     'all_items' => 'All Sliders',     'view_item' => 'View Slider',     'search_items' => 'Search Sliders',     'not_found' =>  'No Slider found',     'not_found_in_trash' => 'No Slider found in Trash',      'parent_item_colon' => '',     'menu_name' => 'Sliders'     );          $args = array(     'labels' => $labels,     'description'   => 'Holds our Slider poste specific data',     'public' => true,     'publicly_queryable' => true,     'show_ui' => true,      'show_in_menu' => true,      'query_var' => true,     'rewrite' => array( 'slug' => 'slider' ),     'capability_type' => 'post',     'has_archive' => false,      'hierarchical' => true,     'menu_position' => 5,     'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes')     );           register_post_type( 'slider', $args );     }     add_action( 'init', 'wms_slider_init' );     add_action( 'init', 'wms_create_slider_taxonomies', 0 );          //create SlideShow Category for the post type "slider"     function wms_create_slider_taxonomies()      {     // Add new taxonomy, make it hierarchical (like categories)     $labels = array(     'name'                => _x( 'SlideShows', 'taxonomy general name' ),     'singular_name'       => _x( 'SlideShow', 'taxonomy singular name' ),     'search_items'        => __( 'Search Genres' ),     'all_items'           => __( 'All SlideShows' ),     'parent_item'         => __( 'Parent SlideShow' ),     'parent_item_colon'   => __( 'Parent SlideShow:' ),     'edit_item'           => __( 'Edit SlideShow' ),      'update_item'         => __( 'Update SlideShow' ),     'add_new_item'        => __( 'Add New SlideShow' ),     'new_item_name'       => __( 'New SlideShow Name' ),     'menu_name'           => __( 'SlideShow' )     );              $args = array(     'hierarchical'        => true,     'labels'              => $labels,     'show_ui'             => true,     'show_admin_column'   => true,     'query_var'           => true,     'rewrite'             => array( 'slug' => 'slideshow' )     );          register_taxonomy( 'slideshow', array( 'slider' ), $args );     }          ?>


CPT: archive-cpt.php VS custom page template

I've created a CPT named `portfolio`. Now i want to create a page which will act as an INDEX for this CPT. Now i've two choices .... a) Make a custom template having custom WP_Query. In this way i can assign this template to any page and that page will work as an index. b) Make `archive-portfolio.php` instead, which will act as an INDEX. Now i've a few questions ... 1: Which is the correct approach? 2: If (a) then what is the actual usage of `archive-cpt.php` page then? 3: If (b) is correct approach, is there any possibility to make this page available in wordpress menu manager by default and also in the drop down menu (located at `Setting->Reading`) to use it as front page?


Undefined WP_Query::has_posts()?

This must be wrong. I was testing something so I did:               $queried_post = new WP_Query(array('posts_per_page' => 5, 'offset'=> 1, 'category' => 1));     var_dump($queried_post->has_posts()); exit;      And I get the error:                Fatal error: Call to undefined method WP_Query::has_posts()       I am working with this inside a class INSIDE the theme .... `var_dump($queried_posts);` shows 5-6 posts. even if their were no posts I would get false. I should get .... true ....


getting parent page id when using custom menu.

Im using custom menus to display a menu using wp_nav_menu(). I want to get the_content() of the parent in the menu, without setting it as a parent page in pages. Is there a way to get the parent id (in php). I can see that the wp_nav_menu gives the parent item a special class name, so i believe i should be able to retrieve that items id, and do something with it before the page loads. Is this possible? Thanks!


Nginx + W3 Total Cache not working

I have a Ubuntu 12.10 x64 server running Nginx + MySQL, i've installed everything and my wordpress site is perfect. But, at the moment i installed W3 Total Cache, i got an error from Minify which blinked fast. The W3 panel says everything its ok, but when i load the site, it appears that it didnt loaded the JS and CSS minified. I have to enter FTP credentials on my wordpress when i want to update some plugin or the core. I've heard that it does have something related, like my php user (www-data user?) doesnt have permissions to write. My www-data user group has permissions to write on all my wordpress site, chmod 775. I've tried to chmod 777 the cache folder without success. The site just doesnt create the minified files


Give wp link pages it's own template

Here's the scenario, I'm working on a site with 100s of of paged posts using the wp_link_pages tag. The issue I'm having is that they're things I want displayed on the main post that I don't want display of the paged parts of the post and vice versa. How can I achieve that? And is it possible to give the paged parts of a post their own template?


Order Custom post type loop by custom field (datepicker)

I know there are a lot of articles and documentation on this but I can't seem to figure it out. I have a custom post type 'agenda' wich is made for events. I want to sort this by the eventdate. For this, I made a custom field (datepicker) using the ACF plugin. I've found some documentation on the ACF website wich learned me how to echo the date in dutch format and also an article about sorting the posts by custom meta value. But I can't get it to work. The key for my custom field is: datum_agenda Codes I have already tried ( in the $args of the loop):               'orderby' => 'datum_agenda'      &               'meta_key'      => 'datum_agenda',     'orderby'       => 'meta_value_num',     'order'         => 'DESC'      What am I doing wrong here? Seems like my code can't seem to find my meta_key or something because it still sorts by the autovalue.. (the normal post date)


echo or return?

> **Possible Duplicate:**   >  append_content help i have a code which is use to display twitter tweets but the problem is, it is displaying before the content of post, i know the problem is with echo, cause it is echoing first and then the post is coming, so the post comes after the tweets, when i tried to make the echoes to return then the tweets are not coming here is my code               function append_the_content1($content) {      //if(get_option('tweetID')!=null){         $content .= "

".tweet(get_option('tweetID'))."

";           return $content;        //}         //else{         //return $content;         //}     }     add_filter('the_content', 'append_the_content1');     function tweet(){     $doc = new DOMDocument();     if (get_option('tweetID') != null) {     if($doc->load('http://twitter.com/statuses/user_timeline/'.get_option('tweetID').'.rss')) {       $output = "
";                 # number of
 elements to display.  20 is the maximum       $max_tweets = 5;                $i = 1;       foreach ($doc->getElementsByTagName('item') as $node) {         # fetch the title from the RSS feed.          # Note: 'pubDate' and 'link' are also useful (I use them in the sidebar of this blog)         $tweet = $node->getElementsByTagName('title')->item(0)->nodeValue;              # the title of each tweet starts with "username: " which I want to remove         $tweet = substr($tweet, stripos($tweet, ':') + 1);                 # OPTIONAL: turn URLs into links         $tweet = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@',                '$1', $tweet);              # OPTIONAL: turn @replies into links         $tweet = preg_replace("/@([0-9a-zA-Z]+)/",                "@$1",                $tweet);              $output = "Twiiter Updates:
". $tweet  . "
\n";                   if($i++ >= $max_tweets) break;       }        $output = "
\n";       return $output;     }     }     }


Location Based Permalink

I'm having trouble creating a location based url for my site. Here is the url format I wanted: http://domain.com/topic/united-states/new-york-ny/brooklyn/5th%20Ave%20Gym/123 The topic is the custom post type and 123 is the ID. "united-states/new-york- ny/brooklyn" is the 3 level categories. First I found a way to upload all the US states and cities into the category table: wp_terms and wp_term_taxonomy and assigned to the proper hierarchy. But there are total of 30000+ cities and states and now every time the page loads, it takes forever and a lot of time it's getting a timeout error. I'm not sure there is the right way to do it. I'm trying to ajax the category in the admin page but have no success. Please help... mm


redirecting from a general category page to another specific one

can anyone tell me what's the best way to redirect a general category page to a specific one? for example:               categoryName1 -> subcategoryName1                   -> subCategoryName2                    -> subCategoryName3     categoryName2 -> subCategoryName4      and when i click in the menu "categoryName1" (but **not** on "categoryName2") i'm redirect automatically into "subcategoryName2". thanks a lot!


Wordpress does not output "post" class when calling post_class() function

I am writing an ajax call to a server which requests a next set of posts. However when I try to generate a list of posts I am having an issue with post_class() function. It does not add a "post" class to post.               $osetin_query = new WP_Query( $args );     while ($osetin_query->have_posts()) : $osetin_query->the_post(); ?>       <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
     <?php endwhile; ?>      Result:
      Expected result:


wp-query, pull children of parent page

So here's what I'm trying to do: I'm trying to develop a theme that shows any sub-pages on the parent page. I've gotten this running successfully with a WP_query and a simple loop:                    <?php $childargs = array( 'post_parent' => $post->ID, 'post_type' => 'page', 'posts_per_page' => '-1', 'orderby' => 'menu_order', 'order' => 'ASC' );           $child = new WP_Query($childargs);          // only show the navbar on pages with sub-children     if ($child->have_posts()) { ?>

             <?php if ($child->have_posts()) : while ($child->have_posts()) : $child->the_post(); ?>                 <a href="<?php the_permalink() ?>"><?php the_title(); ?>             <?php endwhile; endif;                  wp_reset_query(); ?>

     <?php } ?>      This code displays absolutely nothing on the child pages themselves, which is the correct behavior. I want the child pages show this nav, but I don't know how to do that. $childargs references the postid, which in the case of the child page will be the child page (which has no children of its own). How can I modify this code so that it not only displays on parent pages, but on child pages as well? A demo page can be found here: http://sheepish- lab637.com/one/about/ with sub-children of its own. Edit: perhaps this could be better accomplished by a Wordpress menu, which would also have the advantage of bundling the default current_page_item classes and such. Thanks!


Help getting previously visited pages ID

I'm using ACF plugin and I want to pull a custom field from the previous page. I have a WP site that has a homepage and then 20 sub pages. Each sub page is for a specific city and each city has its own contact phone number. Then interested viewers will go to an apply page. So the flow will hopefully be HOME » Your city page » Apply page. Rather than make an Apply page for every city, I want to pull the custom field from the city page the viewer visited before arriving at the apply page. I found this info: Get previously visited page ID But it's a bit advanced for me. Anyone willing to dumb it down and show me what this might look like in practice? The ACF plugin has the ability to pull a custom field from another page using IDs:
<?php the_field('city_phone', 123); ?>
      That would return the custom field city_phone from post 123. How would I get the previous pages ID into 123?


How to use the same code for multiple pages?

The code below prevents a page (defined by its title) from being deleted. When I try to implement two occurrences of this code (one for each page I want to prevent from being deleted) I receive the white screen of death. How would I list more than one page by title and prevent both from being deleted?               add_action( 'wp_trash_post', 'stop_deleting');     function stop_deleting($page){         $page = get_page_by_title( 'About' );             if ($page)                 die('You are not allowed to delete this page');     }


How to add Categories to the top menu of the website?

How can I add links to the categories (for example, Category-1) to the top menu of my WordPress blog? Only Pages appear here. ![top menu from my blog](http://i.stack.imgur.com/0HQN6.png)


Can index.php take over for front-page.php in template hierarchy on second page?

I'm confused by the template hierarchy in WordPress. I have `front-page.php` in a theme I'm developing. It looks great and it works, but then when a user clicks 'Older Posts', it just shows the same content as before, but the URL is changed to ?paged=2. Looking at the diagram about Template Hierarchy on Wordpress Codex, since the second page is _not_ the front page, I'd expect it to fall through `front- page.php` to either `home.php` or `index.php`, but it's not doing that; it's just loading `front-page.php` over and over again. So how can I load, say `index.php`, for every page other than the front page? And also, am I crazy for expecting what I expect? The second question might be subjective. Please only answer the first if you think I am crazy.


Fatal error Call to a member function insert() on a non-object

I am running Custom Query on `functions.php`:               function subscribers(){         if(isset($_POST["email"])){             $email = $_POST["email"];             echo $wpdb->insert($wpdb->easymail_subscribers, array('email' => $email));         }     }     add_action('wp_ajax_subscribers', 'subscribers');     add_action('wp_ajax_nopriv_subscribers', 'subscribers');      This is being call by AJAX request. I got this error message: > **Fatal error** : Call to a member function insert() on a non-object in > **G:\xampp\htdocs\Projects\newsite\wp-content\themes\generic\functions.php** > on line **235**   > Tried really hard to solve this, but was not possible.


Disable pasting of images into wordpress editor

I have a user who loves to do this, It works fine for the website, but when it gets transferred over to the newsletter it breaks the newsletter. Is it possible to disable pasting of images into the WordPress editor without removing the visual editor?


get_post_meta - get a single value

When I do `get_post_meta($post->ID, "company_wp_box_g", false)` I am getting back an array of key/values pairs.               array (size=1)           0 =>              array (size=7)               'f_name' => string 'John Doe' (length=14)               'f_company_name' => string 'Something Ltd' (length=0)               'f_description' => string '' (length=0)               'f_phone' => string '0208 992 7222' (length=13)               'f_cell_phone' => string '07809775200' (length=0)               'f_email' => string 'jonh.doe@gmail.com' (length=0)               'f_web' => string 'doe.com' (length=0)      **How to get a single value for example`f_name`?** just FYI everything is taking place inside `foreach loop`:               $args = array(         'numberposts' => -1,         'post_type' => 'company'     );          $posts = get_posts($args);                 foreach ($posts as $post){               // do stuff          }


Rewrite URL for taxonomy listing

I have created several custom taxonomies and each "archive" can be viewed on the url mysite.com/taxonomy/term Is it possible to rewrite the URLs so my taxonomy archive lives under for example mysite.com/calendar/taxonomy/term instead?


Shortcode displays only default attribute values

For some reasons every shortcode, that I try to add to functions.php, displays only default attribute value and ignores what I specify in a post. E.g.:               function my_shortcode( $atts ) {         extract( shortcode_atts(             array(                 'id' => '18',             ), $atts )         );         return $id;     }     add_shortcode( 'sc', 'my_shortcode' );      So I use shortcode `[sc id="81"]` and expect echoing `81` but I get `18`. BTW I use child theme, and latest version of wordpress. I'm really stuck. Thanks for any help.


Randomize widgets displayed in my sidebar

I have a sidebar which might have any number of widgets. I can count the number of widgets that exist in the sidebar. How do I display randomly only one of the widgets in my sidebar at each page load? Use: We have specials which we display as widgets, but we only want to display one widget's content at a time in the footer of the site. re: the count code               <?php $the_sidebars = wp_get_sidebars_widgets();     echo count( $the_sidebars['center-footer'] ); ?>      re: generating a random widget instance               <?php echo rand(1, count( $the_sidebars['center-footer'] )); ?>


Exclude posts based on an array

I'm using a custom meta box to output a list of post IDs within a particular post type ("Publications" in this example). Is there a way I can output this array into a custom loop to only show posts with those ID's? This is the code I am using; Meta box array               $related = get_post_meta( get_the_ID(), 'ps_related-publications', false );     foreach ( $related as $meta );      WP_Query loop               $related_publication_widget = new WP_Query( array (         'post_type' => 'publications',         'p' => $meta,          'posts_per_page' => '-1',     ));while ( $related_publication_widget->have_posts() ) :      $related_publication_widget->the_post();      Because the ID's are output as just numbers (Ie; without the ',' required to separate ID's in a query, it's only showing the latest post as oppose to all of them as defined in the loop. Any ideas?


how to hide sub menu in members page from visitor and not login user

I just learned how to create menu in buddypress members page. I have created a sub menu in member's page along with activity, profile, message, etc.   How can i hide this menu from users and visitors which are not logged in?   Only logged in users should able to see that menu.


Insert html after certain amount of posts?

Is it possible after a certain amount of posts to close of a list and start a new one, like so... Particularly after 6 posts...

Post content

Post content

Post content

Post content

Post content

Post content

Post content

Post content

Post content

Post content

Post content

Post content

      Something like this but obviously it needs to count he posts, if at all possible?                  <?php $loop = new WP_Query( array( 'post_type' => 'work','posts_per_page' => '-1' ) ); ?>

               <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
                      <?php the_content(); ?>                              <?php the_post_thumbnail( 'work-thumb' ); ?>
                    <?php endwhile; ?>

      I'm not even sure if possible, but any help would be great thanks :)


Add CSS class to every image

I want to add a CSS class "myimg" to every image both inside and outside of a post. What is the best way to approach this?


Wrap Shortcodes and wpautop

WP has me pulling my hair out at the moment (past few days trying to solve). Trying to do some simple shortcodes which wrap around various points of an article. However wpautop() I believe is wreaking havoc. Ive tried various suggestions found around the net including viperbonds ( http://www.viper007bond.com/2009/11/22/wordpress-code-earlier-shortcodes/ ) to control when the shortcodes run but I am still getting various annoyances whether the shortcode runs before or after wpautop. It only formats out the shortcode unblemished with wpautop disabled entirely but the rest of the post is then not formatted. I have a shortcode [REVIEW_SUMMARY]The conclusion text/paras here... written by editor[/REVIEW_SUMMARY] in simple terms it builds out a specific consistent set of titles and from various custom meta data builds out scoring, imagery etc. Works fine for the most part. The problem is a scoring tile we have which outputs as part of the final content of this shortcode:

9.9Out of 10
Our score
      Full example output (stripped a bit because it be too long) of shortcode with wpautop disabled:

Summary

Item Reviewed

9.9Out of 10
Our score

Paragraph1...          Paragraph2...          Paragraph3...          Paragraph4...
              It definitely has no line breaks and so forth that WP should format (apart from what you would expect from the paragraph's. However turning wpautop it on it generates ( ran before wpautop() ):

9.9Out of 10

Our score
      Full version (stripped a bit) of generated code and ran before wpautop() runs:

Summary

Item Reviewed

9.9Out of 10

Our score

Paragraph1

Paragraph2

Paragraph3

Paragraph4/p>

      PLEASE NOTE: then Para4 end is actually like that. Its missing the bracket < and the inserted before Our score. At no point should there be any line breaks I have not told it to nor should there be an open tag not to mention it doesn't close it and the rogue broken end p tag. Full version (stripped) ran AFTER wpautop():

Summary

Item Reviewed

9.9Out of 10
Our score

Para1...

Para2...

Para3...

Para4...
      Im absolutely stumped as to what is generating the rubbish. The above is an example ran before wpautop() runs which keeps all paragraphs on the rest of the content within the shortcode in tack.


Remove wp-mediaelement.css from wp_head

I´m customizing the new core audio/video player via CSS in my _styles.css_. I tried to remove the _wp-mediaelement.css_ with the following code in functions.php, because I don´t need it anymore.               function custom_deregister_styles()     {       wp_deregister_style( 'mediaelement');     }     add_action( 'wp_print_styles', 'custom_deregister_styles', 100 );      The problem is, that this function removes the call of _mediaelementplayer.min.css_ and _wp-mediaelement.css_. The following doesn´t work, too.               function custom_deregister_styles()         {           wp_deregister_style( 'wp-mediaelement');         }         add_action( 'wp_print_styles', 'custom_deregister_styles', 100 );


how to attach an image to a custom post type in wordpress using just code

I'm dynamically creating a custom post type in code (not in the editor) and I have an image I want to attach to my custom post type as a post thumbnail, and have it resized, etc. How do I do that. I'm successfully creating the custom post type using wp_insert_post(). I've looked at wp_save_image(), wp_save_image_file(), load_image_to_edit(), get_attached_file() and others, but they all seem to require an image in $_POST. I also looked at wp_insert_attachment() and update_attached_file() which seemed promising, but were not image centric.


TinyMCE doesn't work correctly in the Media Modal Window

I need to add TinyMCE to descriptions of images. For it, I'm using this code in my functions.php:               function add_tiny_mce_hook() {           if (function_exists('wp_tiny_mce')){          wp_tiny_mce(false,              array(                 'remove_linebreaks' => false,                  'mode'              => 'textareas',                  'editor_selector'   => 'my-tinymce-class')             );     }}     function alternate_tiny_mce_method($fields, $post) {     if (isset($fields['post_content'])) {         $value = $fields['post_content']['value'];         $label = $fields['post_content']['label'];         $name = 'post_content';         $fields[$name] = array(             'label' => $label,             'input' => 'html',             'html' => '<textarea name="attachments['.$post->ID.']['.$name.']" id="'.$name.'-'.$post->ID.'" class="my-tinymce-class">'.nl2br($value).'</textarea>'         );     }     return $fields;}     add_action('admin_head', 'add_tiny_mce_hook');     add_filter('attachment_fields_to_edit', 'alternate_tiny_mce_method', 10, 2);      On the Edit Media page works fine (wp- admin/media.php?attachment_id=XXX&action=edit). But, I have a problem after opening "Add an Image" modal window, and switching to the "Gallery" tab, from "Edit Post". I can't add a link via TinyMCE editor. Every time I click Add Link from the pop-up modal nothing happens. I see the problem in gallery.js (gallery.dev.js; wp-admin/js/gallery.js; WordPress loads this JS). There are 3 lines that do me the trouble: .... tinymce = w.tinymce; tinyMCE = w.tinyMCE; t.editor = tinymce.EditorManager.activeEditor; .... When I drop "tinymce = w.tinymce;" and "tinyMCE = w.tinyMCE;" and replace "tinymce.EditorManager.activeEditor;" with "w.tinymce.EditorManager.activeEditor" - works fine. But, I don't want to do a core mod to WordPress My WordPress version is 3.2.1 Any help, please.


Problem with date comparison for custom fields

This question follows on from: Can you do a date comparison on a custom field and query two or more custom taxonomies using WP_Query? and a similar thing here: http://stackoverflow.com/questions/7080352/multiple- custom-fields-stored-as-meta-keys-how-to-connect-with-the-post/ I'm trying to compare a start and end date which are custom fields in a post type of exhibitions which is set up using a jquery date picker with dateFormat : 'dd-mm-yy'               $today = date('Y-m-d', strtotime('-6 hours'));           $args = array(         'showposts' => 1,         'orderby' => rand,         'post_type' => 'exhibition',         'meta_query' => array(             relation' => 'AND',             array(             'key' => 'startDate',             'type' => 'CHAR',             'value' => $today,             'compare' => '>='              ),             array(             'key' => 'endDate',                 'type' => 'CHAR',                 'value' => $today,                 'compare' => '<='                  ),        )     );      What I don't understand is how this is being saved into the meta data - presumably it will be type CHAR and why my query doesn't seem to work correctly