WP & Server Speed [Teacher Question]

I'm a teacher and have used multisite WP for two years now as a resource for completing assignments. This spring semester, I have the most students that I've had on my site (30). Prior to this semester I've a max of 26 with no problems. Unfortunately, I've had constant slow downs: **either timing out, 500s, or the WP error establishing connection to database**. I use hostmonster as my host and have emailed them. They told me to install a cache plugin and activated it site-wide (WP Super Cache). This didn't really help, though. Besides server-side issues, I'm wondering about two different possible problems:   1. Connection speed / firewall issue in my school district (which I'm waiting to hear back)   2. The location of this install on the grandchild level of the server: public_html (main domain for the server) -> add-on domain -> sub-directory -> student sites Could #2 be my problem? The server is based off of my personal site/domain and any other additional. It views add-on domains as sub-directories (domain1.com/domain2), but parks it as it's own domain (domain2.com). Could all the sub-directories be the problem? Is there anything I could be missing? Does this make sense? Help? Please and thank you.   :)


How to combine custom fields to make one order-able value

I have three different custom fields, for day (01-07) hour (01-12) and minute (00-59) and I really need to combine them into one custom value so I can actually order them using wp_query. I cant actually just use custom field for the whole thing; it would be easier I know, but it needs to be easy on the user to input day/time. So that option is out of the question. Is it possible to join those three numerical values for use in wp_query? Thanks in advance for any help. David


Monkey Man Rewrite Analyzer says my rule will trigger but it doesn't

I installed Monkey Man Rewrite Analyzer, i got a rule installed, it shows in the list, if i test it with monkey man it says it will fire but it doesn't in reality, whats wrong?               add_action('init', array($this, 'register_crr_jsonwebservice'), 99);          public function register_crr_jsonwebservice() {              //Add the rewrite rule for this specific json controller         add_rewrite_tag( '%ticket%', '([a-zA-Z0-9]+)');         add_rewrite_rule( 'cjson/fullticket/([a-zA-Z0-9]+)/', 'index.php?p=1312&ticket=$matches[1]', 'top' );         flush_rewrite_rules();          }      Test this rule in MMRA: > cjson/fullticket/231412tgsxcasfasdfas/ Works fine, test it out on wordpress directly copying the same url? 404, not found... what am i doing wrong?


gravity forms : use previous dropdown choice as variable in gform_pre_render?

I have a question regarding gform_pre_render? I have dealer form. Which basically you choose your county, and then your dealer. **Dropdown A = Dealer Country   Dropdown B = Dealer Name** I have about 15 countries, and I am using get_terms in the gform_pre_render function to list all my countries that I have assigned to a dealer post...               // Dropdown A - Dealer Country     add_filter("gform_pre_render", "dropdown_dealer_country");     add_filter("gform_admin_pre_render", "dropdown_dealer_country");     function dropdown_dealer_country($form){              if($form["id"] != 3)            return $form;              $terms = get_terms("dealer-country");              $items = array();         $items[] = array( "text" => __('Select country...','mission-theme'), "value" => 0 );              foreach($terms as $term)             $items[] = array( "text" => $term->name, "value" => $term->slug );              foreach($form["fields"] as &$field)             if($field["id"] == 6){                 $field["choices"] = $items;             }              return $form;     }      OK so the above function works perfectly in Dropdown A. Now what I am trying to do in Dropdown B is display all my dealer names. I have named each dealer custom post-type title with the name of the dealer, and this is what I am pre populating my secondary drop down with...               // Dropdown B - Dealer Name     add_filter("gform_pre_render", "dropdown_dealer_name");     add_filter("gform_admin_pre_render", "dropdown_dealer_name");     function dropdown_dealer_name($form){              if($form["id"] != 3)            return $form;              $dealers = get_posts(array(             "post_type" => "dealer",             "dealer-country" => $dealerCounty,             "post_status" => "publish",             "orderby" => "title",             "order" => "ASC",             "posts_per_page"  => -1         ));              $items = array();         $items[] = array( "text" => __('Select dealer...','mission-theme'), "value" => 0 );              foreach($dealers as $dealer)             $items[] = array( "text" => $dealer->post_title, "value" => $dealer->post_name );              foreach($form["fields"] as &$field)             if($field["id"] == 7){                 $field["choices"] = $items;             }              return $form;     }      ...and as you can see in line 11, I have a variable in my get_posts array **"dealer-country" => $dealerCounty** My question, is it some how posible to get the choice that is made in **Dropdown A** into my $dealerCounty variable in my **Dropdown B** function? Any tips or help would be much appreciated as my **Dropdown B** is currently very long, and I need to filter it down by country.    If any one knows a method that would be great. Thanks in advance.


Need custom picture field for pages

I want to have a picture or multiple pictures on each page in wordpress. AFAIK there are two standart ways of doing this   1. in WYSIWYG editor, attach file etc   2. widgets. Problem is, those wont do for my clients. So how can I make a custom field on each page, where the user selects a pic if he wants. I know there is a plugin, "sidebar per page" but i would like to do it without plugin, and if possible all the page editing happens on admin>pages>page x without the need to go to widgets are and so on. Pls share if there is a way to do this, or what it would take. TY


php to add a link into wp widget without specific url

I'm trying to write a plugin to a specific page that the plugin creates. The issue is how do i add a link to that page from the widget. I know the page but the url has to be picked up from the site it is installed on.


wordpress radio button on single post page

I have two radio buttons that enable/disable the particular category posts from my wordpress homepage, I have also added these two buttons on single.php, this is what I'v done, If the post belong to category 'ABC' and button is enable then show the following messgae, "PLEASE Disable the button" (the button is right under this message) but when i choose disable option i am redirecting to the index.php automatically :S it works really fine for category pages but doesn't work for single.php , WHY? buttons code,
         <form name="f1" method="POST" action="<?php echo $PHP_SELF;?>">             Family filter:

<input type="radio" name="r1" value="o" onClick="submit();" <?php echo (!$_SESSION['r1'] || $_SESSION['r1'] == "o") ? 'checked="checked"' : ''; ?> />On

