title: Comments and pingbacks issues

text:
I've been trying to figure this out for many, many days now. I tried to modifiy the code various times, always with the same result. I just don't get it. I want to properly separate pingbacks and comments which I did with the following code:               <?php if ( have_comments() ) : ?>
<?php comments_number('No Comments', '1 Comment', '% Comments' );?>

         <?php wp_list_comments(array(       'callback'=>'mytheme_comment',       'type'=>'comment',     )); ?>
       <?php paginate_comments_links(); ?>

      <?php else : // this is displayed if there are no comments so far ?>              <?php if ('open' == $post->comment_status) : ?>                            <?php else : // comments are closed ?>
Comments are closed.
              <?php endif; ?>     <?php endif; ?>               <?php if ( have_comments() ) : ?>

Pingbacks
     <?php wp_list_comments(array(       'callback'=>'mytheme_comment',       'type'=>'pings',     )); ?>
      <?php else : // this is displayed if there are no comments so far ?>              <?php if ('open' == $post->comment_status) : ?>                            <?php else : // comments are closed ?>
Comments are closed.
              <?php endif; ?>     <?php endif; ?>      However, the pingbacks (well the headline and everything) still shows up even if there are no pingbacks to display. I tried to change it to something like this:               <?php if ( have_comments() ) : ?>             <?php if ( ! empty($comments_by_type['comment']) ) : ?>
<?php comments_number('No Comments', '1 Comment', '% Comments' );?>

           <?php wp_list_comments('type=comment&callback=mytheme_comment'); ?>
             <?php endif; ?>                  <?php if ( ! empty($comments_by_type['pings']) ) : ?>
Trackbacks/Pingbacks

             <?php wp_list_comments('type=pings'); ?>
             <?php endif; ?>
       <?php paginate_comments_links(); ?>
      <?php else : // this is displayed if there are no comments so far ?>                  <?php if ('open' == $post->comment_status) : ?>                                       <?php else : // comments are closed ?>