<input type="radio" name="r1" value="p" onClick="submit();" <?php echo ($_SESSION['r1'] == "p") ? 'checked="checked"' : ''; ?> />Off

         </form>
      this is code inside category.php and it is working fine,               <?php               if ( in_category($category) && $_SESSION['r1'] == "o" ) { // See if the user is inside restricted category or if the Family filter is On (if one)             echo "
";             echo "Please turn Off the 'Family filter' in order to read these SMS.
 these text messages are not suitable for user unders age 17";             echo "
";             echo "
";         }     ?>      This is the code inside single.php,               <?php                      $currentCat = get_the_category();  // Get the Array of Categories of current Post                 $filterCategory = $currentCat[0]->cat_ID; // store the First category in filterCategory                 if (($filterCategory == $category) && ($_SESSION['r1'] == "o" )){ //                  ?>          please disable the button
         <form name="f1" method="POST" action="<?php echo $PHP_SELF;?>">             Family filter:

<input type="radio" name="r1" value="o" onClick="submit();" <?php echo (!$_SESSION['r1'] || $_SESSION['r1'] == "o") ? 'checked="checked"' : ''; ?> />On

<input type="radio" name="r1" value="p" onClick="submit();" <?php echo ($_SESSION['r1'] == "p") ? 'checked="checked"' : ''; ?> />Off

         </form>
      This is the code inside every one of them,               $choice = $_POST['r1'];         $id = $category;         if ($choice == 'o') // Family Filter !!! If 'ON'             query_posts("cat=-.'$id'&".$query_string); // Remove Post from Category of particular ID         else if (!$_SESSION['r1'] || $_SESSION['r1'] == "o") // If there is nothing in Session (opening page for the frst time) Remove the posts             query_posts("cat=-.'$id'&".$query_string);          else {             $_POST['r1'] = 'p';         }      The code works for index.php / archieve.php but not working on single.php (i am redirecting onto index,php after choosing "disable/off".


list category posts are not ordering any more

I am not sure if this started with the latest upgrade (didn't notice it until yesterday), but the lists are no longer ordering by either asc or dsc. Doesn't matter which I chooose, or which list, they have all stopped ordering alphabetically. (I use orderby=title order=asc)


Metabox Input Not saving

I haven't made any meta-box's in quite some time so quickly threw together this one for a website I'm developing. My problem is that when I input some text in the box's and hit save the text disappears so I'm left with empty text box's and no saved data. I'm guessing this is something to do with my `save_post` function updated* Now the title field works but the content one doesn't.               //intialising the metabox and using the callback function                    add_action( 'add_meta_boxes', 'owl_mb_create' );          function owl_mb_create() {                  add_meta_box( 'owl-meta', ' Inner Page Box', 'owl_mb_function', 'page', 'normal', 'high' );          }          ?>               <?php          function owl_mb_function( $post ) {                  //retrieve the metadata values if they exist             $owl_mb_content_one = get_post_meta( $post->ID, 'owl_mb_content_one', true);             $owl_mb_title_one = get_post_meta( $post->ID, 'owl_mb_title_one', true);             $owl_mb_content_two = get_post_meta( $post->ID, 'owl_mb_content_two', true);             $owl_mb_title_two = get_post_meta( $post->ID, 'owl_mb_title_two', true);             $owl_mb_content_three = get_post_meta( $post->ID, 'owl_mb_content_three', true);             $owl_mb_title_three = get_post_meta( $post->ID, 'owl_mb_title_three', true);                  echo 'Please fill in the forms below';     ?>
title:<input type="text" name="owl_mb_title_one" value=" <?php echo esc_attr( $owl_mb_title_one ); ?>" />

content:
<textarea cols="1" rows="8" name="owl_mb_content_one" id="excerpt"value=" <?php echo esc_attr( $owl_mb_content_one ); ?>"></textarea>

title:<input type="text" name="owl_mb_title_two" value=" <?php echo esc_attr( $owl_mb_title_two ); ?>" />

content:
<textarea cols="1" rows="8" name="owl_mb_content_two" id="excerpt"value=" <?php echo esc_attr( $owl_mb_content_two ); ?>"></textarea>

title:<input type="text" name="owl_mb_title_three" value=" <?php echo esc_attr( $owl_mb_title_three ); ?>" />

content:
<textarea cols="1" rows="8" name="owl_mb_content_three" id="excerpt"value=" <?php echo esc_attr( $owl_mb_content_three ); ?>"></textarea>               <?php } ?>               <?php          //hook to the save the meta box data          add_action( 'save_post', 'owl_mb_save_meta' );                  function owl_mb_save_meta ( $post_id ) {                                  //save the metadata                          update_post_meta( $post_id, 'owl_mb_content', strip_tags( $_POST['owl_mb_content_one'] ) );                     update_post_meta( $post_id, 'owl_mb_title', strip_tags( $_POST['owl_mb_title_one'] ) );                     update_post_meta( $post_id, 'owl_mb_content', strip_tags( $_POST['owl_mb_content_two'] ) );                     update_post_meta( $post_id, 'owl_mb_title', strip_tags( $_POST['owl_mb_title_two'] ) );                     update_post_meta( $post_id, 'owl_mb_content', strip_tags( $_POST['owl_mb_content_three'] ) );                     update_post_meta( $post_id, 'owl_mb_title', strip_tags( $_POST['owl_mb_title_three'] ) );                  }          ?>      Many Thanks :)


Post Format single-loop.php using get_template_part

I have set up to use post formats gallery and video in addition to the standard. I am editing the loop-single.php to give it different layouts for each post format, but I'm to include get_template_part for each post format. This is what I have:               <?php     /**      * The loop that displays a single post.      *      * The loop displays the posts and the post content.  See      * http://codex.wordpress.org/The_Loop to understand it and      * http://codex.wordpress.org/Template_Tags to understand      * the tags used in it.      *      * This can be overridden in child themes with loop-single.php.      *      * @package WordPress      * @subpackage Twenty_Ten      * @since Twenty Ten 1.2      */     ?>          <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>               <?php              if ( has_post_format( 'gallery' )) {           // code to display the gallery format post here                get_template_part( 'news' 'gallery' ); // News Gallery Template (news-gallery.php)               } else if (has_post_format('video')) {            // stuff to display the video format post here                  get_template_part( 'news' 'video' ); // News Gallery Template (news-video.php)               }else {            // code to display the normal format post here                  get_template_part( 'news' 'standard' ); // News Gallery Template (news-standard.php)               }              <?php endwhile; // end of the loop. ?>               ?>      It is coming up with an error when I'm testing: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/judddev/public_html/pitch/wp-content/themes/pitch/loop-single.php on line 26 Any help would be greatly appreciated.


Publish a message on facebook after having posted a comment

I would like some advice on how to improve the code I use for allowing people to comment posts. Users can only submit a comment if they are connected with Facebook. I started developping this feature directly in the comments.php template. It works but there is another feature which permit people to publish a message on their wall if they tick a checkbox before sending the comment. I have some troubles for developping this functionnality because I need an instance of the Facebook class. I already have it in my comments.php and I was wondering if there was a way to use it instead of creating a new one. Here is the code : **comments.php:**               <?php      locate_template( 'include/facebook.php', true );          $config = array();     $config['appId'] = get_option( 'appId' );     $config['secret'] = get_option( 'secret' );          $facebook = new Facebook($config);     $session = $facebook->getUser();     if(!$session){         $loginUrl = $facebook->getLoginUrl(array('scope'=>'publish_stream, email', 'redirect_uri'=>'http://www.myredirecturi.fr'));     }          if( !isset( $session ) || empty( $session ) ){             ?>

                 <a href="<?php echo $loginUrl; ?>"><img src="<?php echo get_template_directory_uri(); ?>/img/btn-fb.png" alt="">

         <?php     }          $nb_coms = get_comments_number();     if( $nb_coms != 0 ){         wp_list_comments('callback=custom_comment&avatar_size=50');     }     ?>          <?php     if($session){             try {                 $me = $facebook->api('/me');             $username = $me['username'];             $firstname = $me['first_name'];             $email = $me['email'];                  // I display here my custom comment form                 }             catch(FacebookApiException $e){                 error_log($e);             }     }     ?>      **functions.php**               <?php     add_action( 'comment_post', 'custom_save_comment_data' );       function custom_save_comment_data( $comment_id ) {                add_comment_meta( $comment_id, 'fb_username', $_POST['fb_username'] );              //if( isset($_POST['publish']) ){         //  $params = array(         //                  'message'       =>  "Hurray! This works :)",         //                  'name'          =>  "This is my title",         //                  'caption'       =>  "My Caption",         //                  'description'   =>  "Some Description...",         //                  'link'          =>  "http://stackoverflow.com",         //                  'picture'       =>  "http://i.imgur.com/VUBz8.png",         //              );         //  $user = $_POST['fb_userid'];         //    $post = $facebook->api("/$user/feed","POST",$params);         //}     }     ?>      What do you recommend for pass the facebook object ? Does the way I developped these features is correct ? or should I create a plugin ? if it's the case, why ?


Limit number of characters in different excerpts

I've been using this little snippet from another answer on here to limit the number of characters that display in the excerpt;               add_filter('wp_trim_excerpt', function($text){             $max_length = 140;         if(mb_strlen($text, 'UTF-8') > $max_length){             $split_pos = mb_strpos(wordwrap($text, $max_length), "\n", 0, 'UTF-8');             $text = mb_substr($text, 0, $split_pos, 'UTF-8');         }              return $text;     });      The problem is that I now have multiple excerpts and one global character limit isn't a viable option anymore. Is there a way that I could define the character limit on individual excerpts? (So, for example, one excerpt could show 150 characters while another shows 200?)


Which post does a taxonomy term belongs to?

I’m having a page which displays all custom taxonomy terms for a particular type which I get from the URL. I use this code to retrieve all the terms:               $args = array(     'post_type' => 'mycustomposttype',     'programtype' => ’my-custom-taxonomy-term     );     $programtype = new WP_Query($args);     while ( $programtype->have_posts() ) : $programtype->the_post();     $terms = get_the_terms( $post->ID, 'my-custom-taxonomy );      This all works perfectly fine but then I want to produce a link, when pressing on each of the terms to redirect back to the original custom post it belongs to. Let me give an example: The custom post type “Programblock” with ID 19, has three custom taxonomy terms attached to it, which is called “events”. The three terms is listed on above mentioned page, but then I want to produce a link which takes them back to the custom post type page “Programblock” with the post ID as hashtag, like this: http://www.my-domain.com/programblock#19 How can I reverse this so Instead of asking “Which terms does this post has” I want to ask, “Which post does this term belongs to”. I hope I’ve explained myself clear enough, otherwise please ask. Sincere   - Mestika


Add class to the items in wp_list_pages

I just want to add a class for the active page in the wp_list_pages().Is it possible? If so can I provide a particular class for a active page. Here is my code for listing the parent page and its sub page.                      <?php                    $output = wp_list_pages('echo=0&depth=1&title_li= &sort_column=menu_order' );     if (is_page( )) {       $page = $post->ID;       if ($post->post_parent) {         $page = $post->post_parent;       }            $children=wp_list_pages( 'echo=0&depth=1&child_of=' . $page . '&title_li=&sort_column=menu_order' );       if ($children) {         $output = wp_list_pages ('echo=0&depth=1&child_of=' . $page . '&title_li= &sort_column=menu_order');       }     }     ?>
<a href="<?php echo get_permalink( $post->post_parent ); ?>" class="active">Home
     <?php      echo $output;                             ?>      Please help me.I want add the class name "active" to the active page in the wp_list_pages(). For example I want to display my WP pages as follows.If 1 select the sub page 3 I want to add the class active only to that particular page

Home

1

2

3

4

5


How to rewrite a URL to another rewritten URL without changing the address?

Just got to the end of a site build and the client is now saying the original site URL's need to stay the same and do not want to do 301 redirects due to loss of link juice. The structure of the site has changed so not possible to match the URL structure. I have been trying to figure out how to rewrite the URL's so that they stay the same in the address bar but map to different content. As an example Old URL: `advisories/sos-12-11` New WordPress rewritten URL: `relateditem/sos-12-11` Have tried:               RewriteRule ^advisories/([A-Za-z0-9-]+)$ index.php?relateditem=$1 [L]      With Permalinks set to custom (/%postname%) this maps through to the right location but changes the address in the address bar. With Permalinks set to default it just maps to the home page and does not change the address bar. Seems the two are interacting but cannot figure out how. Any help greatly appreciated!


Buddypress Fake (non-bot) Users

BuddyPress Newbie question: I have a brand new site running WP 3.3.1 and BP 1.5. Even before launch I am plagued with numerous fake users every day. I don't think they are bots, because I have a math question at registration, and email activation enabled. They register, usually with a gmail address, and then activate and post updates containing spam links of all sorts. I haven't been able to find any real ideas on how to stop non-bot spammers, and have pretty much given up on an automated solution. Barring that, is there a way to hold new users for admin approval and prevent them from posting until they are approved? Any solutions are greatly appreciated! Thanks! Diana


How to include sticky posts in 'Blog pages show at most' X number of posts?

I'm using the default Loop Code. I've set the 'Blog pages show at most' option in Settings > Reading to 11. In my home page -set to show Latest Posts- whenever I mark a post as 'Sticky' it's being added to the original 'Blog pages show at most' count, so the home page now shows 12 posts instead of 11. I want to avoid this! I want to keep 11 posts in total, that being -in the example above- 1 Sticky post plus 10 normal posts. Is this possible? I've already tested this with default themes and all plugins turned off. Any help will be very much appreciated. * * * So far I've found that I could modify the main query using pre_get_posts. What I intend to do then is query for only the sticky posts, and then merge that query with the main query. I found this snippet but I'm having problems converting that into a pre_get_posts working function.               $newsposts = array();          $sticky = get_option('sticky_posts');     $args = array(         'post__in' => $sticky,         'posts_per_page' => $num     );     $sticky_posts = get_posts($args);          if( count($sticky_posts) < $num ) {         $extras = $num - count($sticky_posts);         $args= array(         'post__not_in' => $sticky,         'posts_per_page' => $extras     );     $extra_posts = get_posts($args);     $newsposts = array_merge($sticky_posts, $extra_posts);     }     else $newsposts = $sticky_posts;


MP4 upload ok, but HTTP500 if I update the file (multisite)

I am trying to make available a mp4 video of ~500Mb but my connection is too slow to do this at home. To achieve this, I uploaded the video via ssh from school then i used the wordpress media manager to upload a mp4 file of 1 byte. Once this file is uploaded, I went through ssh to its directory then I moved the 500Mb file to replace it. The problem is after that I get an HTTP 500 error, even if : - both of the original file (1B) and the replacing file (500Mb) are given 644 perms and the same owner/group - I checked that the filename is the same, it can not be an error like this. Here is my htaccess :               AddType video/mp4 .mp4 .m4v          SetEnv REGISTER_GLOBALS 0     SetEnv ZEND_OPTIMIZER 1     SetEnv MAGIC_QUOTES 0     SetEnv PHP_VER 5          SetOutputFilter DEFLATE     AddOutputFilterByType DEFLATE text/html text/xml application/xhtml+xml text/plain application/javascript text/css     BrowserMatch ^Mozilla/4 gzip-only-text/html     BrowserMatch ^Mozilla/4\.0[678] no-gzip     BrowserMatch \bMSIE !no-gzip !gzip-only-text/html     SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary          ExpiresActive On     ExpiresByType image/jpg "access 1 year"     ExpiresByType image/jpeg "access 1 year"     ExpiresByType image/gif "access 1 year"     ExpiresByType image/png "access 1 year"     ExpiresByType text/x-javascript "access 1 month"     ExpiresByType application/x-shockwave-flash "access 1 month"     ExpiresByType application/pdf "access 1 month"     ExpiresByType image/x-icon "access 1 year"     ExpiresDefault "access 2 days"          RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]          # uploaded files     RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]          # add a trailing slash to /wp-admin     RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]     RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]     RewriteRule . index.php [L]      I can not figure out the problem. Does anyone know ? I forgot to specify that it is a multisite wordpress. Thanks a lot !


How To Grab All Type Of Attachments, But Images?

I need to get all file attachments which is not an image,   'post_mime_type' only accepts "any" or specific mime types, How to grab all type of attachments, but images?


Two posts in same div - WP loop

I would need the following in Wordpress:

Title 1

Title 2

Title 3

Title 4

      I know how to get posts with WP loop, but how can I wrap every two posts in .posts-wrapped div? I fetch the posts with WP_Query. Thanks! EDIT: So I tried few ways to do it. For example with this:               $index=0;
          <?php     while ( have_posts() ) {         $index++;        ?>

<?php the_post(); ?>

 <?php     if(($index % 2) ==0){     echo '

';     }     } ?>
      But this prints one extra empty posts-wrapped div:
         Lorem ipsum 1
         Lorem 2 ipsum est

         Lorem ipsum 1
         Lorem 2 ipsum est

      How can i get rid of this last empty div? It screws my carousel (this content is part of carousel).


Custom Post Types don’t highlight in menu nav

Working on a theatrical events site. The structure requires several separate events areas, each with a top page listing events in the particular area, and corresponding individual events pages underneath the listings page. Since each of the event area pages require a different treatment, I thought this was a good situation for custom post types, using both single-[event] and archive-[event] templates for each area. I installed Custom Post Types UI to make the custom post types (including matching custom taxonomy) and Advanced Custom Fields to make meta fields. So far so good. The Archive custom post type (full listing of area events) pulls meta from the Single custom post type, and both custom post pages display correctly except for one thing: the main nav menu no longer highlights the active web page on the Archive listing. [Note: there are many posts about how to highlight submenu Single custom posts to match parent; I don’t need that, just need the current Event Area to highlight correctly in main menu nav!] I realized I had constructed my main nav – which includes the event areas – with wp_nav_menu and register_nav_menus. So the event areas corresponding to Archive custom posts were originally constructed as Pages and the main nav was set up using WP Menu’s drag and drop capability. Wordpress correctly defaults to the archive-[event] custom post template (and ignores the existing Page with same name), and the nav menu is functional in terms of links, but doesn’t highlight the Archive custom post link in the nav. Pages in the main nav work correctly. When I check output on Event Area, there is a “current_page_parent” class attached to the Blog nav, but no “current-menu-item” elsewhere, which I guess is appropriate for custom posts. I suppose if wp_nav_menu is just for Pages, this makes sense as the top-level archive posts won’t be recognized, but I have no clue how to fix it. I’m will to try hacks, but want to avoid ID- specific ones or jQuery if possible. One thought would be to chuck the archive-[event] template, and use a regular page template for the listing while keeping the true single-[event] custom type post. Any reason faking it that way couldn’t work? Thanks for any advice, hope I'm missing obvious/easy approach.


Beginner advice

Hi I am a self tought web developer with a year experience in using html/css/javascript/ and only just recently learned php/mysql for about 4 months.I have never used a cms before and now I was recently asked to learn Wordpress in a month with all it's features. As I was told I have to learn it from more of a developers point of view so theme development and plugin development is a must. What I want to ask is 8 hours a day enough for learning Wordpress in a month?And can I get some recommendations on what books should I read to get up to speed on what I need to know? I have seen that most of the books that are out are talking about Wordpress 3 but the most recent version is Wordpress 3.3.Will it confuse me if I learn from a book that teaches from an earlier version?


How to pass users back and forth using session data?

I have applications that I wrote that use SAML and then a user database to define permissions for them all. And basically once a user signs on via our SSO they can use the applications with their defined perms. I want to do the same thing for WP. Where do I start? I would like WP to recognize their session username before they login and then create wordpress cookie. I saw a root cookie plugin that would pass the user info to other wp sites but how about getting the session username to begin with? I would like users to come to WP site and see that they are logged in with their username but I am open for other ways too. Right now what is given to me for SAML authentication is:   * app url: redirect to the SSO sign in   * app key: hash to encrypt   * uid   * firstname   * lastname   * email   * time (POST time is used for validation) **Note:** I have just tried using the SAML2 plugin for WP. First it is a beta plugin and very confusing. Second I keep getting fatal error that it cannot find IDP information. Would really just like to take the session uid I have an log a person in using that.


Access for adding subpages but not for pages

For every website project, i make the wordpress admin custom for the client. Right now, i want that the client only has access to add subpages. I have a main navigation on the website. I want that the main navigation is fixed, so the client can not add pages to the navigation. But the client can add subpages to the current pages in the fixed main navigation. I googled it, but i can't find a solution. I know i can show menu items on a specific id. So i can make the main navigation fixed. Example:               <?php wp_list_pages('include=7,13,26,35&title_li=<h2>' . __('Pages') . '</h2>' ); ?>      But, does it show the subpages id's thats below the page id? And is there not a cleaner way? Because with this solutation the client has still access to create pages. I only hide the created pages on the front website. Hope someone can help me. Many thanks,


Exclude category from fucntion

## QUESTION Hey guys, I have this function and I need to exclude 2 categories: 81 and 82. Can You help? :) ## CODE               function has_related_same_cat_posts(){     global $post;     $categories = get_the_category($post->ID);          if ($categories) {         $category_ids = array();         foreach($categories as $individual_category)              $category_ids[] = $individual_category->term_id;              $args=array(         'category__in' => $category_ids,         'post__not_in' => array($post->ID),         'posts_per_page'=> 4, // Number of related posts that will be shown.         'caller_get_posts'=>1,         'orderby' => 'rand',              );              $my_query = new wp_query( $args );         if( $my_query->have_posts() ) {             $return = true;         } else {             $return = false;         }          }          return $return;     }


Add an image gallery to a custom post type?

I am pulling data from an external web service into a custom post type. This data includes images. How can I create an image gallery, add some existing attachments to it, and associate it with a post? What I was hoping to find is something like a `set_post_gallery` counterpart to the `get_post_gallery` function, but I can't find anything like it in the codex, on google, or in `wp-includes/media.php`. This is how I set up the attachments:               $attachment = [       'guid' => wp_upload_dir()[ 'url' ] . '/' . basename( $path ),       'post_mime_type' => wp_check_filetype( basename( $path ), null )[ 'type' ],       'post_title' => "$mlsNum $id",       'post_content' => '',       'post_status' => 'inherit'     ];          $attachmentId = wp_insert_attachment( $attachment, $path, $this->postId );          // Generate attachment metadata and create resized images.     wp_update_attachment_metadata( $attachmentId, wp_generate_attachment_metadata( $attachmentId, $path ));      And this is how I am trying to retrieve the gallery for the theme:               $gallery = get_post_gallery( $post, false );     var_dump( $gallery );     var_dump( $post );      `$post` is defined, and `$gallery` is false. I was under the impression that `wp_insert_attachment` would create a gallery for the post and add the attachment to it, but apparently this is not the case. If it was, then that would cause other problems for me when I go to attach a PDF to the post.


Custom Taxonomy Hierarchy for Custom Post Types (eg Categories and Subcategories)

I'm working on building some custom taxonomies for a custom post type I created. The custom post type is `Products`. For the custom post type `Products` I've created a taxonomy of `Category`. Now Under `Category`, I'd like to have a taxonomy of `Sub_Category`. I've created all the taxonomies and set them to hierarchical, but the `Sub_Category` tax seems to be relative to the `Product` Custom Post Type, NOT the `Category` custom taxonomy. Is there a way to do this? I saw a screenshot where someone was filling out a taxonomy form for a taxonomy they created and it had an option for PARENT but I could never get that to show up. How can I choose a PARENT `Category` taxonomy on my `SubCategory` taxonomy? Here is my `Category` and `SubCategory` taxonomy code:               function create_productcategory_taxonomy() {         $labels = array(             'name' => _x( 'Categories', 'taxonomy general name' ),             'singular_name' =>_x( 'Category', 'taxonomy singular name' ),             'search_items' =>  __( 'Search Categories' ),             'popular_items' => __( 'Popular Categories' ),             'all_items' => __( 'All Categories' ),             'parent_item' => null,             'parent_item_colon' => null,             'edit_item' => __( 'Edit Product Category' ),             'update_item' => __( 'Update Product Category' ),             'add_new_item' => __( 'Add New Product Category' ),             'new_item_name' => __( 'New Product Category' ),             'separate_items_with_commas' => __( 'Separate categories with commas' ),             'add_or_remove_items' => __( 'Add or remove product categories' ),             'choose_from_most_used' => __( 'Choose from the most used categories' )             );              register_taxonomy('tf_productcategory', 'tf_products', array (             'label' => __('Product Category'),             'labels' => $labels,             'hierarchial' => true,             'show_ui' => true,             'query_var' => true,             'rewrite' => array( 'slug' => 'product-category'),             ));      }          function create_product_subcategory_taxonomy() {         $labels = array(             'name' => _x( 'SubCategories', 'taxonomy general name' ),             'singular_name' =>_x( 'SubCategory', 'taxonomy singular name' ),             'search_items' =>  __( 'Search SubCategories' ),             'popular_items' => __( 'Popular SubCategories' ),             'all_items' => __( 'All SubCategories' ),             'parent_item' => __( 'Main Category' ),             'parent_item_colon' => ( 'Main Category:' ),             'edit_item' => __( 'Edit Product SubCategory' ),             'update_item' => __( 'Update Product SubCategory' ),             'add_new_item' => __( 'Add New Product SubCategory' ),             'new_item_name' => __( 'New Product SubCategory' ),             'menu_name' => __( 'SubCategories' )             );              register_taxonomy('tf_productsubcategory', 'tf_products', array (             'label' => __('Product SubCategory'),             'labels' => $labels,             'hierarchial' => true,             'show_ui' => true,             'query_var' => true,             'rewrite' => array( 'slug' => 'product-subcategory'),             ));      }          add_action( 'init', 'create_productcategory_taxonomy', 0 );     add_action( 'init', 'create_product_subcategory_taxonomy', 0 );


On what point (hook) does the_/has_post_thumbnail() load?

I got some problems during my loading priority/order that i already discovered. Now i ran into the problem that i can't use any post_thumbnail functions (get_post_thumbnail_id, has_post_thumbnail, the_post_thumbnail): "Call to undefined function"... Does anyone know at which point these functions are loaded? I would be satisfied if i know after which hook they get loaded. Thanks! Edit: I traced down all files that get loaded on my edit custom post type edit screen. It's 64 file from core before my theme files start loading. Files starting from #26 are:   * /wp-includes/general-template.php   * /wp-includes/link-template.php   * /wp-includes/author-template.php   * /wp-includes/post.php   * /wp-includes/post-template.php   * /wp-includes/category.php   * /wp-includes/category-template.php ... but /wp-includes/post-thumbnail-template.php doesn't seem to load. Weired ... Edit 2: post thumbnail support is activated and i can upload images. Only when i try to view them then i get the error about the id function. My problem is that it worked an hour ago and i need to track down whatever is causing this behavior. Edit 3: Funny. I load my files at init.. right after the file should get included. Plus: I just downloaded wordpress again and replaced the file, so everything from this side should be fine.


BuddyPress - A hook available to hide custom born date on public profile view?

I'm trying to hide some fields on public BuddyPress profiles, it is possible? Thanks in advance.


Filter get_cat_id for Custom Post Type

I have this simple snippet to retrieve the categories (taxonomies) of my Custom Post Type 'portfolio' I need to display each taxonomy but it displays all the categories. I just saw this question Filter get_categories() for taxonomy term in WordPress and unfortunately I tried with no success.               <?php         query_posts("post_type=portfolio");         if ( have_posts() ) : while ( have_posts() ) : the_post();          $catid = get_cat_id('Images');     ?>          <?php          $categories=  get_categories('child_of='.$catid.'&orderby;=name');          foreach ($categories as $cat) {         $input = '
category_nicename.'">';           $input .= $cat->cat_name;           $input .= '
';           echo $input;           }     ?>      Can you please guide me or give me a hint? Thanks so much.


WP as an HTML editor

Is WP a good HTML editor? A friend of mine wants to create HTML pages, but doesn't know HTML. Can WP become a WYSIWIG HTML editor via the appropriate plugin? He'll be formatting images, wanting to place text in specific locations, etc. Nothing too fancy, but not just text either.


Is it possible to have two different previews of a post (ie. two templates for one post)?

I'm looking for a way to allow post editors to see two different previews of the posts they are writing. On the front, the same post can appear it two different sections of the website (each shows a different amount of custom fields). How can I create two preview links (for ex : "Preview with template 1" and "Preview with template 2") ?


Echo post content from archive page

I am trying to pull the latest post content in a archive page into the meta description, this is what I got:                 <?php } elseif (is_tax()) { ?>           <meta name="description" content="<?php                 $current_tag = get_query_var( 'taxonomy' );                $current_tax_tag = $wp_query->get_queried_object()->slug;                 $args = array( $current_tag => $current_tax,                               'numberposts' => 1 );                 $best_post_for_meta = get_posts($args); echo $best_post_for_meta->post_content; ?>">      But I can't find the problem, it's not echoing anything. **EDIT:** Is it because it's in the header?


problem with wp theme uploading to server..?

Please help me out.. I had uploaded new theme(child theme) in clients server.Theme folder has _twenty ten_ and _child theme_ now.But when i activated the theme in admin side ,the twenty ten shows the corresponding child theme and the new one shows the html template (from that html template i made the corresponding wordpress theme).Is this the problem with uploading? what went wrong ?


Set default date in datepicker of the advance custom field

I am using advance custom field in my wordpress project. In it i have added 2 datepickers as custom fields into page. Now the main problem is whenever i add new page both the datpicker by default comes empty, but i want to set current date of the server in it, that is whenever i add a new page both the date picker should have current date of the server by default in it. In advance thanks for the help.


Add filter to Admin list for all custom post types by their custom taxonomies

I want to add **filter** on every **Custom post type** that have taxonomy associated with it. I have googled but found code for only for single post type or for single taxonomy.


How to load javascript file on homepage in Wordpress in order?

I am using a `quicktags` plugin, which was not loading on the home page, now it does, but it does it on the wrong place. How can I solve this? **I want the quicktags.min.js file to load first, rather than the basic- comment quicktags...** I am using this script:               add_action( 'wp_enqueue_scripts', 'ron_scripts' );     function ron_scripts(){        if(is_home()){          wp_register_script( 'quicktags', '/wp-includes/js/quicktags.min.js?ver=3.5.1');          wp_enqueue_script( 'quicktags' );          wp_register_script( 'basic-comment-quicktags', '/wp-content/plugins/basic-comment-quicktags/quicktags.js' );          wp_enqueue_script( 'basic-comment-quicktags' );          } else {              }     }      What should I do to get it work like I want it to be? Edit: so now I am using:               function quicktags_script() {         wp_register_script( 'quicktags-min', '/wp-includes/js/quicktags.min.js?ver=3.5.1');         wp_enqueue_script( 'quicktags-min' );     wp_register_script( 'basic-comment-quicktags', '/wp-content/plugins/basic-comment-quicktags/quicktags.js' );          wp_enqueue_script( 'basic-comment-quicktags' );     }          add_action( 'wp_enqueue_scripts', 'quicktags_script' );      .... Can I get the basic-comment-quicktags beneath all scripts? Edit 2: If I change `quicktags-min` to `quicktags`, it does not give me the l10n error and it shows it to me in my page source. This time I get this error: `Permission denied to access property 'toString'`


How to do a task only once for logged in users

I want to do a task only once after an user has visited my site. I am currently doing like this:               function my_task(){         //do my tasks     }     add_action('init', 'my_task');      I am doing this from a plugin. This actually loads **my_task()** function every time users load any page of wordpress. But I only want to load it once for each user for each session. Once they close the browser, and come back again, I want it to load again only for once till they exit. How can I do this? Thanks in advance.


Bootstrap menu - make menu entries with submenu not clickable

I am currently developing a new WordPress theme employed on the basis of twitters bootstrap build. To use the menu Custom Navbar, I've followed the instructions of goodandorgreat. https://gist.github.com/1597994 My problem now is that menu items with submenus are also clickable. That should not be so. What could I do here? header.php Setup:

             <?php                  $args = array(                 'theme_location' => 'top-bar',                 'menu' => 'main-menu',                  'container_class' => 'nav-collapse',                 'menu_class'     => 'nav',                 'menu_id' => 'main-menu',                 'walker'     => new Bootstrap_Walker_Nav_Menu()             );                  wp_nav_menu($args);                  ?>

      I dont want handle that with entrie url's like "#".


One blog inside another

I have a question about having two blogs at the same host simultaneously. Here is my scenario: The first blog is hosted in the root directory http://mathosproject.com/, and the second is hosted in a _sub directory_ , http://blog.mathosproject.com/, which is linked to _mathosproject.com/blog/_. I have tried to manipulate the _web.config_ file of the root, by making it excluding the directory _blog_ as following:               <configuration>       <system.webServer>         <rewrite>           <rules>             <rule name="wordpress8" patternSyntax="Wildcard">               <match url="^(blog|sample-page)*" ignoreCase="true" />               <conditions>                 <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />                 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />                 <add input="{REQUEST_URI}" pattern="^/(blog|index)" negate="true" />               </conditions>               <action type="Rewrite" url="blog/index.php" />             </rule>                  <rule name="wordpress" patternSyntax="Wildcard">               <match url="*" ignoreCase="false" />               <conditions>                 <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />                 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />                 <add input="{REQUEST_URI}" pattern="^/(blog|index)" negate="true" />               </conditions>               <action type="Rewrite" url="index.php" />                  </rule>           </rules>         </rewrite>       </system.webServer>     </configuration>      This actually helped me to be able to view the second blog, in _blog_ , but as I processed to the _sample-page_ , I was redirected to the first blog. My question is, is there a way I can configure the _web.config_ , so that it excludes a folder entirely?


How to edit wordpress post without republishing

Is there a way to update an older post without republishing the post? If I am looking at a previously published post and discover a misplaced comma or reformat an image I don't need all my RSS and email subscribers to receive that post in their feed. This is especially an issue if I want to fix issues in multiple posts on the same day. I saw something somewhere about changing the post to private, saving, and then setting the post back to public but that seems to also require publishing to reset the post.


How can I add a menu item to the admin area?

I've used almost all of the Wordpress example code but it still doesn't work. I've put the php file under wp-content/plugins/menuitem/ .The code is simple               <?php add_action('admin_menu', 'donations_overview_menu');     function donations_overview_menu() {         add_options_page('Donations overview', 'Donations overview', 'manage_options', 'donations-overview', 'donations_overview');}          function donations_overview() {         if (!current_user_can('manage_options'))  {             wp_die( __('You do not have sufficient permissions to access this page.') );         }         echo '
';         echo '
Here is where the form would go if I actually had options.
';         echo '
';     }     ?>


Advanced Custom Fields Plugin: how would I get an image src path uploaded from User Profile?

I have created an Image Upload field for a User Photo in the User Profile section in the wp-admin using Advanced Custom Fields. I realized ACF could do this per this post: Photo gallery on profile page? How would I go about capturing the contents of the image src field in ACF? The following does not work:               <?php $publisher_photo = get_field('user_photo'); ?>          <?php echo ""; ?>      I even tried this, but it does not work either:               <?php $publisher_photo = get_the_author_meta('user_photo'); ?>     <?php echo ""; ?>      When I try to debug and echo the contents of the $publisher_photo variable, it comes back blank leading me to believe I'm not picking up this field from the User Profile in the correct way.


How can I display these posts in ascending order?

I am trying to display the following posts in descending order beginning with the first created and ending on the last page with the most recently created post. Any help is appreciated. Here is my code:               <?php     $numofmebers = '-1';     if ( empty($_GET['page_id_all']) ) $_GET['page_id_all'] = 1;         $count_post = 0;             query_posts( array( 'posts_per_page' => '-1', 'post_type' => 'coach-instructor' ,'post_status' => 'publish') );             while ( have_posts()) : the_post();                 $count_post++;             endwhile;                 if ( $node->instructor_pagination == "Single Page" ) {$node->instructor_page_num = -1;}                 query_posts( array('posts_per_page' => "$node->instructor_page_num", 'paged' => $_GET['page_id_all'], 'post_type' => 'coach-instructor' ,'post_status' => 'publish') );              $counter_news = 0;             while ( have_posts()) : the_post();             $counter_news++;             $image_id = get_post_thumbnail_id ( $post->ID );             $coach_istructor_meta = get_post_meta($post->ID, "cs_coach_istructor_meta", true);                 if ( $coach_istructor_meta <> "" ) {                     $xmlObject_author = new SimpleXMLElement($coach_istructor_meta);                         $about = $xmlObject_author->about;                         $specialism = $xmlObject_author->specialism;                         $qualifications = $xmlObject_author->qualifications;                         $philosophy = $xmlObject_author->philosophy;                         $contact = $xmlObject_author->contact;                 }                 else {                     $about = '';                     $specialism = '';                     $qualifications = '';                     $philosophy = '';                     $contact = '';                 }     ?>


Sub-directory blog on a sub-domain WordPress network site

I have a WordPress Network install with the individual sites installed on subdomains.   * example.com   * a.example.com   * b.example.com I would now like to launch a blog on each of the sites. It'd like the blog to be situated in a `/blog` sub-directory of each of the subdomains, but as the blogs would be completely separate from the website and use it a different theme, I think it makes sense to have them as separate sites in the network. In other words, what I'd like to have is:   * example.com      * example.com/blog   * a.example.com      * a.example.com/blog   * b.example.com      * b.example.com/blog Each of the above being a separate WordPress Network site, with different themes, admin panels, etc. Is there any way to accomplish something like this? Thanks! P.S.: The site runs on nginx.


Add class name of content, Hypernate doesn't work to IE and Chrome

I am using the `hyphenator.js` to custom page template and works for paragraph, but I can not apply it to Post. How can do that? `header.php`                                   `style.css`               post-single {text-align:justify; font-size:1em;}      `single-news.php`               <div class="post-single" id="post-<?php the_ID();?>">

<?php the_title(); ?>

     Posted <?php the_time('l, j F Y') ?>.
                  <?php the_content (); ?>
        The problem with the class resolved, but the `hypernate .js` doesn't work to IE. How can fix that?


Custom PHP-coding in MU installs

I have a WPMU install with a couple of sites on it. I'd like to add some subdirectories that are not wordpress blog pages but do contain working PHP code. They do not use any of wordpress's libraries and are not plugins. The catch is that I'd like these subdirectories to only show up on a particular site. For instance, the hierarchy is:               /wordpress/customapp      but               http://myfirstsite.something.com/wordpress/customapp      should work while               http://mysecondsite.something.com/wordpress/customapp      should give a 404 error. Is there anyway to do this? I'm running Wordpress through Windows Server IIS7 if it is any help. Thanks


What code removes the admin bar for all users in WordPress 3.3?

How can I remove the admin bar in both the front and backend for all users in WordPress 3.3?


Add #sidebar-2 to a custom page template

I registered a few custom sidebars, and the corresponding code in my version of TwentyTwelve theme now looks like this:                   register_sidebar( array(         'name' => __( 'Sidebar #1', 'twentytwelve' ),         'id' => 'sidebar-1',         'description' => __( 'Appears on posts and pages except the optional Front Page template, which has its own widgets', 'twentytwelve' ),         'before_widget' => '',         'after_widget' => '',         'before_title' => '
',         'after_title' => '
',     ) );          register_sidebar( array(         'name' => __( 'Sidebar #2', 'twentytwelve' ),         'id' => 'sidebar-2',         'description' => __( 'Appears on posts and pages except the optional Front Page template, which has its own widgets', 'twentytwelve' ),         'before_widget' => '',         'after_widget' => '',         'before_title' => '
',         'after_title' => '
',     ) );          register_sidebar( array(         'name' => __( 'Sidebar #3', 'twentytwelve' ),         'id' => 'sidebar-3',         'description' => __( 'Appears on posts and pages except the optional Front Page template, which has its own widgets', 'twentytwelve' ),         'before_widget' => '',         'after_widget' => '',         'before_title' => '
',         'after_title' => '
',     ) );          register_sidebar( array(         'name' => __( 'Sidebar #4', 'twentytwelve' ),         'id' => 'sidebar-4',         'description' => __( 'Appears on posts and pages except the optional Front Page template, which has its own widgets', 'twentytwelve' ),         'before_widget' => '',         'after_widget' => '',         'before_title' => '
',         'after_title' => '
',     ) );          register_sidebar( array(         'name' => __( 'Sidebar #5', 'twentytwelve' ),         'id' => 'sidebar-5',         'description' => __( 'Appears on posts and pages except the optional Front Page template, which has its own widgets', 'twentytwelve' ),         'before_widget' => '',         'after_widget' => '',         'before_title' => '
',         'after_title' => '
',     ) );      My custom page template uses #sidebar-1:
          <?php get_sidebar(); ?>
       Now I want to create a separate custom page template # 2, which should be identical to custom page template # 1, except it should use #sidebar-2 instead of #sidebar-1. **Question:** How should I place the alternative sidebar there? Thank you in advance for your help!


Masonry, remove “is_expanded” class when new item is clicked?

I´m using a layout like http://masonry.desandro.com/faq.html and i am wondering if there is a way to only have one item active at them time. So that when you expand a new item a the one you currently have open goes back to its original form (removes class="is_expanded") . I´ve quite new to programming and don´t really know where to stat to look, tried configuring How do I remove class from previous selection when clicking additional item? but with no luck This is codepen link for the demo : http://codepen.io/desandro/pen/BnCqy Please help me to find out the solution any help would be appreciated..


what is allowed as an id argument in register_sidebar( $args )

I am want to register a sidebar but i am a little confused about the uses of the id argument in register_sidebar function. > Codex says: id - Sidebar id - Must be all in lowercase, with no spaces > (default is a numeric auto-incremented ID). Of what use is the id arguement and must it alyways be in numeric form?.


Undefined index: debuging error for theme option template snippet

Hello I tried to find the solution but couldn't get what I am looking for..I am getting error exactly as bellow.. Notice: Undefined index: page in C:\xampp\htdocs\site\wp- content\themes\mytheme\admin\admin-panel.php on line 745 and code on line 745 is               function mytheme_add_init() {          $file_dir=get_bloginfo('template_directory');     wp_enqueue_style("functions", $file_dir."/admin/functions.css", false, "1.0", "all");     wp_enqueue_script("rm_script", $file_dir."/admin/rm_script.js", false, "1.0");          }      I dont know if I am using deprecated snippet or so.


How to break the wp_link_pages in two lines

I have 4 videos in my single post which are being displayed using nextpage quicktag. To style pagination i am using the follwing code in single.php
<?php wp_link_pages('before=LQ &pagelink=Chapter %'); ?>
      its giving me output like _LQ Chapter 1 Chapter 2 Chapter 3 Chapter4_ But i want to display like _LQ Chapter 1 Chapter 2_ _HQ Chapter 1 Chapter 2_ in seprate lines . What i can do for this? Desired html output should be like this
         LQ         Chapter 1         Chapter 2         Chapter 3

         HQ         Chapter 1         Chapter 2         Chapter 3
      and for this i will add 6 chapter content in my post using the like               Chapter 1     Chapter 2     Chapter 3      Chapter 4  // this will become chapter 1 in HQ     Chatper 5 // this will become chapter 2 in HQ     Chapter 6


Installing Google analytics to home page

I've installed a plugin that puts google analytics code to the page of each post. But it did not install google analytics code to home page and because only a small portion of users click on the post's page I can not track the users. How can I install google analytics manually to the home page and if I do so I could not use the plug-in any more? My theme is Twenty Ten 1.2.


missing argument 2 when passing arguments to add_action

I wanted to pass arguments to a function triggered by an add_action hook. I followed the codex on this. I got a warning and the result was erratic, with an unexpected behavior. This question has already been adressed before without answers. I could reproduce this problem with a simplified function echoing the 2 arguments it needs. So, in `functions.php`:               function my_function ($arg1, $arg2) {         echo 'id1: '.$id1.' id2: '.$id2;         return;     }     add_action('this_hook', 'my_function', 10, 2);      The 2 number stands for the number of arguments needed by `my_function` in order it can take into account some of its context when executed. So, to be executed, the `do_action` must be added in the template pages files, for example in `header.php` as it was the case for me.                do_action('this_hook', 'dogs', 'cats');      The result is echoing > id1: id2: id1: dogs id2: cats Missing argument 2 for my_function() The expected behavior would have been: > id1: dogs id2: cats


Wordpress custom post type post and category links 404

I've recently created several custom post types in a wordpress site, with the code below, they are generating links in the correct form e.g. root/category/id/postname but each link to the full post, pagination or category 404's. I've tried a number of popular solutions, appending /%category%/%post_id%/ to the url structure, rewriting function names but I'm getting nowhere fast. With the wordpress permalink structure set to default e.g. root/?page_id=1257 everything works ok. Any effort to add additional parameters to rewrite (see below) produces "Parse error: syntax error, unexpected ';'" even though no ';' is present.               'rewrite' => array(     'slug' => 'issue')      Any help appreciated - highly confused, very frustrated!               <?php          //      CUSTOM POST TYPE 1     add_action('init', 'mjwpress_register');          function mjwpress_register() {         $args = array(             'label' => __('Press'),             'singular_label' => __('Press'),             'public' => true,             'show_ui' => true,             'capability_type' => 'post',             'new_item' => __('New Press Item'),             'hierarchical' => false,             'rewrite' => true,             'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'comments', 'revisions', 'page-attributes', 'post-formats')         );              register_taxonomy('press-category', array('article'),              array(                 'label' => 'Press Story Category',                  'singular_label' => 'press-story-category',                 'public' => TRUE,                 'show_tagcloud' => TRUE,                 'hierarchical' => TRUE,                 'query_var' => TRUE,                 'menu_position' => 5,                 'rewrite' => TRUE)         );              register_post_type( 'mjwpress' , $args );     }               add_action('inthenews_init', 'inthenews_init');     add_action('save_post', 'save_mjwpress_options');          function inthenews_init(){         add_meta_box('newsmeta', 'Press Options', 'mjwpress_meta_options', 'mjwpress', 'normal', 'low');          }          function mjwpress_meta_options(){         global $post;         $custom = get_post_custom($post->ID);         $linkurl = $custom['linkurl'][0];         $linktitle = $custom['linktitle'][0];     ?>

             Link to External Publication:             <input name='linkurl' value='<?php echo $linkurl; ?>' />
E.g. http://www.example.com/article-title.php

             Title of External Publication:             <input name='linktitle' value='<?php echo $linktitle; ?>' />
E.g. Lib Dem Voice

          <?php     }          function save_mjwpress_options(){         global $post;         update_post_meta($post->ID, 'linkurl', $_POST['linkurl']);         update_post_meta($post->ID, 'linktitle', $_POST['linktitle']);     }          ?>


Display value of custom field not working

I am simply trying to print the value of a custom field. I have read all the documentation, tried out other people's suggestions, and nothing works. I can get it to print the ID #, but not the actual value I have in the field. I am using the Types plugin to create the field. this prints the ID:               <?php echo get_the_ID($value, 'authorinfo', true); ?>      as well as:               <?php echo get_the_ID($key, 'authorinfo', true); ?>      this does nothing:               <?php get_post_meta( $post->ID, 'authorinfo', true ); ?>      this does nothing:               <?php echo get_post_meta(get_the_ID(), 'authorinfo', true); ?>      (I have a separate question on this site where the problem came up and a solution was offered but unfortunately it didn't work for me) - Display custom post type and custom fields within a Bootstrap Carousel Here is all the code I'm working within in case that helps. I hope I'm doing something stupid here.               <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

                    <?php $the_query = new WP_Query(array(                 'post_type' => 'testimonial',                  'posts_per_page' => 1                  ));                 while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

                         <?php the_content();?>                         <?php echo get_post_meta(get_the_ID(), 'authorinfo', true); ?>

                 <?php endwhile; wp_reset_postdata(); ?>                 <?php $the_query = new WP_Query(array(                 'post_type' => 'testimonial',                  'posts_per_page' => 5,                  'offset' => 1                  ));                 while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

                         <?php the_content();?>                         <?php echo get_post_meta(get_the_ID(), 'authorinfo', true); ?>

                      <?php endwhile; wp_reset_postdata(); ?>

          <?php endwhile; ?>            **EDIT/ADDITION** Since working with the Types plugin more, I am pretty sure this problem could be solved by using "types_render_field" instead of "get_post_meta". I don't have a place where I can test this, but I think this should help someone with a similar problem.


Using WP_Query within an mu-plugin

I'm trying to create a list of parent IDs for a custom post type for use within a "must use" plugin I'm developing on a project. Here's the code I'm using to generate the query:               $cpt_parents = new WP_Query( array (          'post_type' => 'cpt',         'posts_per_page' => -1, // Get them all          'post_parent' => 0, // Return only top-level                 'fields' => 'ids'         )        );          $parent_ids = $cpt_parents->posts;      And here are the resulting errors:               Notice: Undefined index: wp_taxonomies in [url]/wp-includes/query.php on line 1700          Warning: Invalid argument supplied for foreach() in [url]/wp-includes/query.php on line 1700          Notice: Undefined index: wp_taxonomies in [url]/wp-includes/query.php on line 1700          Warning: Invalid argument supplied for foreach() in [url]/wp-includes/query.php on line 1700          Fatal error: Call to undefined function is_user_logged_in() in [url]/wp-includes/query.php on line 2485      What do I need to do in order to run WP_Query within a plugin?


Nav Menu and display post count

Iam looking for a solution that the number of child post displayed, like so: Parent (14) - Child - Child Parent (2) - Child I have played with the custom walker and tried the function with ->count but without luck. Has someone a solution? Thanks               class Count_Post_Walker extends Walker_Nav_Menu     {         function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {             global $wp_query;             $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';                  $class_names = '';                  $classes = empty( $item->classes ) ? array() : (array) $item->classes;             $classes[] = 'menu-item-' . $item->ID;                  $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );             $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';                  $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );             $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';                  $output .= $indent . '
';                  $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';             $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';             $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';             $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';                  $submenus = $depth == 0 ? get_posts( array( 'post_type' => 'post', 'show_count' => 1, 'numberposts' => -1,  'meta_query' => array(            array(                 'taxonomy' => 'category',                 'field' => $item->ID,                  ))      ) ) : false;             $item_output = $args->before;             $item_output .= '';             $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;             $item_output .= '';             $item_output .= $submenus ? ' (' . count( $submenus ) . ')' : '';             $item_output .= $args->after;                  $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );         }     }


Last three posts not being put in order by date. How to fix this?

My company adds a quote of the day each day. The last three posts that I have put are not in order though. The first quote I posted 3 days ago is at the top the post I posted yesterday is under that, and the post from today is third down. The posts under that were all from before I posted. How do I fix this?


get child-ID or attachment-ID of a post

I am trying yo get information of attachments and there type, when ever I publish a post with attachment its information is stored in wp_post with three IDS ex: `ID=1, parent-id = 0, post_type=post, mime_type=null ID=2, parent-id = 1, post_type=attachment, mime_type=image/jpg ID=2, parent-id = 1, post_type=revision, mime_type=null` in the first line id-1, its storing information about post in the second line id=2. its storing information about attachment in the third line id=3, i don't know what it was storing If i use get_post()->get_post_ID its fetching post-ID that is ID=1 what I want to get is attachment post information ie; id=2


How to display summary content from a Page (Not a Post) on another page

I created a Page called "About Joe" as a **_page_** in WordPress. Then on a different page (e.g. the homepage), I wish to display _a summary_ which includes:   1. a thumbnail   2. the 1st paragraph   3. link to page Is this possible? Maybe I'm not asking the right questions to the codex as I'm not finding anything. The closest thing I could find was `get_page()`, which i'm not even sure is the solution. But that function is now **_deprecated_**. Please advise! Thanks


Footer with next/previous posts

I'm looking for something to create a multi footer with previous / next posts. The footer needs to know if the current post is the newest (1st, 2nd and 3rd newest), oldest (3rd, 2nd, and oldest) or in between. As an example: ![enter image description here](http://i.stack.imgur.com/uEfPs.png) The old / new links include title & thumbnail. Does anyone know how I can achieve this?


Find all posts via SQL beginning with A of type B

I have problem with post and taxonomy query. What i need is to get all post's from custom post type which starts with A and have defined term. Here is my sql:               SELECT * FROM $wpdb->posts, $wpdb->terms         WHERE post_title LIKE 'А%'         AND post_type = 'filmi-i-serialii'         AND post_status = 'publish'         AND slug = 'igralni';      But this returns me all posts in _filmi-i-serialii_ post-type and not only those that are in the taxonomy _igralni_.


How do WP child-themes work?

Ok, I have my main theme setup, and now I created a child theme with the name interio_child. From these instructions I understand that you only need to add the style.css file which makes the link to your main theme. Also you can add additional files which override code from your main theme. Right now I have activated my child theme. It only displays the code that is present in my child theme folder and no CSS at all. How is this possible? I've looked at numerous tutorials and wordpress support topics, but I can't get this child theme linked to my main theme. These are the contents from my child theme's style.css:               /*     Theme Name: Interio Child     Theme URI: http://tohidgolkar.com     Author: Tohid Golkar     Author URI: http://tohidgolkar.com     Description: Child theme for the Interio theme      Template: interio     Version: 1.1     */          @import url('../interio/style.css');     @import url('stylesheets/mystyle.css');      Does the child theme folder need to contain all files from the main theme? I believe not, it should link with the main theme, correct? Then why are there no files from the main theme displayed on the website?


Can't change parent page

Some of my pages are children of "home". I want to assign them to a new page. But I cant change the pages parent. Everytime I try and publish, it just switches back to "home". I am using the Roots-Theme, I don't know if that matters. Edit: I even tried to erase "Home". The children of home are assigned to "Main" then (I could not change that either). As I recreated home, they were reassigned to it. Maybe its because of the WPML Multilanguage plugin?


If Loop has odd number of posts on last page Custom style for last post in it

My loop displays posts in two columns using this php               <?php     if (have_posts()): while (have_posts()) : the_post();      $count++;     ?>         <?php  if ($count == 1) : ?>

         CONTENT OF POST : Title, Thumbnail, Excerpt... etc

              <?php elseif ($count == 2) : ?>
        CONTENT OF POST : Title, Thumbnail, Excerpt... etc

          <?php $count = 0; ?>                <?php else : ?>       WHEN THERE IS NO POSTS     <?php endif; endwhile; endif; ?>      You can see that the div '' opens in the first count & closes in the second one. so when my loop has an even number of posts works great, but with odd number it doesn't close the div so My idea is this: If loop has even number http://i.stack.imgur.com/Hu4Ua.png If loop has odd number of posts http://i.stack.imgur.com/JjqzZ.png I hope my question is clear,


Custom Walker function need to customize in a specific way for wp_nav_menu in Wordpress

I have used wp_nav_menu() for my custom WP sites with Custom Walker Function which is working fine and providing me below output:

HOME

MY Review Post 1

My Test Post

      But Right now i want to add div class through loop after the ul class="col- sm-12 list-unstyled" inside the div class "yamm-content". So output will be:

HOME

MY Review Post 1

My Test Post

title text come here
                                     learn more

      Please provide some idea how can i get it from my custom Walker function. I just tried to get it through static way but don't know how to place it after ending the `</UL>`. Anybody please help me..                   class custom_menu_walker extends Walker_Nav_Menu {         private $curItem;              function start_lvl(&$output, $depth) {             $thisItem = $this->curItem;                   $output .= '

';                 $output .= ( $depth == 0 && $thisItem->object == 'category' ) ? '
' : '
';                    }               function end_lvl(&$output, $depth) {             $output .= '

';              }              // add main/sub classes to li's and links          function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {              $this->curItem = $item;                  $indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' ); // code indent                       // depth dependent classes             $depth_classes = array(                 ( $depth == 0 ? 'dropdown' : '' ),                 (( $depth == 0 && $item->object == 'category' ) ? 'yamm-first' : ''),                 ( $depth % 2 ? 'menu-item-odd' : 'menu-item-even' ),                 'menu-item-depth-' . $depth             );             $depth_class_names = esc_attr( implode( ' ', $depth_classes ) );                  // passed classes             $classes = empty( $item->classes ) ? array() : (array) $item->classes;             $class_names = esc_attr( implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ) );                  // build html                  $output .= $indent . '
ID . '" class="' . $depth_class_names . ' ' . $class_names . '">';                  // link attributes             $attributes = ' class="menu-link ' . ( $depth == 0 ? 'dropdown-toggle' : '' ) . '"';                       $item_output = sprintf( '%1$s%3$s%4$s%5$s%6$s',                 $args->before,                 $attributes,                 $args->link_before,                 apply_filters( 'the_title', $item->title, $item->ID ),                 $args->link_after,                 $args->after             );                       // build html             $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );         }                        function end_el( &$output, $item, $depth = 0, $args = array(), $current_object_id = 0 ) {             if ( $depth == 0 && $item->object == 'category' ) {                       ?>

title text come here
                                     learn more

                     <?php                  }         }     }


Set Current Category to Active in category.php

Inside the category.php file I have a custom navbar which is...

All Categories
                     <?php wp_list_categories('orderby=name&title_li='); ?>
      I would like the li for the current category to have class = "active". How can I code this? Thank you


Query parsing only author ids

I need array only all author ids from the loop, each one only once if possible and out of all posts in the loop. Any suggestions?


Trying to output a "Most visited blogs" list in wordpress multisite

Does anyone know how to get a "most visited" list out of Wordpress Multisite? I got alot of bloggers and have been looking for a way to output a top 10/20 list of most visited blogs, but cant find any plugin or snippets for this. Example - like the list on the right side of this site (not WP) http://blogg.se/


Customizer preview doesn't update get_option() value properly

I have a setting in index.php               if(get_option('cb2_blog_home')){         cb_get_blog_links();     }      This code allows the home page blog index to be turned on and off. The cb_get_blog_links() function draws out the list of blog post summaries. And, in the customizer, I have a checkbox to allow this value cb2_blog_home to be set. However, it has no effect. Its as if the option is always true. Any ideas why? Inside that function, there are several variables that I'm also setting with the customizer. Those all work perfectly. Here's the full customizer code. Everything fires perfectly except the home blog setting. The only thing I can come up with is that one is a function and the others are variables within the function.               function cb_customize_register($wp_customize){                  $wp_customize->add_section('cb_customizer_blog', array(                     'title'    => __('Theme Blog Settings', 'Theme'),                     'priority' => 120,             ));                          //Show & Hide Blog Links on Home                     $wp_customize->add_setting('cb2_blog_home', array(                             'default'        => '',                             'capability'     => 'edit_theme_options',                             'type'           => 'option',                     ));                          $wp_customize->add_control('cb2_blog_home', array(                             'label'      => __('Enable Home Blog', 'Theme'),                             'section'    => 'cb_customizer_blog',                             'settings'   => 'cb2_blog_home',                             'type'   => 'checkbox',                             'priority' => 125,                     ));                          //Home Blog Post Count                     $wp_customize->add_setting('cb2_blog_home_count', array(                             'default'        => '3',                             'capability'     => 'edit_theme_options',                             'type'           => 'option',                     ));                          $wp_customize->add_control('cb2_blog_home_count', array(                             'label'      => __('Home Blog Post Count', 'Theme'),                             'section'    => 'cb_customizer_blog',                             'settings'   => 'cb2_blog_home_count',                             'priority' => 130,                     ));                               //Show & Hide Home Blog Title Heading                     $wp_customize->add_setting('cb2_blog_home_title_hide', array(                             'default'        => '',                             'capability'     => 'edit_theme_options',                             'type'           => 'option',                     ));                          $wp_customize->add_control('cb2_blog_home_title_hide', array(                             'label'      => __('Hide Home Blog Title', 'Theme'),                             'section'    => 'cb_customizer_blog',                             'settings'   => 'cb2_blog_home_title_hide',                             'type'   => 'checkbox',                             'priority' => 135,                     ));                          //Show & Hide Home Blog Author Byline                     $wp_customize->add_setting('cb2_blog_index_author', array(                             'default'        => '',                             'capability'     => 'edit_theme_options',                             'type'           => 'option',                     ));                          $wp_customize->add_control('cb2_blog_index_author', array(                             'label'      => __('Hide Blog Author Byline', 'Theme'),                             'section'    => 'cb_customizer_blog',                             'settings'   => 'cb2_blog_index_author',                             'type'   => 'checkbox',                             'priority' => 140,                     ));                      //Show & Hide Home Blog Date                 $wp_customize->add_setting('cb2_blog_index_date', array(                             'default'        => '',                             'capability'     => 'edit_theme_options',                             'type'           => 'option',                     ));                          $wp_customize->add_control('cb2_blog_index_date', array(                             'label'      => __('Hide Blog Date', 'Theme'),                             'section'    => 'cb_customizer_blog',                             'settings'   => 'cb2_blog_index_date',                             'type'   => 'checkbox',                             'priority' => 145,                     ));          }          add_action('customize_register', 'cb_customize_register');


Saving options for the fields on paginated pages

I am working on a WordPress plugin with some options for the fields which are working fine without pagination. I am kind of new to WordPress plugin development. The problem is I added pagination to the plugin's options page but the problem is when I click on save changes and if for example I am on page 2 then the changes are reset on the options which are on page 1 and all other pages. It looks something like this: http://usmanali.net/plugin-page.png How can I fix it? I mean how can make the changes save only for the options displaying on that specific page and not on the other page of the pagination? This is the code:               public function register_settings_and_fields()         {                  global $wpdb;                  register_setting('par_plugin_options', 'par_plugin_options'); // 3rd param required for cb                  add_settings_section('par_main_section', 'Check / Uncheck the pages against each user', array($this, 'par_main_section_cb'), 'ua_par_settings'); //id, title of section, cb, page                  $users = get_users();                  $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 1;                  $limit = 2;                  $offset = ( $pagenum - 1 ) * $limit;                      $args = array(                     'blog_id'      => $GLOBALS['blog_id'],                     'role'         => '',                     'meta_key'     => '',                     'meta_value'   => '',                     'meta_compare' => '',                     'meta_query'   => array(),                     'include'      => array(),                     'exclude'      => array(),                     'orderby'      => 'login',                     'order'        => 'ASC',                     'offset'       => '',                     'search'       => '',                     'number'       => $limit,                     'count_total'  => false,                     'fields'       => 'all',                     'who'          => ''                  );                  $entries = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}users LIMIT $offset, $limit" );                  if( $entries ) {                  $count = 1;                      foreach ( $entries as $user ) {                      add_settings_field($user->user_login, '' . $user->user_nicename . '
(' . $user->user_email . ')', array($this, 'process_callback'), 'ua_par_settings', 'par_main_section', array( 'value' => $user->user_login, ));                      $count++;                      };                  }                  $total = $wpdb->get_var( "SELECT COUNT(`id`) FROM {$wpdb->users}" );                  $num_of_pages = ceil( $total / $limit );             $page_links = paginate_links( array(                 'base' => add_query_arg( 'pagenum', '%#%' ),                 'format' => '',                 'prev_text' => __( '«', 'aag' ),                 'next_text' => __( '»', 'aag' ),                 'total' => $num_of_pages,                 'current' => $pagenum             ) );                  if ( $page_links ) {                 echo '

' . $page_links . '

';             }              }


Wordpress Ajax Login without page reload

I'm currently developing a Wordpress theme where I want the user to be able to upload images before he register or log in to the site. The initial problem was, you can´t upload images to wordpress using the wp.media javascript class if you are not a registered user. The solution I create is actually very simple:   1. When the user arrives at the registration page, a javascript code check's if the user is logged in or not, if he´s not we create a temporary user with a random e-mail and password and login the visitor with this newly created temporary user, all in background. After that, the idea is once the user registers with his own data, this temporary user is going to be updated with the correct visitor data.   2. Now the tricky part. I wan´t wordpress to identify this user as logged in without a page reload, to make this work I added a function to the action 'set_logged_in_cookie', so i can get the $_COOKIE data the wordpress is going to set to this new logged in user and retrieve it through the ajax call, I then set this cookie data in the local user computer with javascript. Now I´m able to get the correct data for the Cookie (php working just fine) and set it also without a problem (javascript looks to be working fine also). If I dump the $_COOKIE global after a page reload I get the same data I´m getting in the javascript code ajax call, but after I set the cookie, in the javascript code, without a reload and when I try to upload with the wp.media nothing works, after a page reload it works just fine. Any sugestions? Bellow is my current code ( I left only the relevant code )                // set action to get the cookie data      $this->setAction('set_logged_in_cookie', 'setCookieContents');      public function setCookieContents($logged_in_cookie, $expire, $expiration, $user_id)      {          $this->_cookieContents = array(              'logged_in_cookie'  =>  $logged_in_cookie,              'expire'            =>  $expire,              'expiration'        =>  $expiration,              'user_id'           =>  $user_id          );      }      ...                public function handleAjax( $action )      {             header('Content-type: application/json');             $action     =   PlulzTools::getValue('todo');             $response = array(            'status'    =>  'ok',            'data'      =>  array()        );             switch($action)        {               case 'ajaxlogin' :                      $response['data']['cookie'] = array(                            'key'   =>  LOGGED_IN_COOKIE,                            'data'  =>  $this->_cookieContents['logged_in_cookie']                      );                           echo json_encode($response);               break;            }      Now, in the front end javascript code, get the data and set the cookie (or at least, try to)               jQuery.ajax({          url : Frontend.ajaxurl,          type: 'POST',          data: EnviarLogin,          timeout: 12000     }).done(function(newresponse){               if(newresponse.status == 'ok')          {               // atualizando status de login               logged = true;                    jQuery.cookie(newresponse.data.cookie.key, newresponse.data.cookie.data);               }     }).error(function (xhr, ajaxOptions, thrownError){               console.log(xhr);          console.log('Erro! Status:' + xhr.status + '; Erro thrown: ' + thrownError, + ' Description: ' + xhr.statusText);               return false;          });


Display all sub category but one

How would I display all the sub category but one? I tried `is_category('myslug')` then return in the post loop but it wont work. my code in the post loop               if(is_category('myslug')){         return;     }      Stills return all the sub category even the one with slug `myslug`


The plugin generated xx characters of unexpected output. How to solve?

I get the following message when I activate the plugin `The plugin generated 655 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.' How can I debug this? I have turned WP_DEBUG on. Any solutions?               <?php     /*     Plugin Name: costing calculator     Description: A costing calculator for the engineering industry     Author: Matthew Pollard     Version: 1.0     */               register_activation_hook( __FILE__, 'mp_install_countries_table' );     register_activation_hook( __FILE__, 'mp_install_country_data' );     register_activation_hook( __FILE__, 'mp_install_machines_table' );     register_activation_hook( __FILE__, 'mp_install_machines_data' );     register_activation_hook( __FILE__, 'mp_install_settings_table' );     register_activation_hook( __FILE__, 'mp_install_settings_data' );          function mp_install_countries_table()  {         global $wpdb;         $table_name = $wpdb->prefix . 'countries';                   $sql = "CREATE TABLE $table_name (             id mediumint(9) NOT NULL AUTO_INCREMENT,             name tinytext NOT NULL,             labour_cost INT,             overheads FLOAT,             profit FLOAT,             UNIQUE KEY id (id)         );";             require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );        dbDelta( $sql );     }          function mp_install_country_data() {              global $wpdb;              $table_name = $wpdb->prefix . 'countries';            $rows =   array(                array(                 'id' => '1',                 'name' => 'UK',                 'labour_cost' => '20',                 'overheads' => '0.45',                 'profit' => '0.22'                  ),             array(                 'id' => '2',                 'name' =>'james',                 'labour_cost' => '6',                 'overheads' => '0.27',                 'profit' => '0.17'               )         );                foreach( $rows as $row )         {         $wpdb->insert( $table_name, $row);         }     }            //creating machines table     function mp_install_machines_table() {     global $wpdb;         $table_name2 = $wpdb->prefix . 'machines';           $sql2= "CREATE TABLE $table_name2 (               id int(11) NOT NULL AUTO_INCREMENT,               name varchar(255) DEFAULT NULL,               rate int(11) NOT NULL,               UNIQUE KEY id (id)               ) ; ";               require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );               dbDelta ( $sql2 );               }      // populate machines table     function mp_install_machines_data() {     global $wpdb;     $table_name_mach_in = $wpdb->prefix . 'machines';            $machine_id = '1';       $machine_name  = 'robot spot welder';       $machine_rate = '91';                   $rows_affectedmac = $wpdb->insert( $table_name_mach_in, array( 'id' => $machine_id, 'name' => $machine_name, 'rate' => $machine_rate ));          require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );          dbDelta( $rows_affectedmac );       }            //creating settings table     function mp_install_settings_table() {     global $wpdb;         $table_name3 = $wpdb->prefix . 'settings';           $sql5= "CREATE TABLE $table_name3 (               id int(11) NOT NULL AUTO_INCREMENT,               robot_constructional INT,               robot_stitching FLOAT,               robot_addr_in FLOAT,               robot_addr_out FLOAT,               UNIQUE KEY id (id)               ) ; ";               require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );               dbDelta ( $sql5 );               }        //populate settings table       function mp_install_settings_data() {     global $wpdb;     $table_name_sett_in = $wpdb->prefix . 'settings';            $setting_id = '1';       $setting_con  = '3';       $setting_stitc = '1.8';            $setting_rob_in = '2.4';       $setting_rob_out =  '2.4';           $rows_affectedset = $wpdb->insert( $table_name_sett_in, array( 'id' => $setting_id, 'robot_constructional' => $setting_con, 'robot_stitching' => $setting_stitc, 'robot_addr_in' => $setting_rob_in, 'robot_addr_out' => $setting_rob_out ));          require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );          dbDelta( $rows_affectedset );       }       // end of  create table and populating           // deadctivate the plugin and delete tables      function mp_uninstall_countries_table() {       global $wpdb;       $thetable = $wpdb->prefix. 'countries';       //Delete any options that's stored also?        // delete_option('wp_yourplugin_version');       $wpdb->query("DROP TABLE IF EXISTS $thetable");     }            register_deactivation_hook( __FILE__, 'mp_uninstall_countries_table') ;                 //include jquery     add_action( 'wp_enqueue_script', 'load_jquery2' );     function load_jquery2() {         wp_enqueue_script( 'jquery' );     }                function add_my_css_and_my_js_files(){         wp_enqueue_script('jquery-validate-min', plugins_url('activate/jquery_validate_min.js', __FILE__ ) );     }     add_action('wp_enqueue_scripts', "add_my_css_and_my_js_files");          // shortcode to display calcs     add_action( 'init', 'register_shortcodes');     function register_shortcodes() {     add_shortcode( 'displaycalcs', 'mp_calcs_display' );     }          function mp_calcs_display() {     return '     <form name="calsinput" action="" method="post" id="calsinput" >
 Process

 operation type always robot

     Number of welds: <input type="number" name="numberofwelds" class="required digits" title="This field is required and must be a no."  >

     Number of construction welds: <input type="number" name="numberofconwelds" class="required digits"  title="This field is required and must be a no.">

 Outputs

     Robot in/out: <input type="text" name="robotinout" disabled>

     Weld time: <input type="text" name="weldtime" disabled>

     Controlling cycle: <input type="text" name="concycle" disabled>

     Total time(secs): <input type="text" name="totaltimesecs" disabled>

     <input type="submit" value="Calculate cycle time ">     </form>            ';     }


Custom category for posts via XMLRPC

I have a blog located at one site that when I post into a category, it will auto-post via XMLRPC to another site of mine. This functionality works, but I would like to assign a category to these posts. Is there any way to do this? The only site that will be posting this way is controlled by me, so I don't care if it's global. Thanks