Comments are closed.
                  <?php endif; ?>     <?php endif; ?>      However, now neither pingbacks, nor comments show up unless I take out the "if empty" command. If I do, then the pingback headline shows up again even if there are no pingbacks. This is driving me crazy! Maybe it has to do with the callback function? Here's the function I'm calling:               function mytheme_comment($comment, $args, $depth) {        $GLOBALS['comment'] = $comment; ?>        <li <?php comment_class('clearfix'); ?> id="li-comment-<?php comment_ID() ?>">          <?php echo get_avatar($comment,$size='63'); ?>          <div id="comment-<?php comment_ID(); ?>">
             <?php printf(__('%s'), get_comment_author_link()) ?><?php edit_comment_link(__(''),'  ','') ?> <?php printf(__('%1$s @ %2$s'), get_comment_date('Y/n/j'),  get_comment_time('G:i')) ?>
               <?php comment_text() ?>

                          <?php if ($comment->comment_approved == '0') : ?>              <?php _e('Your comment is awaiting moderation.') ?>
           <?php endif; ?>
              <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>

     <?php }      [Here's] a sample page of my website with comments and pingbacks.1 Please, help me figure this out. Thanks so much!


title: Query posts by custom taxonomy and sort by post_modified

text: I try to query 5 posts in cpt 'vacancy'. Query is very complex. For first I need posts that belongs to custom taxonomy with ID 18 and sorted by 'post_modified', then - all other posts in cpt 'vacancy' also sorted by 'post_modified'. And all of this limited to 5 posts. For now I use:               $query_hot = $wpdb->get_results("(SELECT * FROM wp_posts     WHERE post_type = 'vacancy' AND post_status = 'publish'     AND ID IN (SELECT object_id FROM wp_term_relationships WHERE     wp_term_relationships.term_taxonomy_id = 18)     ORDER BY post_modified DESC)     UNION     (SELECT * FROM wp_posts     WHERE post_type = 'vacancy' AND post_status = 'publish'     AND ID NOT IN (SELECT object_id FROM wp_term_relationships WHERE     wp_term_relationships.term_taxonomy_id = 18)     ORDER BY post_modified DESC) LIMIT 5");      It queries right posts, but not sorts by 'post_modified'. What I doing wrong?


title: How do I restrict user access to plugins?

text: I have created a new user role in my functions.php and set up booleans for each standard Wordpress capability (as listed on [the Wordpress Codex][https://codex.wordpress.org/Roles_and_Capabilities#unfiltered_upload]. So far, things are going great! I'm also using three plug-ins I'd like this user to have access to these plugins as well (Nextgen Gallery, Contact Form 7 and SEO Ultimate). How do I do this? I don't know what the capabilities of these plugins are, or where to find them. TL,DR: I want to set capabilities for a user role, but don't know the capabilities of the plugins NextGen Gallery, Contact Form 7 or SEO Ultimate).


title: the_post_thumbnail('my_image_size') always outputs full image

text: I'm developing a custom theme that uses several custom image sizes defined in my functions.php like this:               add_theme_support('post-thumbnails');     add_image_size('featured_thumb', 175, 120, true);      I then get posts from the database and output on a page like this:               $featured=get_posts();     if ($featured)     {               global $post;               foreach($featured as $post)               {                   setup_postdata($post);                   the_post_thumbnail('featured_thumb');               }               wp_reset_postdata();     }      But this code always outputs a full sized image. I can't figure out why - everything else seems to work alright (the_title(), the_permalink() etc) and it does get the correct image but not in the size I requested. Does anyone know under what circumstances `the_post_thumbnail()` will ignore my image size, or what I'm doing wrong? Edit: using WP 3.4.1


title: How to add custom page using them in wordpress 3.5

text: I did this before in wordpress 3.4 but that code seems not working. I add this code inside `wp-content/themes/` folder and I add new page from backend and try to select that. But it is not showing up, it's because new version..or am I doing it wrong?               <?php     /*     Template Name: Cover_Page     */     ?>          <?php get_header(); ?>     Here's my cover page!     <?php get_footer(); ?>


title: How to import individual blog posts into Wordpress?

text: I'm trying to move some content from another website into blog posts for work, and I need a little bit of help. Basically my task is to parse a bunch of files into their content, put them into a format that Wordpress understands as a blog post, and upload them. Problem is, I'm not really seeing a good way to do this -- I would like to be able to have individual blog posts in individual files so I can upload them one at a time. All that I'm seeing right now is a way to take full blogs and upload them, which isn't quite what I want. I'm also looking for a good format to do this in -- I'm sort of new to this. The content is originally plain text, so I can parse it into whatever format, really. I'm not sure which will be the easiest to build, though, so any help there would be great also. Thank you!


title: The ideal place for storing persistent PHP objects

text: I'm writing some plugins that do background batch processing, i.e. operations that take longer than 30 seconds. I'm creating objects with the necessary job parameters set like this (this is a hugely simplified example):               class MyPlugin_Create_Terms {         public $job_id;         public $terms;         public $taxonomy;         public $created = 0;         public function init( $terms, $taxonommy ) {              $this->job_id = uniqid();              $this->terms = $terms;              $this->taxonomy = $taxonomy;              return $this->job_id;         }         public function do_job( $object_storage ) {              foreach( $this->terms as $term ) {                  wp_insert_term( $term, $this->taxonomy );                  $this->created++;                  $object_storage->save_object( $this->job_id, $this );              }         }     }          $create_terms = new MyPlugin_Create_Terms();     $job_id = $create_terms->init( $_POST['user_input_terms'], $_POST['user_input_taxonomy'] );     $object_storage = new MyPlugin_Object_Storage();     $object_storage->save_object( $job_id, $create_terms );      And in another process:               $object_storage = new MyPlugin_Object_Storage();     $create_terms = $object_storage->load_object( $job_id );     $create_terms->do_job( $object_storage );      While anywhere else:               $object_storage = new MyPlugin_Object_Storage();     $create_terms = $object_storage->load_object( $job_id );     echo "We have created {$create_terms->created} terms.";      Now the problem is implementing the `Object_Storage`. I have figured out the following options for storing objects:   1. Transients. They apparently won't do, since they have no guaranteed life-time (with caching, the transients might never be written to the database, I've learned).   2. Existing DB tables. Serialized PHP objects should not be saved to MySQL `text` fields, since they might contain `NULL` bytes (( I had a spectacular WSOD failure when serializing an object with a `protected` property to the usermeta table) : > Note that this is a binary string which may include null bytes, and needs to > be stored and handled as such. For example, serialize() output should > generally be stored in a BLOB field in a database, rather than a CHAR or > TEXT field. - PHP Manual: serialize()   3. Creating a custom table with `BLOB` type fields for serializing any object or alternatively, storing the object data without serializing. Feels like overkill. What are the best practices?   4. Using the filesystem. Various factors like locking, atomic and non-atomic processes and file permissions complicate this. Specifically, since there will be two processes accessing the object concurrently, there is the problem with race conditions when they need to look at the same object.   5. Using _SESSION? Probably not good for two concurrent processes. Any thoughts would be appreciated!


title: Wordpress import media error

text: I have developed a theme and had to export all contents via the exporter. Now when i import them via the importer plugin the posts etc get imported but there is an error importing media. Could you please help me out? Here is a screenshot: ![](http://i.stack.imgur.com/ejfxt.png)


title: Change Custom Post Type singular_name through function/filter

text: I'm working on e-commerce site using woocommerce plugin. My client will be selling tickets online. woocommerce plugin creates custom post type "Product". I want to change this cpt singular_name to "Ticket" (just a cosmetic change) I'm ok with keeping cpt slug to "product" as it requires for other woocommerce functions? ![cpt_product](http://i.stack.imgur.com/rXyVo.png) Is there any function/filter available in wordpress to alter custom post type singular_name through function/filter


title: Registering menu with 'Automatically add new top-level pages to this menu' selected

text: Is it possible to register a menu inside of a theme functions file and have 'Automatically add new top-level pages to this menu' pre-selected? I can't find any info about this in the register_nav_menus documentation.


title: Modify post filter to set custom number of posts per page and exclude child posts

text: I have a custom post type called "galleries," which is hierarchical. I'm using a function in my functions.php file to modify the number of posts displayed per page to 48. That part works fine, but I also need it to exclude all child posts, so that only top-level parent posts make up the 48 posts pulled in per page. Here is the current code:                   function projects_custom_number_of_posts( $query ) {         if ( is_admin() || ! $query->is_main_query() )             return;              if ( is_post_type_archive( 'galleries' ) ) {             // Display 48 posts for a custom post type called 'galleries'             $query->set( 'posts_per_page', 48 );             return;         }     }     add_action( 'pre_get_posts', 'projects_custom_number_of_posts', 1 );      How can I modify the `$query->set` component to also limit the posts to top- level parent posts only? I tried the following, but it throws an error:                   function projects_custom_number_of_posts( $query ) {         if ( is_admin() || ! $query->is_main_query() )             return;              if ( is_post_type_archive( 'galleries' ) ) {             // Display 48 posts for a custom post type called 'galleries'             $query->set( array ('posts_per_page'=>48, 'post_parent'=>0) );             return;         }     }     add_action( 'pre_get_posts', 'projects_custom_number_of_posts', 1 );


What is the wordpress wp-includes folder for? That is, whats the fundamental architectural purpose of it, for example why isn't it all in themes or an admin folder? Can a plugin developer rely in it's contents (e.g. jQuery) and for how long? I would also like to know, who decides what goes in there and how does it get maintained as Wordpress changes, any is all this documented somewhere as a policy doc?


title: Building a plugin: use offset values, save to database, call values on frontpage in loop

text: I first posted this on StackOverflow, but now I realise that this is probably more suited for this site. _Updated 26 Feb. 2014_ I already that this question will be quite elaborate, so for everyone who is willing to try something to help me: I will put out a bounty as soon as I can. ## Case The loop (front page) of my website looks like this. (Zoomed out for better overview) ![Front page](http://stackoverflow.com/questions/22024587/extensive- use-of-jquery-ui-draggable-then-save-an-image-and-use-in-wordpress) As you can see, it is a regular "blog"-like stream of posts with a title, some meta information, a thumbnail ('featured image') and an excerpt. The wrapper (parent) of the thumbnail image is restricted to 658 pixels wide and 120px tall. The image itself has `max-width: 100%` so it will never be wider than its parent. In code, it looks something like this:               .entry-thumbnail {       max-height: 120px;       overflow: hidden;       margin-bottom: 1em;     }     .entry-thumbnail img {       height: auto;       max-width: 100%;       margin: 0 auto;     }      This works quite well if the content on the picture itself is at the top. However, when the top of the image is rather empty, the thumbnail looks empty as well. That is because only the top 120px of the image is shown. The remaining pixels are "cut off" because of the `overflow: hidden` that sits on its parent. As an example, you can see that there is way too much white space at the top. ![Too much white space](http://i.stack.imgur.com/kipBC.png) ## A solution **EDIT 1** : an answer provided by D. Kasipovic gives a good new insight. Rather than saving two seperate images (a full thumbnail and a cropped one), it should be possible to save the offset positions of the image. That way, these values can be inserted per image on the front page without having to use multiple images. **EDIT 2** : I edited the fiddle. Now the value that is seen in the input field (`#offset-val`) changes whenever one changes the position of the image. The value that is represented is a value relative to its parent. Ideally this value is saved in a database (and overwritten when changed) and when called, the thumbnail gets a css value of `top: X` in which case `X` stands for the value that is in the database. ## What I have tried so far First I have been looking into how I could make a draggable image and all that. (Cf. aforementioned fiddle). This works fine. I have looked into canvas and save canvas to image to save the image. However, this is not what I need. I have finished the fiddle. Now it's only a matter of saving the value of the input field to the database and hooking this value to the `the_post_thumbnail` function (with a filter?) so that when on the front page an extra argument is passed to it, namely the `style="top:X;"` value. ## What needs to be done/goal   * (End up with a Wordpress plugin)   * Save value to database (and overwrite when changed)   * In the loop the value should be imported as the X value of `top` inside a `style`-tag   * Either the `the_post_thumbnail()` should be changed so `style="top=X;"` is inserted, only when in the loop on archive pages or the front page Please do tell if something is not clear. It's clear in my mind, but it's hard to put into words.


title: upload multiple images in wordpress admin and create post

text: I have created a plugin with a new page in the admin area. Here I would like to create a function that images can be uploaded and for each image a post is created (with custom meta field data). I got this html form:               <label for="upload_image">     <input id="upload_image_button" class="button" type="button" value="Upload Image" />      and I got this javascript code: ` jQuery(document).ready(function($){ var custom_uploader; $('#upload_image_button').click(function(e) { e.preventDefault(); //If the uploader object has already been created, reopen the dialog if (custom_uploader) { custom_uploader.open(); return; } //Extend the wp.media object custom_uploader = wp.media.frames.file_frame = wp.media({ title: 'Choose Images', button: { text: 'Choose Images' }, multiple: true }); //When a file is selected, grab the URL and set it as the text field's value custom_uploader.on('select', function() { var selection = custom_uploader.state().get('selection'); selection.map(function(attachment) { attachment = attachment.toJSON(); // Do something else with attachment object $('#upload_response').html(attachment.url); //$('#upload_image').val(attachment.url); }); }); //Open the uploader dialog custom_uploader.open(); }); }); ` How can I now implement a function that create a post for each image and stores for example, the URL of the image into a custom post meta? thanks for your help!


title: Using custom post type as front home page pagination not working

text:
I've searched for days for a solution, scouring the interwebs, including, of course, stackoverflow. I'm using a custom post type as a static home page, but the pagination will not work. When I attempt to navigate to the second page, it reverts back to the same first page. This is not a problem unless I'm using it as a static front page. Here's the code I have set up.               <?php $home_num = get_option('of_home_num'); ?>          <?php query_posts( 'post_type=portfolio&posts_per_page='.$home_num.'&paged='.$paged); ?>          <?php if (have_posts()) : while (have_posts()) : the_post(); ?>          ... content ...          <?php endwhile; ?>          <?php else: ?>
<?php _e('Sorry, nothing here.', 'Zoho'); ?>
          <?php endif; ?>          <?php if (function_exists("pagination")) { pagination($additional_loop->max_num_pages); } ?>          <?php wp_reset_query(); ?>      I know the pagination function works fine, because I've used it many, many times before. I'm happy to offer a donation to anyone who can help out with this. Like I said, I'm stuck :)


title: Revision History for Entire Wordpress Site

text: I am learning wordpress and am working on a wordpress site where I would like to have a revision history for every single change I make. I understand you can see the revision history for pages and posts, but what about custom css + php files? I have some experience using git and github, so I am trying to save every single change I make to my website. Having version control is not necessary, I would just like to see every single edit I have made to the file. I am using Dreamweaver to edit the files or editing files within the wp-admin in the wordpress site. **UPDATE: I've changed the question** Question: Is there anyway to have Version Control/Revision History without using Git and having multiple setups of wordpress for the same site? (example: I do not need a Dev mode, Production mode, or branches) -Git seems too complicated for what I want to do **UPDATE: I've changed the question again** I can deal with the branches of git but I would like to be able to have git on the server automatically push any changes to the repo when I put my file to the server in dreamweaver.


title: Multipart/formatted MySQL query problem

text: I'm creating a plugin and I want to automate the creation of a MySQL Trigger on a table. The problem seems to be that $wpdb->query doesn't appear to accept either multipart statements and/or formatted queries. If I print and run the following query in phpMyAdmin it returns success. I also noticed if I formatted the query all on 1 line it would still report success but in this case the trigger is NOT created.               $wpdb->query(         "DELIMITER //         DROP TRIGGER IF EXISTS {$wpdb->get_blog_prefix($site->id)}post_queue_insert//         CREATE TRIGGER {$wpdb->get_blog_prefix($site->id)}queue_insert BEFORE INSERT ON {$wpdb->get_blog_prefix($site->id)}posts         FOR EACH ROW BEGIN             INSERT INTO {$wpdb->base_prefix}post_queue (action_id, action_type, action_status, action_timestamp, sync_complete, SITE_ID) VALUES (NEW.ID, NEW.post_type, NEW.post_status, UNIX_TIMESTAMP(now()), 0, {$site->id});         END//         DELIMITER ;"     );      Is there another function I can use or another way to format the query to run successfully?


title: Source problem for children page image

text:
I have this problem and maybe you can help me. I want to get a list of all children pages from page (with id 20) and then get the featured image from each one and resize with Thumbnail. Right now I get the_title from each one but not the Image so think there is a source problem. here's the code:                   <?php $args = array (                         'child_of'     => 20,                         'title_li'     => '',                         'depth'         => 0,                         'sort_order'    => 'DESC',                         'sort_column'   => 'menu_order'                         );                              $pages = get_pages( $args );                         foreach($pages as $page)  :         setup_postdata($post);              $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), false, '' );          $thumbnailSrc = $src[0];             ?>         <li id="<?php echo $page->post_name; ?>">
<a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?>
         <img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo $thumbnailSrc; ?>&h=256&w=415&zc=1q=100" />         <?php endforeach; ?>


title: Add custom read more to the_excerpt and <--more-->

text: My today's question is... is there any way to auto add an custom (whatever I want) Read more... each time I use the_excerpt or get_the_excerpt function??? Thanks in advance


title: infinite scroll not working when logged out

text:
**The problem:** infinite loop works only when the user is logged and then it shows posts that were not published yet. Once I log out, the infinite scroll doesn't work anymore. **The setup:** I have the following custom infinite loop function:               add_action('wp_ajax_zephyr_infinite_scroll', 'zephyr_get_nextpage');            function zephyr_get_nextpage() {         $loopFile = $_POST['loop_file'];         $paged = $_POST['page_no'];         $vv = stripslashes($_POST['vars']);         $vars = json_decode($vv, true);         $vars['paged'] = $paged;         global $isms;         global $zephyr_post_columns;         $zephyr_post_columns = $vars['columns'];         unset($vars['columns']);         $isms = $_POST['mas'];         query_posts($vars);         global $wp_query;          if ( $wp_query->found_posts == 0 ) {              echo 0;         } else {             get_template_part( 'templates/'.$loopFile );         }         exit;       }      Then I have in my `loop.php` file:               <?php global $zephyr_cont;          global $zephyr_post_layout;         global $zephyr_i;         global $isms;         global $zephyr_post_columns;         $zephyr_i = 0;         if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>             <?php              if ( $isms == 'true' ) {                 $zephyr_i++;                 get_template_part( 'templates/post', 'masonry'.get_post_format() );             } else {                 get_template_part( 'templates/post', get_post_format() );             }         endwhile; else : ?>
<?php _e('No posts found, go ', 'zephyr'); ?> <a href="<?php echo home_url(); ?>" title="<?php bloginfo('name'); ?>"><?php _e('home', 'zephyr'); ?>?
         <?php endif; ?>      And the `script.js` file:               function loadArticle(pageNumber) {             $('#ajaxload').fadeIn(300);             $.ajax({                   url: Zephyr.ajaxurl,                   type:'POST',                   data: {                     action : 'zephyr_infinite_scroll',                     page_no : pageNumber,                     loop_file : 'loop',                     vars : Zephyr.queryvars,                     mas : isms                 },                    success: function(html){                     if ( html !== '0' ) {                         if ( isms ) {                             $zephyr_container.isotope( 'insert', $(html) );                         } else {                             $(html).hide().appendTo('#content').fadeIn('300');                         }                         layoutSidebar(ms);                     } else {                         noload = 1;                     }                     $('#ajaxload').fadeOut(300);                 }               });               return false;           }


title: Create a slug for a page in WordPress

text: How can I create a slug for a page in WordPress? I see that there are custom formats available, but I would like to be able to specify things like:               mydomain.com/about          mydomain.com/home          mydomain.com/portfolio      etc. Is there a plugin or technique that I could use to accomplish this?


title: Pull out Advanced Custom Fields in Related post plugin

text:
I'm using Advanced Custom Fields plugin and microkid Related Posts. I would like to display my custom fields inside Related post This is what I got so far?               <?php //related artworks          $related = MRP_get_related_posts( $post->ID, true, false, 'quote_list' );          //for testing related array     //print_r ($related);          if(!empty($related)) {         foreach($related as $key => $value) {             $related = get_post($value);             $related_id=$related->ID;             $related_content=$related->post_excerpt;             $related_url=$related->get_permalink;             echo "

".get_the_title($related_id)."

";             //echo get_the_post_thumbnail($related_id);             echo "".$related_content."

";             echo "read more";             //for testing related array             //print_r ($related);         }          }?>      But how I would pull out my advanced custom field? Many thanks,


title: Random ID for custom post type

text: I am doing some testing with custom post types. Assume I have various page templates and a custom post type template that share one footer.php file. In the footer, I call `do_dis_function()` which is simply defined as:               function do_dis_function() {             global $post;                  the_ID();             // echo get_the_ID();             // echo $post->ID;     }      In both cases, in the page and/or CPT template, an ID displays... but only in the page template is it consistent. Upon further testing, I realize that if I am viewing the custom post type template, the ID that's echoed, which seems random at first, looks to be an ID from a custom post type entry which shares the same category. So to break it down, I have 5 projects, 2 categories. 3 of the projects share the same category. Their IDs are 16, 22 and 41. If I'm viewing post 22, the ID echoed is either 16 or 41. Dafuq. Someone please explain.


title: Can't change author to myself after post published

text: I am having this weird issue wherein if I create and publish a post, I can/am attributed as the author. However, if my editor creates a post and tries to add me as an author, I don't appear. It doesn't work even if I go in after she's done editing and try to make myself author. I still don't appear in the dropdown. Any idea about what may be the issue here? Can I provided more info/screenshots?


title: Different upload directory based on post type in a theme

text: I have a lot of uploaded image files and image sizes. So it would be better to organize media files into folders based on post type. I have just read this tutorial, but as I can see it works with plugins. How to change this to use in a theme? Thanks.               function custom_upload_directory( $args ) {               $id = $_REQUEST['post_id'];         $parent = get_post( $id )->post_parent;               // Check the post-type of the current post         if( "post-type" == get_post_type( $id ) || "post-type" == get_post_type( $parent ) ) {             $args['path'] = plugin_dir_path(__FILE__) . "uploads";             $args['url']  = plugin_dir_url(__FILE__) . "uploads";             $args['basedir'] = plugin_dir_path(__FILE__) . "uploads";             $args['baseurl'] = plugin_dir_url(__FILE__) . "uploads";         }         return $args;     }     add_filter( 'upload_dir', 'custom_upload_directory' );


title: wp_update_post making my post sticky

text: I am updating my post using below code:               $post_information = array(         'ID' => $_REQUEST['ID'],         'post_content' =>  $_REQUEST['content'],         'post_status'  =>  'publish'     );     wp_update_post($post_information);        But when I update my post, then it also make my post sticky, Please tell me how update my post whiteout making it sticky.


title: WP_Query articles order by offset in collumns

text:
The code below wants to show a list of articles in two collumns.                   <?php         $i = 0;         $the_query = new WP_Query( 'showposts=35&offset=0' );         while ($the_query -> have_posts()) : $the_query -> the_post();         $i++;         ?>              <?php if ($i == "1") { ?>
             <?php the_title(); ?>         <?php } ?>                   <?php if (in_array($i, array(3,4,5,6,7,8,9,10))) { ?>             <?php the_title(); ?>         <?php } ?>             <?php if ($i == 10) { ?>
        <?php } ?>              <?php if ($i == "2") { ?>
             <?php the_title(); ?>
                   <?php } ?>              <?php endwhile;?>      The problem is: the article with $i = 2 appears below article with $i = 1. It is not the order that I used in code above. How can I arrange articles in this order? PS: my articles with $i=2 appears in first collumn (aligned left) too, because of `</div>` after article with $i=10. If you have some questions, or if you don't understand, I'm here. EDIT: My code:               <?php     $the_query = new WP_Query( 'showposts=35&offset=0' );     while ($the_query -> have_posts()) : $the_query -> the_post();     $titles[] = get_the_title();                    $excerpts[] = get_the_excerpt();      endwhile;     ?>      To display first article:               <?php     echo $titles[0];     echo "
";     echo $excerpts[0];     ?>      Is code above ok for server speed?


title: Using radio button meta data from a custom meta box

text:
Very new to attempting PHP and am hacking together my first plugin using tutorials.. I have a custom meta box with a Yes/No radio button on all WordPress pages (in the editor). **EDIT-** I removed the original code. See below. So.. my question is, how do I check to see _which_ of the two buttons is checked using an if() statement? I plan on appending a script to WordPress pages that have 'yes' selected. I'm simply not sure which value I should be looking for, or how to call it out. **EDIT-** This is what I'm now using with no luck. Current code:               <?php     }          /**      * Adds a meta box to the post editing screen      */     function prfx_custom_meta() {     add_meta_box( 'prfx_meta', __( 'Meta Plugin', 'prfx-textdomain' ), 'prfx_meta_callback', 'page', 'side', 'high' );     }     add_action( 'add_meta_boxes', 'prfx_custom_meta' );          function is_edit_page($new_edit = null){     global $pagenow;     //make sure we are on the backend     if (!is_admin()) return false;               if($new_edit == "edit")         return in_array( $pagenow, array( 'post.php',  ) );     elseif($new_edit == "new") //check for new post page         return in_array( $pagenow, array( 'post-new.php' ) );     else //check for either new or edit         return in_array( $pagenow, array( 'post.php', 'post-new.php' ) );     }          /**     * Outputs the content of the meta box     */     function prfx_meta_callback( $post ) {     wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' );     $prfx_stored_meta = get_post_meta( $post->ID );     ?>
     <?php _e( 'Is this a thank you page?', 'prfx-textdomain' )?>
                      <input type="radio" name="meta-radio" id="meta-radio-one" value="radio-one" <?php if ( isset ( $prfx_stored_meta['meta-radio'] ) ) checked($prfx_stored_meta['meta-radio'][0], 'radio-one' ); ?>>             <?php _e( 'Yes', 'prfx-textdomain' )?>
                      <input type="radio" name="meta-radio" id="meta-radio-two" value="radio-two" <?php              if (is_edit_page('new')) echo "checked";              else if (isset ( $prfx_stored_meta['meta-radio'] ) ) checked($prfx_stored_meta['meta-radio'][0], 'radio-two' );              else  echo "checked";  ?>>             <?php _e( 'No', 'prfx-textdomain' )?>

          <?php     }          /**     * Saves the custom meta input     */          // Pending a fix from WordPress- https://core.trac.wordpress.org/ticket/16972     function prfx_meta_save( $post_id ) {          // Checks save status     $is_autosave = wp_is_post_autosave( $post_id );     $is_revision = wp_is_post_revision( $post_id );     $is_valid_nonce = ( isset( $_POST[ 'prfx_nonce' ] ) && wp_verify_nonce( $_POST[ 'prfx_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';          // Exits script depending on save status     if ( $is_autosave || $is_revision || !$is_valid_nonce ) {         return;     }          // Checks for input and saves if needed     if( isset( $_POST[ 'meta-radio' ] ) ) {     update_post_meta( $post_id, 'meta-radio', $_POST[ 'meta-radio' ] );     }     }     add_action( 'save_post', 'prfx_meta_save' );     echo '
' . print_r($_POST, true) . '
';          global $post;     $post_id = $post->ID;     get_post_meta( $post->ID, $_POST['meta-radio'], true );     $response_radio = $_POST['meta-radio'];          if ($response_radio=="radio-one") {         add_action('wp_footer', 'add_this');         function add_this() {         echo "The Yes button is selected...";       }       } elseif ($response_radio=="radio-two"){           add_action('wp_footer', 'add_this');         function add_this() {         echo "The No button is selected...";     }      } else {         add_action('wp_footer', 'add_this');         function add_this() {         echo "No data is passing...";     }     }      The result is "No data is passing..." when viewing a live page (even though the data is saving in the meta box). **Edit-** I added: `echo '<pre>' . print_r($_POST, true) . '</pre>';` Below: `add_action( 'save_post', 'prfx_meta_save' );` Output (editor and published page): `Array ( )`


title: Only show posts from a certain category?

text:
How can I only show items from a certain category (category 51)? Here's my loop below that I need to incorporate the code into.
       <?php $portfolioloop = new WP_Query( array( 'paged' => get_query_var('paged'), 'post_type' => 'news', 'posts_per_page' => 4 ) ); ?>       <?php while ( $portfolioloop->have_posts() ) : $portfolioloop->the_post(); ?>       <div class="news-item" onClick="location.href='<?php echo the_permalink(); ?>'">
<a style="color:#F45B11!IMPORTANT;" href="<?php echo the_permalink(); ?>"><?php echo the_time('d.m.Y'); ?> / <?php echo the_title(); ?>

           <?php if (get_field('description') != "") { ?>           <?php echo the_field('description'); ?>             <?php } else {              $newscontent = get_the_content();             $newscontent_str = strip_tags($newscontent, '');             echo substr($newscontent_str,0,250) . "…";             } ?>

       <?php endwhile; // end of the loop. ?>
<?php echo wp_count_posts('news')->publish; ?> opportunities
         <?php if (function_exists('wp_pagenavi')) {         wp_pagenavi( array( 'query' => $portfolioloop ) ); } ?>


title: How to embed php page from separate site

text: I have configured a Wordpress site for a client for which the content has been migrated from a static HTML site from 2004. The old site has a link which takes the user to a PHP form (also developed in 2004) which is hosted on a separate domain. This PHP page queries a MySQL database also hosted on the separate domain. I have been asked if I can make this PHP form appear as part of the new Wordpress site rather than as a link to an external site. Currently the most straight forward option I can think of is to modify the styling used by the PHP form and then embed it using an iFrame. Alternatively I could try and build a form in Wordpress that will query the MySQL database on a separate domain, but this seems like a lot of work and may have security implications. Given I am relatively inexperienced with Wordpress what other options are there for doing this?


title: Is there any plugin which can paste a common content to my every post?

text: I am using wordpress for my blog. My blog contains events details and in every post i want to start with "this information is exclusively provided by...." this statement and end with my "feedburner subscribe us box" So what I am actually looking for is               <---My String--->         MY Actual Post     <---My feedburner subscribe us code--->      this. Is there any plugin which can automatically add the common stuff to my post. Please help out.


title: How to save the output of php variables used in inline css code to the main style.css?

text: I have some PHP variables that each represent some user settings set via a theme options interface such as:   * theme colors   * typography   * etc. All these variables are in a file called `dynamic-style.php`:               <?php     <style type="text/css">     body {         color: <?php echo $text_color; ?>;     }     </style>     ?>      Is there a way to get the parsed CSS code from `dynamic-style.php` and save it to the main `style.css` at the bottom of the file? I need this to be done to decrease the number of HTTP requests on a public theme. Thank you.


title: How to write: $wpdb->update having WHERE NOT value pair in the array

text: I need to update all meta keys in the postmeta table that have a value other than 0, to the value of 0. I tried this.. no love (though I cannot figure out why....):               $status = $wpdb->query("UPDATE {$wpdb->prefix}postmeta SET meta_value=0 WHERE meta_key = _wti_like_count AND meta_value <> '0'");      I'm on this concept, but how to say "!0" NOT 0 in the key list?               $wpdb->update('wp_postmeta', array('_wti_like_count' => '0'), array('_wti_like_count' => '0'));      Thanks a ton! UPDATE: I fixed my `$wpdb->query` as follows and it works:               $status = $wpdb->query("UPDATE {$wpdb->prefix}postmeta SET meta_value='0' WHERE meta_key = '_wti_like_count' AND meta_value <> '0'");      However, I would still like to know if there is a way to pass a key pair array to the `WHERE` parameter of `$wpdb->update` and request a `!=` value.


title: tax_query in WP_Query problem

text: I am trying to create a widget which queries multiple taxonomies for my plugin but am having problems with my query. My query is:                   $query_args = array(             'numberposts' => $limit,             'order' => 'DESC',             'orderby' => 'post_date',             'post_type' => 'match',             'posts_per_page' => $limit,         );              $query_args['meta_query'] = array(             'key' => 'played',             'value' => true,         );              $query_args['meta_query'] = array(                         'relation' => 'OR',             array(                 'key' => 'home_club',                 'value' => $club,             ),             array(                 'key' => 'away_club',                 'value' => $club,             ),         );              $query_args['tax_query'] = array(             array(                 'taxonomy' => 'comp',                 'terms' => $comp,                 'field' => 'term_id'             ),             array(                 'taxonomy' => 'season',                 'terms' => $season,                 'field' => 'term_id'             ),             array(                 'taxonomy' => 'team',                 'terms' => $team,                 'field' => 'term_id'             ),             array(                 'taxonomy' => 'venue',                 'terms' => $venue,                 'field' => 'term_id'             ),         );              $r = new WP_Query( $query_args );              if ( $r->have_posts() ) {                  while ( $r->have_posts()) {             $r->the_post();                 ...             }         }      I'm 99.9% sure that the taxonomies are correctly registered as they are in use in many other areas of the site including a similar widget using `get_posts`. The above query outputs nothing, as if there are no matches. If I add `'relation' => 'OR',` to the `tax_query` it shows a list of matches but without the taxonomy filtering, the same happens if I remove the `tax_query` completely. The following SQL query is generated:               SELECT SQL_CALC_FOUND_ROWS hoc_posts.ID      FROM hoc_posts      INNER JOIN hoc_term_relationships      ON (hoc_posts.ID = hoc_term_relationships.object_id)      INNER JOIN hoc_term_relationships AS tt1      ON (hoc_posts.ID = tt1.object_id)      INNER JOIN hoc_term_relationships AS tt2      ON (hoc_posts.ID = tt2.object_id)      WHERE 1=1      AND ( hoc_term_relationships.term_taxonomy_id IN (17) OR tt1.term_taxonomy_id IN (3) OR tt2.term_taxonomy_id IN (4) )      AND hoc_posts.post_type = 'match'      AND (hoc_posts.post_status = 'publish' OR hoc_posts.post_status = 'private')      GROUP BY hoc_posts.ID      ORDER BY hoc_posts.post_date DESC LIMIT 0, 6      And the result of `print_r( $query_args );` is:               Array (          [numberposts] => 6          [order] => DESC          [orderby] => post_date          [post_type] => match          [posts_per_page] => 6          [meta_query] => Array (              [key] => played              [value] => 1          )          [tax_query] => Array (              [relation] => OR              [0] => Array (              [taxonomy] => comp              [terms] => 17              [field] => term_id              )              [1] => Array (              [taxonomy] => season              [terms] => 3              [field] => term_id              )              [2] => Array (             [taxonomy] => team              [terms] => -1              [field] => term_id              )              [3] => Array (              [taxonomy] => venue              [terms] => 4              [field] => term_id              )          )      )      I'm pulling my hair out trying to figure out the problem. I've searched through several related posts on this site and SO but none seem to have solved my particular problem. Any help would be greatly appreciated. :)


title: Can't show custom post thumbnail sizes as background images

text: I'm trying to work out a solution for responsive background images in Wordpress to use on my clients' sites. This is what I got: 1) I created some custom thumbnail sizes:               function custom_image_sizes() {         add_image_size ( 'small_regular', 832, 800, true );         add_image_size ( 'small_retina', 1664, 1600, true );         add_image_size ( 'big_regular', 1728, 800, true );         add_image_size ( 'big_retina', 3456, 1600, true );     }     add_action( 'after_setup_theme', 'custom_image_sizes' );      2) Now I'm trying to use them in my template with inline media queries, like this:               $small_regular = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( 832, 800, ) );     $big_regular = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( 1728, 800, ) );     echo "<style type='text/css'>";     echo ".entry-featured-image { background-image: url('{$big_regular[0]}'); }";     echo "@media screen and (max-width:48em) { .entry-featured-image { background-image: url('{$small_regular[0]}.'); } }";     echo "</style>";      The point is: inline media queries are working, but they always show the same image size (832x800) no matter what. How do I fix that?


title: Insert Google authorship into WordPress header

text: I'm working on a custom plugin that creates courses and lessons within WordPress. Here's the page I'm trying to get Google authorship showing in:   → http://myguitarpal.com/videos/?lesson_id=13 Google authorship needs to be in every lesson and should be in the header. It's the same author for every lesson. I thought it would be as simple as adding this to the `lessons.php` file, but it's not. Nothing shows up when I view the source.               <?php         function google_authorship(){             echo '<link rel="author" href="https://plus.google.com/authorname">';         }         add_action('wp_head', 'google_authorship');     ?>      I'm assuming it's because `header.php` is loaded before this block of code runs and the action hook doesn't get hooked. I checked our theme and `wp_head()` is in `header.php`. I guess I could modify the `header.php` file and do:               <?php         is_page('videos'){             echo '<link rel="author" href="https://plus.google.com/authorname">';         }     ?>      But I don't want to modify the theme if I don't have to. There must be a way to add code to the header from within a plugin. Is there? After a lot of searching, I haven't been able to find a solution.


title: Permalinks that start with same string as blog's directory not working

text: I have a blog in a directory called "press". Permalinks are set to post-title and work in most cases, but if a post/page-title starts with the string of the directory, in this case "press", the post/page is not found. For example the page with the permalink "/pressclippings" is not found under that permalink. I already deactivated all plugins, but the problem remains. Strangely enough, if I add a dash to the link (not the permalink itself, but in the address bar of the browser), the page is found, i.e. a page with the permalinks "/pressclippings" will be found with "www.mydomain.com/press/-pressclippings", but not with "www.mydomain.com/press/pressclippings". I already reset the .htaccess to the standard wordpress .htaccess, so the problem must be somewhere else. Any ideas where to look?


title: Images inserted with HTML

text: I coded some images each image tag with a new line, so visualy you would have a row of images. When I previewed the page instead of showing me a row of images it showed me a column of images. It seems that if I have a new line for all my images or a row of images in Sublime Text 2, and then paste that info onto wordpress it keeps it a row of images (Visually). Editor(ST2):                                         This is confusing to me because before I started working with WordPress I was working on a website staight from Sublime Text 2 and this was not the resulted behavior for images. The only way that they would be in lists of images was if I was using `<li>` tags in an `<ul>` or if I put `<br>` in bewteen the images. Does WordPress handle code differently than the standard?


title: $wpdb in php 5.5

text: I am helping a friend update their website and move it over to a new server. Their old server is running php 5.3.6-13 and the new site is running php 5.5. There is a custom plugin that uses $wpdb that allows the user to edit some information that is written to a custom table in the database, specifically:               $query = "UPDATE wp_building_plan SET sale_price = '$sale_price', available = '$available', broker_name = '$broker_name', broker_email = '$broker_email',    broker_phone = '$broker_phone' WHERE id = '$unit_id' ";      $wpdb->query($query);      Here is the actual code for the plugin: http://snippi.com/s/dk7bxvx On the server running 5.3 the data can be written to the appropriate rows within the wp_building_plan table when info is updated or changed. On the new server running 5.5 when data is changed within the plugin nothing is changed or written to the database at all. I am trying to find a better way to write the UPDATE wp_building_plan code that is compatible with PHP 5.5 I've checked out the following links and tried to implement them but have not had any success: http://www.php.net/manual/en/function.mysql-db-query.php http://codex.wordpress.org/Class_Reference/wpdb http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for- wpdb-prepare/ http://markoheijnen.com/the-future-of-wpdb/ Any tips or pushes in the right direction would be greatly appreciated, d


title: Get current terms info when querying by multiple taxonomy terms

text:
I'm currently using the following in my archive template to create a menu of taxonomy terms and add a 'live' class to the term that's currently being queried.               $termsA = get_terms('MYTaxA', array( 'parent' => 0, 'hide_empty' => 0 ));     $currentA = get_term_by( 'slug', get_query_var( 'term' ),  'MYTaxA' );     foreach ($termsA as $term) {         $class = $currentA->slug == $term->slug ? 'live' : '' ;         echo '
slug .'">' . $term->name . '
';     }      This works great, except I have another instance of the above elsewhere on the page with a separate menu of terms from a different taxonomy. This secondary menu is visible when the first is active. The link structure of the secondary menu is set up so that you can query by multiple taxonomy terms like so: _WEBSITE.com/?MyTaxA=term &MyTaxB=term_.               $termsB = get_terms('MYTaxB', array( 'parent' => 0, 'hide_empty' => 0 ));     $currentB = get_term_by( 'slug', get_query_var( 'term' ),  'MYTaxB' );     foreach ($termsB as $term) {         $class = $currentB->slug == $term->slug ? 'live' : '' ;         echo '
slug .'&MYTaxB='. $term->slug .'">' . $term->name . '
';     }      The problem I'm having is that the second instance of get_term_by is not returning anything and so I'm unable to compare the second term being queried to the second menu and ultimately apply the 'live' class like we can to the first menu. Btw, I do not want to use the QMT plugin.


title: How to write testable classes in Wordpress

text: I'm currently doing some modifications on the Wordpress plugin that I created in order to make it testable. The problem is I don't know which methods am I suppose to write tests for. I have methods which uses some of these functions and global variables:               is_singular()     $_GET     $_POST     $_SESSION      `is_singular`, `is_page`, `is_home` and other functions depends on the context. I'm not sure how to fake those context in a test. I tried passing those as arguments to the methods instead but there are some hooks that doesn't accept additional arguments so I can't really pass them. Is it OK to just supply those from the test class? I'm really having difficulty modifying the plugin in such a way that I don't use those. Any ideas? **Update** I'm using wordpress-tests and PHP Unit for the unit testing. I've done some research on unit testing before I started and there's a practice that when unit testing global variables should be avoided.


title: very slow wordpress query with default query

text:
I had been asking questions about this issue but sadly not getting the help blog at this address : http://fixapk.com Currently, the blog includes approximately 560,000 apps ( 560,000 equivalent posts) each article covers about 20 custom fields therefore wp_postmeta table is the largest table ( with about 10 million records ) However, when the query to the table wp_postmeta very good for speed , for example : When access to the single post the query related articles based on the title , the speed is very good ( you can access on an article to see any speed ) Or : When using the search function shows good speed ( not the best) But when access to the category , the speed is really slow for example, when accessing the APPS category ( fixapk.com/apps ) or GAMES ( fixapk.com/games ) , the speed is too slow Category apps has about 300k posts . This means that the default wordpress query very slow ( query base on category ) and here is the content of the file archive.php               <?php get_header(); ?>
         <?php             if (have_posts()):while(have_posts()):the_post();             $numdown=get_post_meta($post->ID,'_numdown',true);             $icon=get_post_meta($post->ID,'_icon',true);             $screenshot=get_post_meta($post->ID,'_screenshot',true);             $language=get_post_meta($post->ID,'_language',true);             $licesne=get_post_meta($post->ID,'_licesne',true);             $os=get_post_meta($post->ID,'_os',true);             //....         ?>
             <img src="<?php echo $icon; ?>" /> <a href="<?php the_permalink(); ?>"><?php the_title(); ?>             <?php the_excerpt(); //.....?>

     <?php get_footer(); ?>      Thus, how to replace the default query to speed wordpress Look forward to the help


title: Custom conditions in wp query

text: This is basic query arguments .               $loop = new WP_Query(array('post_type' => 'project', 'posts_per_page' => -1));      Now I want to pass custom arguments like 1.If it is front page post_type will be "post" and post per page will be "4" I know how to do it `is_front_page() {//do stuff here}` .But I want to inject the condition like this way                $loop = new WP_Query(array('post_type' => 'is_front_page() {//do stuff here}', 'posts_per_page' => -1));      Can I do it?


title: Send invitations by email. invite someone to the group who is not yet a member on buddypress

text: I am using wordpress 3.8, buddypress Version 1.9, invite anyone plugin to invite people to the group by email Group mod's need to send invitation by email for this i am using a plugin invite anyone but it is showing entire list of members on my website including send invitation by email Now i need to hide entire list of members to group mod's on buddypress groups Please assist me, thanks for help in advance Thanks and regards,


title: How to get the SQL of the changes made to the database from an update or upgrade?

text: When I update/upgrade a plugin, theme, or even the core of WordPress, it has an impact in the database, it changes many things. How do I keep track of it? The problem is that I have a repository, all the changes made to the files are all correctly tracked, but I don't have any idea how to create an SQL file to store the database changes (alter, insert, update, drop, create, etc.). I use a tool, which is Flyway, that picks the list of SQL files I have in the repository and applies the query of each file to the database, so my question is, how do I create or get an SQL query of all the changes made by the update/upgrade future of WordPress? This way all the team will be able just to make a pull from the repo and the changes I did will be propagated. Thanks.


title: wp_update_post behaves differently for different user role

text: {       "sections": [         {           "section_name": "Objective",           "data": "Test",           "key": "ref"         }       ]     }      I am updating the above JSON data as plain text through wp_update_post               data = <<<EOD     {"sections":[{"section_name":"Objective","data":"Test","key":"ref"}]}     EOD;         $new = array(                     'post_title'    => $title,                     'post_content'  => $data,                     'post_author'    => $userid,                     'post_status'   => 'pending',                     'post_type' => 'post'                   );              $id = wp_insert_post($new );      The data is saved exactly like it passed with escaped slashes only on "Administrator" login. On all other user types, for ex "subscriber", the slashes are automatically stripped when saved. which makes it invalid JSON. How to save the exact passed data for all user types?


title: CPT-onomies CPT_TAXONOMY->get_terms extremely slow with 6K posts

text: I currently have a site with 6K posts. There are 3 CPT taxonomies that are attached to posts. When I try to access .../wp-admin/edit.php, I'm getting the following LONG QUERY error:               SELECT wpposts.ID, ( SELECT COUNT(*) FROM wp_postmeta wpmeta INNER JOIN wp_posts wpmetaposts ON wpmetaposts.ID = wpmeta.post_id AND wpmetaposts.post_type IN ( 'post' ) AND wpmetaposts.post_status = 'publish' WHERE wpmeta.meta_key = '_custom_post_type_onomies_relationship' AND wpmeta.meta_value = wpposts.ID ) AS count FROM wp_posts wpposts WHERE wpposts.ID IN ( '1000197','21759','21205','21204','21203','21202','21201','21200','21199','20207','20205','20200','20149','19337','19154','19139','18632','18311','18306','18304','18287','18285','18279','18277','18275','18273','18247','18086','17693','17621','17284','17134','16976','16970','16946','16759','16703','16702','16701','16699','16698','16697','16696','16695','16694','16693','16660','16299','16192','16187','16178','16176','16173','16170','16169','16160','16156','16154','16152','16054','16053','16052','15924','15890','15884','15844','15831','15672','15485','15406','15299','15196','15180','15168','15060','15005','14996','14886','14749','14681','14680','14679','14677','14662','14610','14586','14422','14421','13982','13683','13682','13666','13576','13568','13555','13553','13495','13406','13405','13399','13394','13393','13392','13390','13389','13354','13321','13319','13302','13301','13300','13299','13184','13128','13075','13071','12996','12774','12773','12308','12197','12050','12033','11782','11206','10821','10820','10816','10788','10286','10280','10279','10278','10277','10276','10275','10267','10264','8753','8482','8481','8480','8479','8478','8477','8476','8475','8445','7768','7353','6948','6900','6899','6898','6896','6895','6894','6877','6730','6611','6609','6605','6565','6372','5992','5660','5577','5510','5492','5359','5119','5004','4964','4963','4961','4919','4844','4817','4813','4531','4052','4051','4050','4048','4047','4046','4045','4044','4042','4041','4039','4038','3987','3986','3984','3983','3964','3703','3699','3540','3475','3474','3450','3430','3403','3402','3401','3336','3325','3281','3243','3234','3091','3041','2928','2900','2889','2869','2828','2826','2801','2735','2719','2703','2702','2699','2651','2632','2631','2630','2629','2568','2511','2475','2407','2386','2361','2332','2318','2300','2123','2122','2066','2042','2039','2038','2004','2003','2002','1974','1917','1856','1673','1671','1612','1532','1530','1507','1455','1452','1196','1189','1188','1128','894','893','892','891','855','854','850','609','608','548','449','286','285','241','159','146','144','141','93','92','91','85','84','73','72','71','70','69','68','67','66','65','64','63','62','61','60','59','58','57','56','55','54','53','52','51','50','49','48','47','46','45','44','43','42','41','40','39','38','37','36','35','34','33','32','31','30','29','28','27','26','25','24','23' ) AND wpposts.post_status = 'publish' ORDER BY wpposts.ID ASC      If I detach all but one of the taxonomies, I can get to .../wp-admin/edit.php. Query monitor shows the following stats: > SPEED: 15.03 second load time > > **CPT_TAXONOMY->get_terms** 4 13.3913 > > **CPT_TAXONOMY->wp_get_object_terms** 2 0.2535 I'm trying to figure out the best way to modify the plugin so that the query hooks don't cause the edit pages to be unreachable. If anyone out there is familiar with this plugin and might have some optimization suggestions, I'd really appreciate it!


title: Problem with multiple tags in URL

text: I used the link mydomain.com/tags/tag1,tag2/ on my Wordpress website with no problems whatsoever. But it doesn’t work from a certain moment. It displays error 403: Forbidden. I noticed that links with only tag works fine, but with multiple don’t. What could be a problem?


title: wp_redirect shows header already sent message

text: I am new to wordpress plugin development. I have created a list page and an add item page. When I add successfully, I want to redirect and it is giving me this error. ![enter image description here](http://i.stack.imgur.com/5t4zE.png) **Notice the error is on`pluggable.php on line 876`** I have checked many sources but unable to find the solution so far   1. I have used `wp_redirect('admin.php?page=ccURLList'); exit;` it gives the attached error   2. I have used `no-header` in the query string of form submission, it does work but in case of any error I wanted to show the page again and that page is without any sidebar or wp stuff   3. When i move the `wp_redirect` to my main file `clickCounter.php` it says function is unknown If any of you can resolve this issue, it will be highly appreciated. **EDIT** `clickCounter.php` is my main file. It creates menus etc. I have a list page which is working. I have an add page. I have put the wp_redirect on the very first lines after               <?php     // ccURLAdd.php my add page     if (!defined('ABSPATH'))         die('You are not allowed to call this page directly.');          add_action( 'init', 'CCaddNewLink' );     function CCaddNewLink(){         wp_redirect(home_url());         exit;     }     //wp_redirect('admin.php?page=click-counter');     exit;      Below is my main file               <?php     // clickCounter.php my main page.     /* some plugin info */     add_action('admin_menu', 'ccAdminMenu');     function ccAdminMenu()     {         add_menu_page("Click Counter", "Click Counter", 8, 'click-counter', "ccAdminMenuListUrls", CC_HTML_WEB . "/images/icon.png");         add_submenu_page('click-counter', 'Add New Link', 'Add Link', 8, 'click-counter-url-new', 'ccAdminAddUrl');          }     function ccAdminAddUrl()     {         include 'ccURLAdd.php';     }


title: Ordering taxonomies by rank

text:
I'm using a function (copied and modified a bit from this question ) which displays taxonomies in order by rank with » between parent and child and | between terms, but I get a mistake in the html output and I don't understand what's wrong. Here's what I put in my functions php (the function I copied from WP questions):               function print_taxonomy_ranks( $terms ) {         // if terms is not array or its empty don't proceed         if ( ! is_array( $terms ) || empty( $terms ) ) {             return false;         }              foreach ( $terms as $term ) {             // if the term have a parent, set the child term as attribute in parent term             if ( $term->parent != 0 )  {                 $terms[$term->parent]->child = $term;                } else {                 // record the parent term                 $parent = $term;             }              echo "taxonomy/$parent->slug'>$parent->name » child->taxonomy}/{$parent->child->slug}'>{$parent->child->name} | ";            }     }      (Note: I'm using absolute path `http://blogadress` because I'm running it locally and I'm not managing to make it work otherwise) And here's what I put in my template file
<?php print_taxonomy_ranks( get_the_terms( $post->ID, 'soggetto' ) ); ?>
      Here's the WRONG html output I get: error1: the first two terms don't appear (just a link to the blog home with a double slash at the end, linked to nothing); error 2 (unwanted behavior): the terms parents appear two times: once as solitary terms, and once as parents of the children.
 »  |      parent1 » child1 |      parent2 »  |      parent2 » child2 |


title: How Can I Add the "Insert From URL" Tab to a Custom 3.5 Media Uploader?

text: I've inserted a WP 3.5 media uploader into a widget by running this JavaScript when a button is clicked on:               var frame = wp.media( {         title       : 'Widget Uploader',         multiple    : false,         library     : { type : 'image' },         button      : { text : 'Select Image' }     } );          frame.on( 'close', function() {         var attachments = frame.state().get( 'selection' ).toJSON();         imageWidget.render( widget_id, widget_id_string, attachments[0] );     } );          frame.open();     return false;      That gives me a modal that has the "Upload Files" and "Media Library" tabs, but I also want it to have the "Insert From URL" tab that you get when you click on the "Add Media" button while editing a post/page. ![enter image description here](http://i.stack.imgur.com/KV78g.png) I've spent a couple hours digging around the web, reading through the source code and and watching Daryl Koopersmith's presentation on the uploader's backend, but haven't been able to figure it out. Can someone point me in the right direction? Is there a parameter I can pass to wp.media() to include it, or should I use one of the built-in views/models that includes it?


title: Nextgen Gallery and slideshow: images are not changing

text: If I don't use the option `Flash Slideshow` the slideshow only shows me the first image. It doesn't fade to the next image. FireBug gives me the following error: `TypeError: a.browser is undefined` in the file `/wp-content/plugins/nextgen- gallery/js/jquery.cycle.all.min.js?ver=2.9995`. I'm using jQuery 1.9.1 for my custom theme and NextGEN Gallery 1.9.12. Any ideas?


title: Serve apache 404 for missing assets rather then wp 404 template WP_Rewrites

text: I have a custom 404 page, but dont want serve it for every broken asset that may crop up. Instead I want to just serve the Apache 404 as its much faster. I've found the following htaccess rule that will achieve what Im after:                RewriteEngine On      RewriteCond %{REQUEST_FILENAME} !-f      RewriteRule \.(jpg|jpeg|png|gif|ico|swf|bmp|js|css)$ - [nocase,redirect=404,last]       But rather then manually placing it in the htaccess file before `# BEGIN WordPress` I'd like to programatically add the rule via the theme, as Im also trying to get my head around WP's rewrite API. My current rules are below with the crucial line added manually for testing:               # BEGIN WordPress     <IfModule mod_rewrite.c>         RewriteEngine On         RewriteBase /         RewriteRule ^index\.php$ - [L]         RewriteRule ^assets/css/(.*) /wp-content/themes/tr_roots_0.4.1/assets/css/$1 [QSA,L]         RewriteRule ^assets/js/(.*) /wp-content/themes/tr_roots_0.4.1/assets/js/$1 [QSA,L]         RewriteRule ^assets/img/(.*) /wp-content/themes/tr_roots_0.4.1/assets/img/$1 [QSA,L]         RewriteRule ^plugins/(.*) /wp-content/plugins/$1 [QSA,L]         RewriteCond %{REQUEST_FILENAME} !-f         RewriteRule \.(jpg|jpeg|png|gif|ico|swf|bmp|js|css)$ - [nocase,redirect=404,last]          RewriteCond %{REQUEST_FILENAME} !-d         RewriteRule . /index.php [L]     </IfModule>      I've been looking a a lot of examples in and effort to try to achieve this, but they seem inordinately complicated, and not directly applicable. Could someone take a stab at putting me in the right direction? This is what I have (not doing the trick) so far:               function tr_flush_rewrites() {       global $wp_rewrite;       $wp_rewrite->flush_rules();     }          function tr_add_rewrites() {          global $wp_rewrite;           $tr_new_non_wp_rules = array(            '\.(jpg|jpeg|png|gif|ico|swf|bmp)$' => 'nocase,redirect=404,last',          );          $wp_rewrite->non_wp_rules = $tr_new_non_wp_rules + $wp_rewrite->non_wp_rules;     }     add_action('generate_rewrite_rules', 'tr_add_rewrites');     add_action('admin_init', 'tr_flush_rewrites');      Thanks for looking


title: wp_nav_menu: current_post_ancestor-category parent

text: I have a nav like this:   * page 1 -- page 1.1 -- category 1.2      * page 2     * page 3 When I am on a single post in the category 1.2, the category-menu-item gets the correct class `current-post-ancestor` and `current-post-parent`, but the page 1 has none of the parent or ancestor classes. Is there a way to add a `foobar"` class down the nav hierarchy? I've fouad some filters for `nav_menu_css_class` but can't get the correct behavior.


title: Adding custom styles to elements, without creating new elements

text: So Im using the `tiny_mce_before_init` filter to added a few classes to the `wp_editor` and am getting unexpected results. I havent used this before, but from what Im reading and what my peers tell me I should be able to apply classes to elements in the editor directly, and not creating a wrapper element. So I have this:                $new_styles = array(             array(                 'title' => __( 'Custom Styles', 'title' ),                               array(                     'title'     => __('Table Header','kjd'),                     'classes'   => 'table-header',                     'wrapper'   => true                 ),                 array(                     'title'     => __('Table Subheader','kjd'),                     'classes'   => 'table-subheader',                     'wrapper'   => true                 )....      From what I understand, both `'inline'` and `'block'` are optional and the `'wrapper'=>true` argument will apply the class to the selected element, and not wrap it in whatever. But no matter which options I apply (like `'wrapper'=>false`, or `'block' => 'td'` ) work. Anyway, Im told that this funcationality changed in WP 3.9 My goal is to apply some classes to table cells so that when my client copies and pastes in a table, they can style it appropriately. They would click a cell and apply the style to said cell.


title: Security updates to 3.3.2

text: I know all security updates are important but given that how important on a scale from 1 to 10 is it to upgrade from 3.1.3 to 3.3.2. I have some sites that need to be upgraded but the host has me locked down in an older version of php that limits me to 3.1.3. I am currently running version 5.2.3 of php. Thanks, Bart


title: Is it possible to stop selected plugins from loading on certain template pages?

text: I have a template page that has form on that is only used once in my site. The form uses form validation using jquery validate plugin (such a great plugin). Once the cart66 Plugin is loaded, the form validation stops working. Rather spending ages looking for the conflict, I thought it would be easiest to just turn off the plugin for that template page as cart66 is not need on this page. Is it possible to stop plugins loading on individual template pages? I am using WordPress 3.2.1


title: How would you require and automatically download dependent plugins?

text: Was wondering if there was a class or programming technique that would allow me to check for the installation and activation of a particular plugin and if said plugin were not installed, to have it downloaded from WordPress's plugin repository? I have a plugin I would like to require scribu's Post 2 Post plugin and I was wondering how it could be done?


title: Plugin to assign parent category on multiple taxonomy terms

text: I've inherited a mess of a WP site. I need to be able to take 100+ categories and rearrange parent/child relationships. I need something with a UI that will make this easy. Anyone know of a plugin that does this?


title: Can Wordpress redirect to a "similar page" in case of 404 error

text: This stuff is driving me nuts. The following url does NOT exist and should return a 404: http://www.easyjob.net/resume/ However, if I try to access it, I get a 301 to http://www.easyjob.net/r/cover- letter/resume-and-cover-letter/ Even if I add a redirect to the .htaccess to redirect it somewhere else, I still get the ***** 301 to http://www.easyjob.net/r/cover-letter/resume-and- cover-letter/ again. Anybody knows what's going on? PS this is the .htaccess:               AddHandler php5-script .php          # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress          #/RESUME/     Redirect        http://www.easyjob.net/resume/ http://www.easyjob.net/r/ [R=301,NC,L]


title: How do I programatically empty trash?

text: I need to create an "Empty Trash" button inside my plugin. How would I do it using PHP code?


title: WP Query - Post Thumbnail

text:
I am using the plugin: Series and by default it only gets the linked posts titles. I would like to add the post thumbnails as well. I was able to get the thumbnails to appear, but they show up outside of the widget. I added: the_post_thumbnail('thumbnail') parts. The full template is below. Thank you for the help!               /**      * Displays a list of posts by series ID.      *      * @since  0.1.0      * @param  array   $args      * @return string      */     function series_list_posts( $args = array() ) {              if ( empty( $args['series'] ) )             return;              $out     = '';         $post_id = 0;              if ( in_the_loop() )             $post_id = get_the_ID();              else if ( is_singular() )             $post_id = get_queried_object_id();              $defaults = array(             'series'         => '', // term slug             'order'          => 'ASC',             'orderby'        => 'date',             'posts_per_page' => -1,             'echo'           => true,         );              $args = wp_parse_args( $args, $defaults );              $loop = new WP_Query( $args );              if ( $loop->have_posts() ) {                  $out .= '
';                  while ( $loop->have_posts() ) {                      $loop->the_post();                      $out .= $post_id === get_the_ID() ? the_title( '
' . the_post_thumbnail('thumbnail') .  '
', false ) : the_title( '
' . the_post_thumbnail('thumbnail') . '', '
', false );             }                  $out .= '
';         }              wp_reset_postdata();              if ( false === $args['echo'] )             return $out;              echo $out;     }          /**      * Displays a list of posts related to the post by the first series.      *      * @since  0.1.0      * @param  array  $args      * @return string      */     function series_list_related( $args = array() ) {              $post_id = 0;              if ( in_the_loop() )             $post_id = get_the_ID();              else if ( is_singular() )             $post_id = get_queried_object_id();              if ( !empty( $post_id ) )             $series = get_the_terms( $post_id, 'series' );              if ( empty( $series ) )             return;              $series = reset( $series );              $args['series'] = $series->slug;              return series_list_posts( $args );     }          /* === DEPRECATED === */          /**      * @since      0.1.0      * @deprecated 0.2.0      */     function get_series_feed_link( $cat_id, $feed = '' ) {         _deprecated_function( __FUNCTION__, '0.2.0', 'get_term_feed_link' );         return get_term_feed_link( $term_id, 'series', $feed );     }          /**      * @since      0.1.0      * @deprecated 0.2.0      */     function is_series( $slug = false ) {         _deprecated_function( __FUNCTION__, '0.2.0', 'is_tax' );         return is_tax( 'series', $slug );     }          /**      * @since      0.1.0      * @deprecated 0.2.0      */     function in_series( $series, $_post = null ) {         _deprecated_function( __FUNCTION__, '0.2.0', 'has_term' );         return has_term( $series, 'series', $_post );     }          /**      * @since      0.1.0      * @deprecated 0.2.0      */     function create_series_taxonomy() {         _deprecated_function( __FUNCTION__, '0.2.0', '' );     }          /**      * @since      0.1.0      * @deprecated 0.2.0      */     function series_register_widgets() {         _deprecated_function( __FUNCTION__, '0.2.0', '' );     }


title: Change the Simple Facebook Connect popup position

text: **Is it possible to add a parameter to Simple Facebook Connect and the sfc_like_button function to cause the popup to fly out to the left?** Right now, it flies out to the right and is underneath the dark outer wrapper of my page. _(see below)_ This happens in Firefox, IE and Safari. Using `overflow:visible` in the containing `div` doesn't help. I've tried using positioning and z-index in that div and containing elements to position the popup on top of the wrapper with no luck. Is this a function of the output of the iFrame at Facebook that can't be changed? ![screenshot](http://i.stack.imgur.com/6HJUx.png) This is the function that includes SFC:               <?php sfc_like_button(array('width' => '125', 'height' => '20', 'layout' => 'button_count')); ?>      This is the resulting html in page source:               <fb:like href='http://mydomain.com/page/' send='false' layout='button_count' show_faces='true' width='125' height='20' action='like' colorscheme='light' font='lucida+grande'></fb:like>


title: get_term_children doesn't return an array of children terms

text: I am trying to get the term children and then check if they exist to display them. But I get no IDs in return of get_term_children command. This is the code:                 $children = get_term_children($term->term_id, locations);       echo $children;      $term is already defined and outputs well, "locations" taxonomy exists. The code returns me just an "Array" word, no list of child terms shows up. I've got a similar code in my post archive pages and it works well returning me child categories in n/n/n/n/n format:                 $children = get_category_children($this_category->cat_ID);       echo $children;      What's wrong with the first code? It should work as well as the second.


title: Featured Image Thumbnail size on Twenty Ten Archive Page

text: I have figured out how to get a thumbnail to appear on a twenty ten archive page but I cannot figure out how to resize it to say a size of "150px" by "150px". For example, on the following page the featured image is showing the full width of the post excerpt, I just want it 150px wide on the left hand side of the post excerpt and the large full size image to appear on the actual post page once you click and read the full post. See: http://www.westlimerickphysio.com/category/physiotherapynews/ I hope I am making myself clear. Regards, Noel.


title: Why are double-periods ("..") invalid in a Wordpress image filename?

text: `ms-files.php` contains the following code fragment:               $file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET[ 'file' ] );     if ( !is_file( $file ) ) {         status_header( 404 );         die( '404 — File not found.' );     }      This code determines whether or not the file can be found. However, it does something that I find... Odd. It removes all double-periods ("..") from the string. Normally, this doesn't matter, but we've had users upload files with two periods in a row (sigh), causing this portion of the code to incorrectly report code 404 (not found). I'm tempted to remove the strange double-period-removing nature of this code, but I fear that I'll inadvertently break something else. Why is this functionality present as it is coded? Thanks! :) Edit: To be clear, it would appear that double-periods are NOT invalid in Wordpress, but they can't be served up by this bit of code... So, they're not invalid, but when accessed via this mechanism, 404 is incorrectly reported.


title: ignore_sticky_posts not working with word press version 3.9.1

text:
I am trying to display a sticky post by its category id. The sticky post is displayed, but the problem is that the published sticky post is displayed twice. You can see from the snap shot below that the same sticky post is displayed twice (it is highlighted with the blue arrow). I don't want to display the sticky title news in the sub tittle of sticky news. You can see in bellow snap. These are same news the first arrow is sticky I have set from backend and second arrow is the same news displaying bellow the sticky see here I don’t want display second arrow news its twice here I wanted to display another news except the second arrow News. ![sticky](http://i.stack.imgur.com/pnb6B.png) Bellow is the code to set sticky from widget post
     <?php           $args = array(                 'category_name' => 'maharashtra',                 'post__in' => get_option( 'sticky_posts' ),                 'showposts' => '1',                  );          $the_query = new WP_Query( $args );              while ($the_query -> have_posts()) : $the_query -> the_post(); ?>

<a title="<?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail(array(342,173), array ('class' => 'alignleft1')); ?>

<a title="<?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?>

           <?php          endwhile;          ?>
      Bellow is the my sample code to display the recent post.

महाराष्ट्र
     <?php      $recent = new WP_Query("cat=255&showposts=6&ignore_sticky_posts=1");           ?>
     <?php              while($recent->have_posts()) : $recent->the_post();      $postvariable++;          if ($postvariable == 1) {      ?>
[widget id="text-8"]
     <?php       } else { ?>

<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?>


title: Changed sub-site to its own domain trigger 302 redirects for all page links

text: Below, I'm calling the development site `mainsite.com` (containing the WPMS install) and the domain that will point to a Norwegian sub-site of `mainsite.com`, I call `launchsite.no`. A **Norwegian sub-site** is ready to be launched, and the client is ready to point `launchsite.no` to the Wordpress installation. I'm manually pointing `launchsite.no` to the correct IP address in HOSTS to make sure it's ready for the 'switch'. So it's not a migration question. The host has internally made an alias for `launchsite.no` to be the same directory where the WPMS install is.   * The site works perfectly when Domain is set to `mainsite.com` and Path is set to `/no/` (in wp-admin).   * Just pointing `launchsite.no` to the server IP gives me `mainsite.com` (main site, not Norwegian). (And `launchsite.no/wp-admin` doesn't work.)   * I changed the Domain to `launchsite.no` and the Path to `/` for the Norwegian site.   * This gives me `launchsite.no` (yay!) and if I hover on all links on the site, they are correct, like launchsite.com/om-oss (About Us page). But when I click them, all of them give 302 Moved Temporarily and I end up on `mainsite.com`! I'm having trouble debugging this. I have read these documents and these from the codex The Site URL and Home in the database are correct, and there are no relevant occurrences of `mainsite.com/no/`. I've tested out some URLs that work and some that don't, hoping that it will give a clue.   * `launchsite.no/wp-admin/` - OK (phew!)   * `launchsite.no/` - OK, Norwegian start page.   * `launchsite.no/om-oss` (page) - 302 redirect to `mainsite.com`!   * `launchsite.no/?pagename=om-oss` (same page) - OK!   * `launchsite.no/?page_id=18` (same page) - 302 redirect to `mainsite.com`. I have disabled the Rewrite and Yoast SEO plugins (since they are capable of doing 301 redirects), no difference. I have saved and flushed Wordpress' rewrite rules. The host will not help me with Wordpress, but just says WP Multisite works on their servers. So I would be very grateful for suggestions what causes this, where I should look. ## It seems that Wordpress' own permalink translation is broken after the "sub-site move". **UPDATE:** ## I think I've ruled out everything but an error in wp_rewrite. Is there a way to catch or log what Wordpress is rewriting the page Permalinks to? Is there a third value apart from siteroot and home that it uses, that I could check in the database? Here is my .htaccess (standard, from the multisite article on wordpress.com):               Options All -Indexes     DirectoryIndex index.php index.html index.htm          #make sure in development site is not found by search engines.     Header set X-Robots-Tag "noindex, nofollow"          # BEGIN WordPress     <IfModule mod_rewrite.c>     Options +FollowSymlinks     RewriteEngine On          RewriteBase /     RewriteRule ^index\.php$ - [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).*) $2 [L]     RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]     RewriteRule . index.php [L]          # END WordPress      And here's my wp-config:               $table_prefix = 'wp_';          /**     * WordPress Localized Language, defaults to English.     *     * Change this to localize WordPress. A corresponding MO file for the chosen     * language must be installed to wp-content/languages. For example, install     * de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German     * language support.     */     define('WPLANG', '');          /**     * For developers: WordPress debugging mode.     *     * Change this to true to enable the display of notices during development.     * It is strongly recommended that plugin and theme developers use WP_DEBUG     * in their development environments.     */     define('WP_DEBUG', false);     /* Multisite */     define( 'WP_ALLOW_MULTISITE', true );     define('MULTISITE', true);     define('SUBDOMAIN_INSTALL', false);     define('DOMAIN_CURRENT_SITE', 'mainsite.com');     define('PATH_CURRENT_SITE', '/');     define('SITE_ID_CURRENT_SITE', 1);     define('BLOG_ID_CURRENT_SITE', 1);     define('WP_POST_REVISIONS', true);     define( 'WP_AUTO_UPDATE_CORE', false );          /* That's all, stop editing! Happy blogging. */          /** Absolute path to the WordPress directory. */     if ( !defined('ABSPATH') )     define('ABSPATH', dirname(__FILE__) . '/');          /** Sets up WordPress vars and included files. */     require_once(ABSPATH . 'wp-settings.php');


title: Counting the posts of a loop (WP_Query)?

text:
I tried this way to display NO of post:               <?php       $news_2 = new WP_Query( array ('post_type'=> 'jobs','posts_per_page'=> '10' , 'meta_key' => 'status_for_jobs','meta_value' => '1') );       if ( $news_2->have_posts() ) { while ( $news_2->have_posts() ) { $news_2->the_post();            $count = $news_2->post_count;            ?>

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

                        <?php } } ?> <?php wp_reset_query(); ?>       if the NO of post = 0 i need to display this :-               <?php       $news_2 = new WP_Query( array ('post_type'=> 'jobs','posts_per_page'=> '10' , 'meta_key' => 'status_for_jobs','meta_value' => '1') );       if ( $news_2->have_posts() ) { while ( $news_2->have_posts() ) { $news_2->the_post();            $count = $news_2->post_count;            if ($count  == '0') {            ?>

No Post

            <?php       } else {       ?>

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

          <?php  }  ?>              <?php } } ?> <?php wp_reset_query(); ?>       But instead of the total of posts, I not getting any thing. Any suggestions to fix this?


title: Permalink for custom post type

text: I have created a custom post type called job. Posts are generated with wp_insert_post(), and that works perfectly fine. My problem is that the permalinks to those posts are either wrong or I have done something wrong myself. Basicaly the post heads to this url : http://myblog.eu/job/1-adjointe- de-direction-ee/ and it will display only if I go to http://myblog.eu/?job=1-adjointe-de-direction-ee/. Id like each post to be generated with the right permalink. Here is a random post array :               [9] => stdClass Object             (                 [ID] => 42                 [post_author] => 1                 [post_date] => 2014-03-02 16:40:23                 [post_date_gmt] => 2014-03-02 15:40:23                 [post_content] => [reso_job_post id=8]                 [post_title] => adjoint(e) de direction, La Ciotat                 [post_excerpt] =>                  [post_status] => publish                 [comment_status] => closed                 [ping_status] => open                 [post_password] =>                  [post_name] => 8-adjointe-de-direction-la-ciotat                 [to_ping] =>                  [pinged] =>                  [post_modified] => 2014-03-02 16:40:23                 [post_modified_gmt] => 2014-03-02 15:40:23                 [post_content_filtered] =>                  [post_parent] => 0                 [guid] => http://myblog.eu/job/8-adjointe-de-direction-la-ciotat/                 [menu_order] => 0                 [post_type] => job                 [post_mime_type] =>                  [comment_count] => 0             )      and here is the code I use to generate posts all variables are set right (as you can see above) :               $new_job_post = array(                             'post_content' => $job_post_shortcode,                             'post_title' => $job_post_title,                             'post_status' => 'publish',                             'comment_status' => 'closed',                             'ping_status' => 'open',                             'post_name' => $job_post_slug,                             'post_type' => 'job',                             'comment_count' => '0'                              );                     wp_insert_post( $new_job_post );      Here is the code I use to create the custom post type :               function job_custom_init() {       $labels = array(         'name'               => 'Jobs',         'singular_name'      => 'Job',         'add_new'            => 'Add New',         'add_new_item'       => 'Add New Book',         'edit_item'          => 'Edit Job',         'new_item'           => 'New Job',         'all_items'          => 'All Jobs',         'view_item'          => 'View Job',         'search_items'       => 'Search Jobs',         'not_found'          => 'No jobs found',         'not_found_in_trash' => 'No jobs found in Trash',         'parent_item_colon'  => '',         'menu_name'          => 'Jobs'       );            $args = array(         'labels'             => $labels,         'public'             => true,         'publicly_queryable' => true,         'show_ui'            => true,         'show_in_menu'       => true,         'query_var'          => true,         'rewrite'            => array( 'slug' => 'job' ),         'capability_type'    => 'post',         'has_archive'        => true,         'hierarchical'       => false,         'menu_position'      => 5,         'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt' ),         'taxonomies'         => array( 'category', 'post_tag' )       );            register_post_type( 'job', $args );     }     add_action( 'init', 'job_custom_init' );     function my_rewrite_flush() {         job_custom_init();         flush_rewrite_rules();     }     register_activation_hook( __FILE__, 'my_rewrite_flush' );      Thank you.


title: WooThemes PremiumNews Theme jQuery Conflict with WordPress 3.2

text: This morning I updated my wp, and after that few of the jquery of my site is not working. I am using woo themes premium newspaper theme. After the upgrade, the categories drop down menu(superfish menu) stopped working. I was using lightbox plugin for images, that stopped working. I deactivated all plugins and checked the theme, but still the superfish was not working, I updated the themes framework with latest, but still no effect. Can any one help me in this? My website URL is:http://webstutorial.com/ and the theme which I am using is this:http://demo.woothemes.com/?name=premiumnews


title: Join wp_users and wp_usermeta

text: I have a custom user meta named created_by, which is the ID of creator of this user. I want to create a view table like this for example:               ID   user_login  created_by           2    andi        admin      How to do this?


title: function triggered by "manage_users_custom_column" filter not working

text: I am trying to add a custom column un users.php but it stays empty. I have successfully added a column to the users admin page with this code in my theme's functions.php file:               function add_user_test_column( $columns ) {         $columns['test1'] = 'Test';         return $columns;     }      add_filter( 'manage_users_columns', 'add_user_test_column' );      I have tried to add something to the column with this code but the colum stays empty:               function add_test_column_data($v = '', $column_name, $user_id ) {         if( 'test1' == $column_name ) {             return 'test'.$column_name.$user_id;         }     }     add_filter( 'manage_users_custom_column', 'add_test_column_data', 10,3);      I can see that the function is firing because if I modify the return to an echo like this :               function add_test_column_data($v = '', $column_name, $user_id ) {         if( 'test1' == $column_name ) {             echo 'test'.$column_name.$user_id;         }     }      I can see the "test test test test test test" echo'd along the top of the user table.   As you can see, the variables passed into the function are not taken into account. I have also tried reducing the priority (3rd argument to the add_filter function) from 10 to 1, with no effect.      So my questions are:   Why is the return from this function not working?   Why are the variables passed into the function not taken into account?   Where should I look to debug this?   I should add that this is not a vanilla install. I have taken over a complex site on wordpress 3.4.2 with lots of extensions and > 100 000 users. (and I have never used Wordpress before... ). Thanks in advance for your suggestions. Keith


title: One login for 2 websites on different platforms

text: I have 2 websites, 1 in core PHP where users are already logged in. I have a tab which name is 'post'. When the user click on 'post', it link to website 2 which is wordpress site. I want a user automatically logged in and show his post. Any suggestions how to do it.


title: Get Number of total Parent Categories for Custom Taxonomy

text: I am running an artist feature blog where I do interview artists from different countries and post some travel stuff from different countries. I've set up a Custom Taxonomy called "Artist Name". This is only used on Interviews. The parent categories are different countries (Germany, US, France, China etc.), the child categories are cities. I use categories on all posts (interviews AND travel stuff). I made a statistics page template where I want to show the total number of countries where my interviewes are from. In addition I want to show the total number of countries where I've traveled to. 1) Is it possible to get the total number of all PARENT catagories of posts that use that custom taxonomy? 2) Is it possible to get the total number of all PARENT catagories of posts that do NOT use that custom taxonomy (e.g. when Artist Name is blank)? I already tried to use some code snippets I found including count(get_categories('parent=0&hide_empty=0') but I am not that good in PHP to figure it out.


title: How to force Wordpress to temporarily switch locale (using qTranslate)?

text: I have a multi-language store running WooCommerce and qTranslate, and am trying to setup multi-language customer emails. The problem is, the "order complete" email gets sent from the admin backend, and it is sent in the language the backend is used in, not in the language that the order was initially made in. What I've got working so far is storing the order locale as a custom field, and plugging my code into WooCommerce's email sending mechanism. What I need to do now is to dynamically switch the current locale to the one saved in the order data, dispatch the email, and switch it back. Currently, I'm trying to force locale in a multitude of places, but none of them work. Here's the current code:               // get order language and its locale from qTranslate config     $order_custom_data = get_post_custom($order_id);     $new_locale = $order_custom_data['Customer Locale'][0];          // save current locale     $old_locale = get_locale();          // set the current locale and send email with it active     setlocale(LC_ALL, $new_locale);     global $q_config, $locale;     $locale = $new_locale;     $q_config['language'] = substr($new_locale, 0, 2);     // dispatch email     global $wc_cle_wc_email;     $wc_cle_wc_email->customer_processing_order($order_id);          // set the old locale back     $q_config['language'] = substr($old_locale, 0, 2);     $locale = $old_locale;     setlocale(LC_ALL, $old_locale);      Debug output shows the current and order locales being read correctly, and a `get_locale()` call parallel to `customer_processing_order()` outputs the order locale instead of the current one. But the email generated by the `customer_processing_order()` call is built with the current language strings instead of those in the order language. Any ideas how to work around this?


title: How grab first two image attachments?

text:
I am grabbing an image that is uploaded to that post working with this function: wp_get_attachment_image_src               <?php          $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 2 ) );         if ( $images ) :                 $total_images = count( $images );                 $image = array_shift( $images );                 $image_img_tag = wp_get_attachment_image_src( $image->ID, 'full' );                      ?>
             <img src="<?php echo $image_img_tag[0] ?>">
      How do I grab the first two images that are uploaded to a post? I guess I need help with a foreach statement.. and limit it to two. I tried this but it just printed the same first image over and over..               <?php foreach ($image as $images) {               echo "";     } ?>      IF I echo `$total_images` then I get the correct count of 2 Thanks for any help! Here is the paste of the page