Bootstrap Nav Menu not showing more than 1 dropdown

I have this code to show my navigation menu in the `functions.php` file.               class BootstrapNavMenuWalker extends Walker_Nav_Menu {               function start_lvl( &$output, $depth = 0, $args = array() ) {                   $indent = str_repeat( "\t", $depth );         $submenu = ($depth > 0) ? ' sub-menu' : '';         $output    .= "\n$indent
\n";          }          function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {                   $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';              $li_attributes = '';         $class_names = $value = '';              $classes = empty( $item->classes ) ? array() : (array) $item->classes;              // managing divider: add divider class to an element to get a divider before it.         $divider_class_position = array_search('divider', $classes);         if($divider_class_position !== false){             $output .= "

\n";             unset($classes[$divider_class_position]);         }              $classes[] = ($args->has_children) ? 'dropdown' : '';         $classes[] = ($item->current || $item->current_item_ancestor) ? 'active' : '';         $classes[] = 'menu-item-' . $item->ID;         if($depth && $args->has_children){             $classes[] = 'dropdown-submenu';         }                   $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );         $class_names = ' class="' . esc_attr( $class_names ) . '"';              $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );         $id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';              $output .= $indent . '
';              $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';         $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';         $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';         $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';         $attributes .= ($args->has_children)        ? ' class="dropdown-toggle" data-toggle="dropdown"' : '';              $item_output = $args->before;         $item_output .= '';         $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;         $item_output .= ($depth == 0 && $args->has_children) ? ' ' : '';         $item_output .= $args->after;                   $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );     }               function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {         //v($element);         if ( !$element )             return;              $id_field = $this->db_fields['id'];              //display this element         if ( is_array( $args[0] ) )             $args[0]['has_children'] = ! empty( $children_elements[$element->$id_field] );         else if ( is_object( $args[0] ) )             $args[0]->has_children = ! empty( $children_elements[$element->$id_field] );         $cb_args = array_merge( array(&$output, $element, $depth), $args);         call_user_func_array(array(&$this, 'start_el'), $cb_args);              $id = $element->$id_field;              // descend only when the depth is right and there are childrens for this element         if ( ($max_depth == 0 || $max_depth > $depth+1 ) && isset( $children_elements[$id]) ) {                  foreach( $children_elements[ $id ] as $child ){                      if ( !isset($newlevel) ) {                     $newlevel = true;                     //start the child delimiter                     $cb_args = array_merge( array(&$output, $depth), $args);                     call_user_func_array(array(&$this, 'start_lvl'), $cb_args);                 }                 $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output );             }             unset( $children_elements[ $id ] );         }              if ( isset($newlevel) && $newlevel ){             //end the child delimiter             $cb_args = array_merge( array(&$output, $depth), $args);             call_user_func_array(array(&$this, 'end_lvl'), $cb_args);         }              //end this element         $cb_args = array_merge( array(&$output, $element, $depth), $args);         call_user_func_array(array(&$this, 'end_el'), $cb_args);          }          }          register_nav_menus( array(     'primary' => __( 'Primary Menu', 'infi'),     'secondary' => __( 'Secondary Menu', 'infi' ),      ) );      And I used this code to show my navigation in the `header.php` file.                <?php                 $args = array(                     'theme_location' => 'primary',                     'depth'      => 0,                     'container'  => false,                     'menu_class'     => 'nav navbar-nav',                     'walker'     => new BootstrapNavMenuWalker()                 );                 wp_nav_menu($args);             ?>      But the menu is showing multilevels. Only a single dropdown is visible. If I add more than one dropdown items in the navigation, it simply doesn't show up. Any help please.


Saving category as insert post

I'm having a problem with `$_POST` a category. I got something like that :                   // ADD THE FORM INPUT TO $new_post ARRAY     $new_post = array(     'post_title'    =>  $title,     'post_content'  =>  $description,     'post_category' =>  array($_POST['cat']),   // Usable for custom taxonomies too     'tags_input'    =>  array($tags),     'post_status'   =>  'draft',           // Choose: publish, preview, future, draft, etc.     'post_type' =>  'post'  //'post',page' or use a custom post type if you want to     );      And the code about taking category:                        <fieldset class="category">         Type:         <select name="cat" id="categories">         <?php      $categories = get_categories('tab_index=10&taxonomy=category&orderby=name&hide_empty=0&include=6,7,8,9,10');     foreach ($categories as $category) {     $option = '<option name ="'.$category->category_nicename.'" value="'.$category->category_nicename.'">';     $option .= $category->cat_name;     $option .= '</option>';     echo $option;     }       ?>      </select>     </fieldset>      However, It doesn't work If I use `wp dropdown categories` this works, but I need to have a `name` for the options. `wp dropdown categories` doesn't provide the names itself. Is there anyone who knows what Am I missing here ? Edited * So after all It was simple enough to make it like that                     <fieldset class="category">         Type:         <select name="cat" id="categories">         <?php      $categories = get_categories('tab_index=10&taxonomy=category&orderby=name&hide_empty=0&include=6,7,8,9,10');     foreach ($categories as $category) {     $option = '<option name ="'.$category->category_nicename.'" value="'.$category->term_id.'">';     $option .= $category->cat_name;     $option .= '</option>';     echo $option;     }       ?>      </select>     </fieldset>


Events plugin for theater (event = performance of a production)

all event plugins I tried had the logic that an event has all information attached to it in a post-type. I have the case where I want to have events which are just performance date/time of a theater production. So I want one page describing the production and then a list of events / calendar to show the performances. As the performances can occur on different times on different days, the event plugin functionalities for recurring events do not fit (they all only support same time on different days). What are your suggestions to modeling this case? I guess its actually quite simple, but I can't get it. Thanks! Chris


Multi row post list

I'm trying to create a 'two posts per row grid'. Here is the template i made:

         <?php get_sidebar(); ?>

             <?php query_posts('category_name=portfolio&posts_per_page=100');  $do_not_duplicate = $post->ID;?>                       <?php if (have_posts()) : while (have_posts()) : the_post();       if (in_array($post->ID, $do_not_duplicate)) continue;      ?>                  <?php the_content(); ?>                  <?php endwhile; else: ?>
<?php _e('Sorry, this page does not exist.'); ?>
             <?php endif; ?>

             <?php query_posts('category_name=portfolio&posts_per_page=100');  $do_not_duplicate = $post->ID;?>              <?php if (have_posts()) : while (have_posts()) : the_post();       if (in_array($post->ID, $do_not_duplicate)) continue;      ?>                  <?php the_content(); ?>                  <?php endwhile; else: ?>
<?php _e('Sorry, this page does not exist.'); ?>
             <?php endif; ?>
      Something is wrong, cause all posts are visible in both divs, how do I tell wordpress to only add odd posts to the first div and even posts to the second?


Where to hook settings api init

I am getting a bunch of notices in Theme-Checker for my settings api init function. The notices are all for 'undefined index' in the $_REQUEST array. Here is the code :               <?php          function typesetter_settings_api_init () {              if ($_REQUEST['update-settings']) {             typesetter_save_settings();         }         register_sections();              $current = $_REQUEST['tab'] ? $_REQUEST['tab'] : 'page';         $page = 'typesetter_options_'.$current;              $callback = 'typesetter_render_settings_field';         foreach ( typesetter_get_sections() as $section ) {             foreach ( typesetter_get_settings_fields($section) as $field ) {                 add_settings_field(                     $field['id'], // $id                     $field['title'], // $title                     $callback, // $callback                     $page, // $page                     $field['section'], // $section                     array(                         'id' => $field['id'],                         'type' => $field['type'],                         'choices' => $field['choices'],                         'desc' => $field['desc'],                         'class' => $field['class'],                         'std' => $field['std']                     )                 );                 // Register my setting so that $_POST handling is done                 register_setting($page, $field['id']);                  }         }          }// typesetter_settings_api_init()          ?>      I hook this into 'admin-init'. Am I doing something silly here? Do I hook it somewhere else? Should I just ignore the notices?


Posts2Posts, wp_query and orderby issue

I've been working on this issue for several hours now and I'm stumped. The following query refuses to accept any orderby directive. **NOTE:** This is running on a single-cpt.php page within the normal WP Loop:               <?php $args = array(       'orderby' => 'title',           'order' => 'ASC',       'suppress_filters' => true,       'nopaging' => true,       'connected_type' => 'directory_to_projects',       'connected_items' => get_queried_object_id(),     );          $new_connected = new WP_Query($args);          // Display connected posts     if ( $new_connected->have_posts() ) { ?>
Projects

             <?php while ( $new_connected->have_posts() ) : $new_connected->the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
             <?php endwhile;              endif;             wp_reset_postdata(); ?>
     <?php } ?>      I've confirmed I'm not running any page- or post-ordering plugins that might interfere with 'orderby'. Switching 'orderby' to something else (name, date, meta_value, you name it) has no effect whatsoever. **UPDATE:** Actually, no parameters for wp_query are working at all. I tried adding `'posts_per_page' => 2,` and that had no effect either. Must be a posts2posts thing but I believe support for that plugin has been discontinued. :( Anyone ever run into this? Any ideas? Thanks so much for your help!


Custom login redirects to wp-admin on wrong password

My custom login form redirects to the wp-admin login when an user doesn't manage to guesses his/her credentials right. How can I manage to redirect the user to the current form instead? And of course show the proper errors? Here is the code: (same as on WordPress manual)               $args = array(             'echo' => true,             'redirect' => site_url( $_SERVER['REQUEST_URI'] ),              'form_id' => 'loginform',             'label_username' => __( 'Username' ),             'label_password' => __( 'Password' ),             'label_remember' => __( 'Remember Me' ),             'label_log_in' => __( 'Log In' ),             'id_username' => 'user_login',             'id_password' => 'user_pass',             'id_remember' => 'rememberme',             'id_submit' => 'wp-submit',             'remember' => true,             'value_username' => NULL,             'value_remember' => false );           wp_login_form( $args );


Different Name and Email for wp_mail_from and wp_mail_from_name

I want to make the email and Name dynamic.Everything works fine.But I can't able to get the name and email for each doctors.I have attached my code which I have tried.please help Thanks in Advance.               function send_email_status($patient_id , $doctor_id, $status, $dateTime)     {         //Getting User Details From Database         $from_email     =  get_user_meta($doctor_id,'user_email',true);         $to            =  get_user_meta($patient_id,'user_email',true);         $doctorName    =  get_user_meta($doctor_id,'display_name',true);         $patientName   =  get_user_meta($patient_id,'display_name',true);         $appdate       =  date('Y-m-d',strtotime($dateTime));         $appTime       =  date( 'g:i a', strtotime($dateTime));         $statusMsg    =  $this->column_status($status);         // Email subject and body text              $subject = 'Appointment Status PeoplesDoc.com';         $mailheaders .= "MIME-Version: 1.0\n";         $mailheaders .= "X-Priority: 1\n";         $mailheaders .= "Content-Type: text/html; charset=\"UTF-8\"\n";         $mailheaders .= "Content-Transfer-Encoding: 7bit\n\n";         function my_mail_from( $doctor_id ){             return get_user_meta($doctor_id,'user_email',true);              }         function my_mail_from_name( $doctor_id ){         return get_user_meta( $doctor_id ,'display_name',true);              }         //filter hooks for from Name and from Email         add_filter( 'wp_mail_from', 'my_mail_from' );         add_filter( 'wp_mail_from_name', 'my_mail_from_name' );         // Call to wordpress Mail Function         if( wp_mail( $to, $subject, $message, $mailheaders ) ) {             // the message was sent...             $flag =true;         } else {             // the message was not sent...             $flag = false;         }         return $flag;     }


What are the security reasons to disallow Microsoft Word uploads?

When I try uploading a .doc or .docx file I get this message: > Sorry, this file type is not permitted for security reasons What are the security risks involved in a multisite installation (3.9.1)? I know how to enable the feature. Thank you.


How to add wordpress pagination

i must use pagination. Where can i found good tutorial? ` $wpdb->get_results("SELECT * FROM wp_ogloszenia_kupione WHERE klient_id = $current_user->ID"); `


Change label of title field for posts in the backend

I am trying to add some HTML to the title label in the backend of WordPress. **Attempt 1:** I am using the following (simplified) function:               function change_post_titles() {         global $post, $title, $action, $current_screen;              $title = 'foo
bar';     }     add_action('admin_head', 'change_post_titles');      This works in the way that the label of the title field is indeed changed, however the HTML tags get encoded afterwards. This mean that the label looks like:               foo
bar      Instead of:               foo     bar      ![Encoded HTML](http://i.stack.imgur.com/z6bzh.png) **Attempt 2:** I also tried using a `gettext` filter, but that just completely filters (removes) the HTML.               add_filter('gettext', 'change_post_titles');     function change_post_titles( $translated_text, $text, $domain ) {         return $translated_text = 'foo
bar';     }      ![Removed HTML](http://i.stack.imgur.com/ZK8EQ.png) Is there any way to change the title label (programmatically) in a way I can add HTML?


Set variable in javascript and using in my shortcode

my script is               function($) {        var google_map_address = $('#address').text();     $(function () {     $('#gmap').gmap3({         marker: {             address: google_map_address          },         map: {             options: {                 zoom: 14             }         }     }); });})(jQuery);      and my php code is                   init_shortcode();         function init_shortcode() {         $shortcodes = array(         'gmap' => 'spyrowebs_gmap');         foreach( $shortcodes as $tag => $func )             add_shortcode( $tag, $func );         }           function spyrowebs_gmap( $atts = array(), $content = '' ) {         $defaults = array(             'address' =>'',           );         $atts = shortcode_atts( $defaults, $atts );         extract( $atts );         $address=$address;         return '

'.$address.'

';     }      but this does not work i want to create a shortcode like               [gmap address="your address"]      now what is the problem when i assign a value to javascript variable like               var google_map_address = 'your address';      then its work while in the above its not working please any help. when i put the above code in my theme its work but when i use it in my plugin its not work.


Allowing Users to Register Themselves and Post : Does WordPerss Handle these Problems?

If one allows visitors of a WordPress blog to register themselves and post to the blog without moderation(i.e. without submit for review), malicious visitors may try to 1)Post a large number of posts and fill up the server space 2)Post a few large posts and fill up the server space 3)Create a large number of drafts and fill up the server space 4)Post inappropriate content Does WordPress have mechanisms to prevent these? Or any plugins to do this? P.S: If you see any other problems I have missed please point them out as well. Thanks


On WP Multi sites how many sites...!

He I'm Hieu, I work as IT Engineer in An Thanh company Vietnam. We have 5 hosts (Shared host: Godaddy) with more that 60 sites each. On the moment all of this main sites (5) go down regularly with 500 errors. All on different times and duration and go from some minutes 5, 15 and more to some hours. We haven't found the problem yet and because we don't have much experience with WP and, specifically, Multisite, we need to ask some questions.   1. What is the maximum number of sites for a WP Multisite? What are the limits on the database?   2. This interruption that we have I'm sure that is happening before with some with your other customers can you help me to know what the reason is...! I hope you can help me on the right way Tran Trung Hieu IT AN THANH Vietnam


rewrite rule for home/index page

I've been struggling for a while already and all of my attempts failed so I have no other choice but to ask for help here... a) I've made a custom post type `page_blox` whose `capability_type => 'page'` and `rewrite => array( 'slug' => 'blox' )` b) All of `page_blox` pages can be selected on **Reading Settings** screen (Admin) as 'Front page displays' > Static page So far so good. However... **The problem:** Front-end home page URL doesn't read **my_domain.com** any more but also appends `post_type` and page slug so it looks like **my_domain.com?page_blox=my-page-slug** **The Question:** I believe it has something to do with WP's rewrite rules so how do I remove that appendix (`?page_blox=my-page-slug`) from home page URL? My initial code did not score any results. Is there anybody willing to tell what's wrong with it?               function k_rewrite_rules( $wp_rewrite ) {         $frontPost = get_post( get_option( 'page_on_front' ) );         $wp_rewrite->rules = array( '^$' => $wp_rewrite->index . '?' . $frontPost->post_type . '=' . $frontPost->post_name ) + $wp_rewrite->rules;     }     add_action( 'generate_rewrite_rules', 'k_rewrite_rules' );


How to get viewed posts during an user session?

I want to track user activity on my blog by store viewed post id's in $_SESSION. So I wrote a plugin but wp call it twice. I get allways current post id and the id of the next post. This problem is also decribed here: http://shinephp.com/single-php-called-twice-how-to-stop/ I need an another solution without plugins or deactivating actions. Any ideas? Update: Sample               function handle_session(){          global $post;     // read session data     if(isset($_SESSION['mykey']) {     echo $_SESSION['mykey'];     }     // set session data     $_SESSION['mykey'] .= ','.$post->ID;          echo $_SESSION['mykey'];     } // end: handle_session          Output 1:      ''     Output 2:     ',1,2'      1 is the id of the current post and 2 of the next. Solution: Browser is sending a special header, so if it's header is sendet everything can be done but no session data have to be changend.               class Example{         private $prefetchRequest = false;              function __construct() {             add_action('init', array( $this, '_get_prefetch_header' ));             add_action('shutdown', array( $this, '_update_session' ), 9999);         }              function _get_prefetch_header(){                 if(isset($_SERVER['HTTP_X_MOZ']) && strripos('prefetch', $_SERVER['HTTP_X_MOZ'])!==false ){                     $this->prefetchRequest = true;                 }             }         function _update_session() {             if($this->prefetchRequest!==true) {                 $_SESSION['mykey'][] = $this->additional_session_data;              }         }        } // end: class Example


Register Taxonomy - What is `query_var`?

The Codex doesn't really explain it very well, what is it used for and how do I use it exactly?


How to joint develop a WP locally on two far away machines?

I was hoping someone can confirm to me, someone new to WP, how I can view a WP site created locally on 1 computer on another computer in a far away land. Basically my friend started developing a site on his MAC locally using MAMP and now wants me to continue working on it. He sent me a copy of his entire Htdocs folder, and thinks I should be able to see his work? wrong or right? What else is needed? I have installed XAMPP and have created a folder for his site in htdocs. I also created a database using MyPHPadmin and edited his wp-config to access this database. When i open the site It works, but I don't see any changes/posts etc. I can see all the themes he has downloaded and thats about it. I think, he needs to make a copy of his database to send me..is this right? Also, what is the easiest way for us to share back and forth locally hosted WP sites, so I can develop a site and send him to look at and vice versa..without the need for live hosting etc. remembering neither of us are particularly knowledgeable on matters!


arguments for comment_notification_text filter

From WP codex: > comment_moderation_text: applied to the body of the mail message before > sending email notifying the administrator of the need to moderate a new > comment. Filter function arguments: mail body text, comment ID. Nevertheless, when I put in my functions.php:               function x99($textMsg, $comId) {       if (is_null($comId)) {         return "empty";       } else {         return ($textMsg);       }     }     add_filter("comment_notification_text", "x99");      the notification message body is "empty". So comment ID is null. Why? How can I retrieve it?


Create attribute for woocommerce on plugin activation

I want to create attribute on plugin activation.By below code,i'm able to create attribute in database table `prefix_woocommerce_attribute_taxonomies` but these attributes are not showing (or listed ) under menu **Product -> Attributes**.               register_activation_hook( __FILE__, 'ravs_wpm_activate_plugin' );     function ravs_wpm_activate_plugin() {         global $wpdb;                   // attributes parameters         $wpm_attributes = array(             array(                 'label' => 'Quantity',                 'name' => 'qty',                 'type' => 'select',             ),             array(                 'label' => 'Paper',                 'name' => 'paper',                 'type' => 'select',             ),             array(                 'label' => 'Side',                 'name' => 'side',                 'type' => 'select',             )         );              //create default attributes         foreach ( $wpm_attributes as $attr ) {             $attribute = array(                 'attribute_label'   => $attr['label'],                 'attribute_name'    => $attr['name'],                 'attribute_type'    => $attr['type'],                 'attribute_orderby' => 'menu_order'             );                  $wpdb->insert( $wpdb->prefix . 'woocommerce_attribute_taxonomies', $attribute );         }              // //terms         // $wpm_terms = array(         //  array(         //   'label' => 'Single Side Price',         //   'slug' => 'single-side-price',         //  ),         //  array(         //   'label' => 'Double Side Price',         //   'slug' => 'double-side-price',         //  )         // );              // //insert default trems         // foreach ( $wpm_terms as $term ) {         //  wp_insert_term( $term['label'], 'pa_size', array( 'slug' => $term['slug'] ) );         // }     }      **Updated:** I found answer. Actually woocommerce set attribute list in a transient,so you have to delete transient on every modification related to attribute( edit, add, update).               delete_transient( 'wc_attribute_taxonomies' );


How do I echo saved data outside the function?

I know the data I want is stored as _$lineOne_ and I can _echo_ that inside the function. But I want to get the data outside of the function. I've tired:               $lineOne;      $instance['lineOne'];      Here's the code where I want to insert `$lineOne` (line 11) and the widget where the variable is loaded/saved: http://pastie.org/7142717


WordPress Hook for user register

how can I tell WordPress, that if a user registers, it shall execute my function?


How do I replace the e-mail form to functional e-mail subscription?

In `front-page.php` I have an e-mail form prototype in HTML:               <input type="email" class="form-control" id="email" placeholder="Enter your e-mail address">     <button type="submit" class="btn btn-default">Get notified</button>      * * * Most Wordpress plugin I found is usually a subscription form in widget and send subscribers e-mail automatically when there's a new blog post. This isn't what I'm looking for. I'm looking for a system that allow visitor to enter their e-mail address and their e-mail address will be added in a file, something like CSV format, so I could use an e-mail program (or Wordpress) to send them e-mail when I need to. I'm not picky, just anything that would work. Is there any Wordpress plugin that help me to achieve this? Thanks!


Post navigation using date

On my site: www.finmand.dk/almastofa/nyheder (a danish site) I have used this code to navigate between the post:               <?php foreach(get_the_category() as $category)     { $thecat = $category->cat_ID; } ?>     <?php $result = "
";     $catposts = get_posts('category='.$thecat."&orderby=monthly=asc&numberposts=".$NUMBEROFPOSTS);     foreach($catposts as $single):         $result .= "
ID)."'>".$single->post_title."
";     endforeach;     $result .= "
";     echo $result; ?>      This right thing about the code is that it only shows on the News page /Nyheder. Problem is It only shows the newest post, and links to a page called sample- post. Which I don't have, so I get page not found. I would like it to link to page.php or single.php. But I can't figure out where to change it in the code. And I would like the navigation in the sidebar to be shown by Month and year posted. Not as now with name. But again - Beginner programmer with zero luck. So can anybody give me a hint on what to write? I know I may be playing with the big boys now regarding knowledge about "heavy" programming, and my problem may seem insignificant - but we all have to start somewhere. Hopeful Thanks Marlene


page not found in IE, but found in Chrome & Firefox

I use .html on PAGES plugin, and this works fine for me in Chrome and Firefox. However, Internet Explorer displays "page cannot be found". Why would one browser not display a page, but two others find it? Problem pages are:   * http://tech.doig.com.au/testimonials.html   * http://tech.doig.com.au/portfolio.html


How to add multiple buttons to TinyMCE?

I've followed a tutorial on Nettuts on how to add a custom button to TinyMCE (http://net.tutsplus.com/tutorials/wordpress/wordpress-shortcodes-the-right- way/) It works great and all, but i want to add many buttons and i wonder if there's a smart way to do this without having to duplicate all the code over and over. Here's the code i use for adding a button:               add_shortcode("quote", "quote");       function quote( $atts, $content = null ) {           return '
"'.$content.'"
';       }          add_action('init', 'add_button');       function add_button() {          if ( current_user_can('edit_posts') &&  current_user_can('edit_pages') )          {            add_filter('mce_external_plugins', 'add_plugin');            add_filter('mce_buttons_3', 'register_button');          }       }       function register_button($buttons) {          array_push($buttons, "quote");          return $buttons;       }       function add_plugin($plugin_array) {          $plugin_array['quote'] = get_bloginfo('template_url').'/js/customcodes.js';          return $plugin_array;       }      And then i create a customcodes.js file with this code in:               (function() {           tinymce.create('tinymce.plugins.quote', {               init : function(ed, url) {                   ed.addButton('quote', {                       title : 'Add a Quote',                       image : url+'/image.png',                       onclick : function() {                            ed.selection.setContent('[quote]' + ed.selection.getContent() + '[/quote]');                            }                   });               },               createControl : function(n, cm) {                   return null;               },           });           tinymce.PluginManager.add('quote', tinymce.plugins.quote);       })();      So again, how can i add multiple buttons without having to do all this code for each new button? Thanks :) Sebastian


separate categories with comma and srounded by single quote

hello and sorry for yet another beginner question i am extracting wordpress categories form the array but i want them to be separated by comma my code is               <?php     $args=array(     'child_of' => 79     );     $categories=get_categories($args);     foreach($categories as $category) {      echo $category->cat_id;     ?>      this will return some thing like 11223344556677 but i want the result like '11,22,33,44,55,66,77' thank you for your help


Automaticly add slug to posts

I'm using a us/news/%postname%/ structure for my permalinks. This works great for regular posts. However, I have a few different custom post types, and I don't want the us/news part in their slug. How do I have it both ways?


How to show custom field's value under post/page title in wp-admin

I'm trying to add the value of a custom field under the post/page title in wp- admin list of posts/pages (much like excerpt mode in posts list) without hooking into the columns process since other plugins are already doing that and it looks like each cancels the other. Here's a screenshot of what I'm trying to achieve: ![screenshot of pages list](http://i.stack.imgur.com/kToA2.png) Thanks!


wp_pagenavi function parameters

I've been searching all around the web for the API of the wp_pagenavi plugin, but seems that I can't find one. I just want to know: In examples that I found, the wp_pagenavi function has from 0 to 3 parameters. What are those parameters and what do they change? Also, what I've been meaning to do is, with WPML, translate my Page 1 of 5 in french (Page 1 de 5). Will these parameters help me translate that sentence, or is there another parameter/option to find to translate that. By the way, with WPML I can call different functions for different languages, so if it needs a parameter to change the language of the "Page 1 to 5" sentence, I'll be ok.


How to display products name in a non-alphabetical order, in a custom field (taxonomy)?

Now the order is: **apples, oranges, pears**.   But I want to be in a random order, for ex: **oranges, apples, pears**.   Or to write them in a order that I want. Is this possible? Taxonomy is like that:                       'fruits' => array(             'post-types' => array('products'),             'name' => 'Fruits',             'slug' => 'fruits',             'type' => 'tags' ),


adding meta data using plugin to top of head

It seems if you use the wp_head hook as an action to put your custom metadata into the head tags of your page, it is dependent on where the theme you are using calls the wp_head. In my case, it is at the end of the head tags. How can I force my meta data near the top of the head tags? I have a header.php file I'm calling in using a self-made plugin. I know how to write the function code to call the header.php. I just need to know how to hook it to the start of the head tags. Thanks, Derek


Wordpress Hide Show Content script and activate/deactivate script on screensize

I am currently using jquery.expander.js to hide/show paragraph content. I want to only use this for screen sizes less than 500px width and less (for mobile phones) ONLY. I am working in wordpress 3.5 and genesis theme 1.9.1 My questions:   * Is there a good script proven and tested to load jquery.expander.js only on screen sizes 500px width and less. *The most important part is for desktop viewers if they reduce the screen size to 500px or less width it loads the jquery.expander.js and if they expand larger than 500px width it stops/kills the jquery.expander.js, again the reason being I just want to activate hide/show on a mobile device or desktop view that is 500px or less width.   * The Wordpress question is: When one of our marketers adds content to a page they will do this in the entry content window for that page, how can I edit my php so that it will somehow place a div of around the entry content. Sample code below for div and class name it needs for the script to work. `<div class="expander">` `<h1>Welcome and Thanks</h1>` `
Aliquam aliquet, est a ullamcorper condimentum, tellus nulla fringilla elit, a iaculis nulla turpis sed wisi. Fusce volutpat. Etiam sodales ante id nunc. Proin ornare dignissim lacus. Nunc porttitor nunc a sem. Sed sollicitudin velit eu magna. Aliquam erat volutpat. Vivamus ornare est non wisi. Proin vel quam. Vivamus egestas. Nunc tempor diam vehicula mauris. Nullam sapien eros, facilisis vel, eleifend non, auctor dapibus, pede.
` `
` *If I have not followed the forum rules let me know and I will adjust


Wordpress is rewrite my htacces file. I adding a font rule

I used webfonts in my Wordpress site. I need a rewriterule in my htacces. I put this in my htacces file:               RewriteRule ^fonts/(.*) /mikevierwind/wp-content/themes/roots/fonts/$1 [QSA,L]      But when i save this htacces file. Wordpress is rewriting the htacces file and my fonts rewriterule is gone. How can i fix that? Thank for helping!


trying to figure out how to use more that one image upload in the same section in theme customizer

i am trying to figure out how to use more that one image upload **in the same section** in **theme customizer**. the function is `new WP_Customize_Image_Control`. when you try to get the path of the image you have uploaded it will give you only from the first WP_Customize_Image_Control you have created. the others just not working. this is the code:               $wp_customize->add_section(         'head_section',         array(             'title' => 'Head',             'description' => 'head section.',             'priority' => 55,         )     );          $wp_customize->add_setting( 'img-upload' );          $wp_customize->add_control(         new WP_Customize_Image_Control(             $wp_customize,             'first-img-upload',             array(                 'label' => 'first image Upload',                 'section' => 'head_section',                 'settings' => 'img-upload'             )         )     );          $wp_customize->add_setting( 'img-upload' );          $wp_customize->add_control(         new WP_Customize_Image_Control(             $wp_customize,             'second-img-upload',             array(                 'label' => 'second image Upload',                 'section' => 'head_section',                 'settings' => 'img-upload'             )         )     );      then i try to get the link to the image by using               $first_image = get_theme_mod('first-img-upload');     $second_image = get_theme_mod('second-img-upload');     echo $first_image;     echo $second_image;      from here i just get the first link but the secend is empty. thanks for help.


Difference Between Admin and Super Admin in Database

I was looking at the user table and noticed for a super admin ( have access to network admin panel ) and an admin to a network site have same `wp_capabilities` which is `a:1:{s:13:"administrator";b:1;}` and also the `wp_user_level` is `10` for both. So, I was wondering **what is the database value that differentiate between a super admin and an admin?** I don't see any more usermeta that relates to network admin level. What is the proper way to assign super admin capability to a admin via:   1. Database Edit.   2. Via Code.


Show or hide custom menu widget in side bar conditionally

I have been trying and searching to accomplish this. I have the "custom menu" widgets "Members Area", "Admin Area" in side bar, assigned menus to them. Fine, they display. I want to show "Admin Area" widget only when the current user is admin. I believe it has something to do with adding a filter to "sidebars_widgets". Honestly, i do not have a clue to target the "Admin Area" widget. How do I handle this ?


How to close open divs in post loop

I want to add some additional HTML markup to specific posts in a loop. For example in the post loop, I want to wrap the post 3, 4, 5 in two divs `.extra` and `.extra2` I want to display post in following order: Post 1, 3, 4, 5, 2 I am trying following:               <?php if ($query ->current_post == 0) { ?>
 Post # 1
     <?php } ?>     <?php if ($query ->current_post == 2) { ?>

     <?php } ?>       <?php if ($query ->current_post >= 2) { ?>
 Post # 3

 Post # 4

 Post # 5
      <?php } ?>      <?php if ($query ->current_post == 1) { ?>
 Post # 2
      <?php } ?>      Now I'm unable to figure out how to close the div `extra` and `extra2` after the post #5 and before the post #2. The number of posts are variable in the loop. If this method is not correct, please let me know how can I add additional markup for specific posts in the lop. Thanks.


Display site admin profile fields in header.php

I am working on a multisite setup and Im trying to display some meta from the site owner's profile. I tried the following code but it is echoing the super admin's meta instead of the current site admin --                <?php $user_id_from_email = get_user_id_from_string( get_blog_option(get_current_blog_id(), 'admin_email'));          $current_site_admin = get_userdata($user_id_from_email);          $twitt = (get_user_meta($current_site_admin, 'twitter', true)); ?>     <?php echo $twitt; ?>      Since there will be a lot of sites on the network and only one admin, im trying to retrieve this information dynamically. Any ideas on how to fix this? Thanks


Outputting posts from post id´s in variable

I have a variable containing some post ID´s. I´d like to output the posts in that variable using the standard wordpress loop. How can I do that? Thanks! Added:               <?php      /*     Template Name: Favorites page     */          $favorites = wpfp_get_users_favorites($user = '');     $favorites_query = new WP_Query('post__in' => $favorites);          get_header();     get_sidebar();      ?>
     <?php get_template_part( 'menu' );          if(!$favorites) {     echo '
'; echo _e('Du har ingen favoritter', 'deals');      echo '
';     }          if($favorites) {     echo '
'; echo _e('Dette er dine favoritttilbud denne  uka. Favorittene dine vil kún være være tilgjengelig i denne nettleseren på denne maskinen.', 'deals');      echo '
';     }          while ($favorites_query->have_posts()) : $favorites_query->the_post();      $start = get_post_meta($post->ID, '5Start', true);     $stop = get_post_meta($post->ID, '6Slutt', true);           echo print_offer($post_id, $start, $stop);     endwhile;          if($favorites) {     echo '
';     wpfp_clear_list_link();     echo '
';     } ?>
           <?php      get_template_part( 'rightsidebar' );     get_footer();      ?>


Forcing frontend login with UI switch

Is there a way to force log-in even for _viewing_ a WordPress blog that the blog's owner can turn on and off by themselves? I can hardcode it in the template's `header.php` like so:               if ( !is_user_logged_in() ) {        wp_redirect( wp_login_url() );        exit;     }      but this can't be influenced from the blog's administration page. There is the force user login plugin, but it doesn't work in 3.x blogs. I'll try to patch the plugin for 3.x, but suggestions for other (native?) methods are welcome.


Remove toolbar option (and set to default to no) in user profile

I don't want users to be able to choose to display the admin bar/toolbar when they log into wordpress. It doesn't have a function for those users. Instead I would like for admin users to have the toolbar shown by default and anyone else to have the toolbar hidden by default. I can do this with a plugin by using css and all sorts to hide the toolbar and the option in the profile, however I was wondering if there was a "proper" way to do this at all? Thanks


Passing Custom Field Data as Array to be Saved (Resulting Custom Field Array is inconsistent)

I've been staring at this for hours, and it's clear I'm missing something, but I don't know what it can be... I have custom meta box for adding downloads to a particular post or page. All the data is save into one custom field key as an array. For each "download" we enter 3 pieces of info: resource name (input=text), resource link(input=text), and resource type (select list of like pdf,zip file, video, etc). The problem is when I save the data, it gets rearranged somehow, the order the data gets saved in and the resulting custom field array after the save is not consistent. And while saving, if I watch my log, data seems to be inserted randomly into the array for this custom field key. Here's the function which saves the data: http://pastebin.com/TY6LFuiL The specific section is question starts just below this comment: // If passed along is an array, we should remove all previous data Here's the bit that outputs the options: http://pastebin.com/EGF4dibZ - This is where things are getting messed up because, the order the data is saved and the order of the data in the resulting array for the custom field key is not consistent. For example, if I save the options as:               input 1(text): Resource Name 1 - wsm-content-downloads[]          input 2(text): http://link.com/1.pdf - wsm-content-downloads[]          input 3(select): PDF - wsm-content-downloads[]      The array looks like this BEFORE being saved:               Array     (         [0] => Resource Name 1         [1] => http://link.com/1.pdf         [2] => PDF     )      Then the function that saves the data, goes through and for each value of this array, saves it as custom field data for the same key (wsm-content-downloads) - which results in an array after saving:               Array     (         [0] => http://link.com/1.pdf         [1] => Resource Name 1         [2] => PDF     )      Here's a more detailed log:               http://pastebin.com/cdDsN5Sk      (had to code sample that last link because of limit on links) I print out the custom field data as an array after each save/update in the loop. You can see how the data is saved is not consistent at all... sometimes the value being saved/updated goes at the beginning of the resulting custom field data array, sometimes at the end and sometimes even shoved right in the middle... I need the custom field data array for this key (wsm-content-downloads) to be identical to the array I pass to the save function after all is said and done, but for some reason, it's not coming out like that... And perhaps the worst part is, this code works perfectly on my local server - on my live server it's doing this... Thanks in advance... Cheers, Bryan


WordPress 3.8 Test unit Import error

I've just updated my WordPress to 3.8 and I'm currently using multisite installed locally. It's a fresh new install. So I tried to import the test unit data from the WordPress codex which gives me a lot of errors. Here's a screenshot: ![enter image description here](http://i.stack.imgur.com/FtbHp.png) Does anyone know why I'm getting these erors? Thanks.


How to generate a sitemap with custom posts (not Google XML)

I'm looking for a way to generate a sitemap for display on my site that includes my custom posts. I'm not looking for an xml sitemap generator for search engines -- that is sorted using Google XML Sitemaps and Get Up and Running's patch for that plugin. I'm specifically looking for something to display to users. Normally, I'd use Dagon's sitemap generator, but it does not support custom posts, and the author does not seem to be responding to queries. Any hacks/patches/code snippets/ideas?


Adding custom html and standard widgets to sidebar

I want to add both custom html that advanced text widgets can't support and the standard sidebar widgets in the same sidebar. However, when I put a sidebar widget into the theme, it removes all the custom html and just displays the widgets in the sidebar. It shouldn't be a tough fix, but I am pretty big php noob who learned wordpress by trial and error. I have attached the code from my sidebar:

Title goes here

Content goes here

Title goes here

Content goes here

      Thanks for any help


Problem to show custom post type in archive page category wise

I was facing problem to show custom post type post category wise. Then i found to solve the problem . i wrote below code in function page :               function my_blog_category( $query ) {     if ( is_post_type_archive( 'blog') && $query->is_main_query() ) {         $action =   (isset($_REQUEST['ac'])) ? $_REQUEST['ac'] : 'none';         if($action!='none') $query->set( 'category_name', $action );         }      }     add_action( 'pre_get_posts', 'my_blog_category' );      So when I click > local/wp/index.php/blog?ac=company-news it shows all company-new category's post. But main problem is that I upload all file to website server. Now filter is not working on my webserver. There I click > Mydomain/index.php/blog?ac=company-news it show all post, not filter by category. I don't why it not work on my live web server .


Disable creation of default content during installation

How can I disable or at least modify the default content inserted on a fresh wordpress install? For example to change the category from Uncategorised to News.


How to 301 private posts rather than 404?

How do I 301 redirect private pages, rather than 404 them? If a post is private, WordPress filters it out in the SQL query, so there are no $post variables to work with. I'd like for this code to work, but doesn't:               add_action('wp','redirect_stuffs', 0);     function redirect_stuffs(){     global $post;         if ( $post->post_status == "private" && !is_admin() ):             wp_redirect("http://dangayle.com/",301);             exit();         endif;     }      I don't know where that is set earlier than `wp`, other than the fact that I know it's a user role issue. If I could set a non-logged in user to have that capability, it would probably fix the issue:               $publicReader -> add_cap('read_private_posts');      The problem with add_cap is that only logged-in users have capabilities.


How can I get page slug

How can I get the slug of a page or post?


displaying tags in a widget

I have a widget which displays the latest projects as thumbnails on my website. When I mouse over a thumbnail the project title appears; this is the code for title: `<h2><?php echo get_the_title(); ?></h2>` So, I'm thinking to display also the tags from that specific project, to be something like beautiful, nature, landscape Is this possible, or could you give me some suggestions on how to achieve this ? Thanks!


Specific css on homepage, different one for other pages

Is there a way to have specific css on the homepage and use a different one for all the other pages?


Jetpack stats and caching strategy

I'm thinking about hosting a WordPress website with agressive caching/optimization strategies (like varnish, microcache, ngx_pagespeed, etc). But I still want Jetpack stats to work alright. What should I pay attention to? How does jetpack-stats count visits?   * tracking images?   * AJAX calls?   * internal WP hooks? Depending on its strategy, I'd probably have to tweak my cache configuration...


Ajax Validation for reCaptcha

# Background I have a **registration form** that validates with AJAX using jQuery Validation Engine. The form was created using Theme My Login and contains **reCaptcha** which I implemented using WP-reCAPTCHA. Just like the rest of the fields, I needed to **validate reCaptcha using AJAX** as well, that is, without refreshing the whole page. So far I managed to make it work when the Captcha didn't validate. But **when it did validate** , ie. the input was correct, the page refreshed but with an **error message** which says **'That reCAPTCHA response was incorrect'**. Thus, the form was not saved. I tried using `console.log()` to check the output and the result is 'valid'. So I can't really tell where I went wrong. Currently I'm testing this locally using _XAMPP_. # The Code That I Used **The Javascript:**               (function($){            // Validate Captcha       $.fn.validateCaptcha = function() {              challengeField = $('input#recaptcha_challenge_field').val();         responseField = $('input#recaptcha_response_field').val();              $.ajax({             type: 'POST',             url: the_ajax_script.ajaxurl,             data: 'action=validate_captcha&recaptcha_challenge_field=' + challengeField + '&recaptcha_response_field=' + responseField,             async: false,                  success:function(result)               {                 //console.log( result );                      if(result != 'Valid') {                        $('#captchaError').html('
The security code you entered did not match. Please try again.
');                   $captchaFlag = 'Invalid';                   Recaptcha.reload();                      } else {                        $('#memberInformation span').css({'color':'green'});                   $('#memberInformation span').html(html.message).show(3000);                   $('#captchaError').html('
Success!
');                   $captchaFlag = 'Valid';                   dataString = form.serializeArray();                   getSearchMembers(dataString);                      }               }           }).responseText;       }              $('#registerform').submit(function() {           var form = $(this);                if (form.validationEngine('validate')) {             $('#memberInformation span').html('');             form.validateCaptcha();           } else {             $('#memberInformation span').css('color','#ff0000').html('Please fill out required fields').show(3000);           }           return false;         });          })(jQuery);      **The PHP:**               function validate_Captha() {       $privatekey = "xxxxxxxxxx"; //


Code working just in specific time period

I have this code in my style.css               iframe[src*="http://www.youtube.com/"]     {width:480px !important; height:305px !important;padding-top: 20px;display:none}      as you can see, it makes youtube videos not to display. But I want to display videos in some time period (for example: from 2.00 AM to 2.00 PM). How to do it? I have a theory, but I am not good at codes, so I am not able to do it myself.:               <this code work in some time period>     iframe[src*="http://www.youtube.com/"]     {width:480px !important; height:305px !important;padding-top: 20px;display:none}     </end of code>          <this code work in some time period>     iframe[src*="http://www.youtube.com/"]     {width:480px !important; height:305px !important;padding-top: 20px;}     <end of code>      Can anybody help me? Thanks a lot! :)


Admin Ajax is returning 0

I am relatively new to jQuery and AJAX in particular. I have a small issue with the return value always being 0, though I think this is actually the success message and it's not returning anything. I have scoured the Google-verse and I have the die() function on the PHP callback and I believe the add_actions are correct. I am working on a local host, though I doubt that affects it and this is all in the admin, not front end. I also checked that the js is enqueued and localised. I get a 200 OK message in the chrome developer area. I also tested out the basic AJAX from http://codex.wordpress.org/AJAX_in_Plugins and it also returned 0, which makes me wonder if it is something other than the code outlined below. Right now I am just trying to make it send something back to the jQuery. Any help would be appreciated. **The jQuery**               jQuery(document).ready(function(){         jQuery('.cl_link_buttons').val('id').click(function() {                      var currentid = jQuery(this).attr('id');                      //alert(currentid);                 console.log(currentid);                      jQuery.ajax ( data = {                     action: 'cleanlinks_ajax_get_post_data',                     url: ajaxurl,                     type: 'POST',                     dataType: 'text',                     "currentid" : currentid                      });                      jQuery.post(ajaxurl, data, function(response) {                          var dataz = response;                     alert( dataz );                     console.log (dataz); //show json in console                           });                      return false;              }); //end click event     }); //end doc ready      **The PHP**               add_action("wp_ajax_cleanlinks_ajax_get_post_data", "cleanlinks_ajax_get_post_data");     add_action("wp_ajax_nopriv_cleanlinks_ajax_get_post_data", "cleanlinks_ajax_get_post_data");          function cleanlinks_ajax_get_post_data() {          $from_ajax =  $_POST['currentid'];          echo "do" . $from_ajax . "something";          die();               }


Internal linking when on a shared IP

I have a WP site in a temporary location, and the site URL is an IP address followed by slash, tilde and the short site name. I also have a number of internal links in the pages that assume linking from the root - `<a href="/services">` - for example. Now these links do not work in the testing environment because of the shared IP. Does anyone know what I can do to make my internal links work, no matter where the site lives? UPDATE: I'm trying to update links (and the SRC of uploaded images) in the page content, not in a template file. ANOTHER UPDATE: I think I'm going to just go the manual route and drop in absolute URLs. Thanks! jen


WooCommerce - results per page not working after page reload

What I wanted to achieve is to list some products on a custom page which belongs to two common categories. This part is working fine, except the results per page dropdown. When I change the dropdown values to 24/36/48, after page reload the number of products shown is the same as on the initial pageload. I have the following code:               $wp_query = new WP_Query(         array(             'post_type' => 'product',             'tax_query' => array(                 'relation' => 'AND',                     array(                         'taxonomy'  => 'product_cat',                         'field'     => 'slug',                         'terms'     => 'new-arrivals'                     ),                     array(                         'taxonomy'  => 'product_cat',                         'field'     => 'slug',                         'terms'     => 'earrings'                     )                 )         )     );     while ( $wp_query->have_posts() ) : $wp_query->the_post();     woocommerce_get_template( 'archive-product.php' );     endwhile;     wp_reset_postdata();     wp_link_pages(array('before' => '
Pages: ', 'after' => '
', 'next_or_number' => 'number'));      I would like to get some directions on how to customise the loop to meet also the results per page functionality. I know I am missing sending and getting the dropdown values, but have no clue (yet) on how to do it with best practice, without cruel PHP and JS. There must be some WooCommerce styled best practice. If my code can be customised or if I'm on a totally wrong way. If so, where I made the mistake? I thought this was will be the simple one, did not payed attention to the "posts per page" detail.


Add html plugin into wordpress

I purchased an HTML5 Video & Youtube background plugin, I want to use it with WordPress. http://codecanyon.net/item/html5-video-youtube-background/1555660 Any Suggestions? Maybe create a template, page,etc..?


Simple spam check for valid domain in commenter's email address

Many times commenters leave fabricated email addresses. As a really basic step, is there a plugin that checks to make sure that the domain actually exists?


Add a column before username in the users profile table

I want to reorder the Company column to be the first column in the table, the code is working fine but it's position is the last one. How can I get it to be in the first before the username?               function add_company_column($defaults) {         $defaults['company'] = __('Company');         return $defaults;     }          function view_company_column($value, $column_name, $id) {         if ($column_name == 'company') {             global $wpdb;             $companyID = get_usermeta($id, 'company');             $company = $wpdb->get_row("SELECT com_name FROM " . $wpdb->prefix . "companies WHERE com_id = " . $companyID);             return $company->com_name;         }     }          add_filter('manage_users_columns', 'add_company_column', 15, 1);     add_action('manage_users_custom_column', 'view_company_column', 15, 3);      Thanks


how to display json_encode via $wpdb

ive been struggling for quite a while how to make this work. i created a custom php, and used it as a **template page**. _[below code]_ i also ended up with this link `//localhost/site/?page_id=43` if i want to query an id, i just need to add `page_id=43&id=3` and it will display aa member name associated with the ID. whenenver i query an ID, i only get `{"result":[]}` on that page. can someone check my code please?               /*     Template Name: getID     */              global $wpdb;         if (isset($_GET['id']) === true && empty($_GET['id']) === false) {                   $query = $wpdb->get_results("SELECT * FROM `memberid` WHERE `memberid` = `$_GET['id']`");                 $array = array();                 while ($row = mysqli_fetch_array($query)) {             array_push($array, array('name' => $row [2]);            }                 echo json_encode(array("result" => $array));         }


php console log speed

How do I log speed benchmarks to a console in php? I don't want to `echo` the results for the user to see, but just in some kind of log. I know that I can get the time elapsed with this:               $first  = new DateTime( '11:35:20' );     $second = new DateTime( '12:00:45' );          $diff = $first->diff( $second );          echo $diff->format( '%H:%I:%S' ); // -> 00:25:25      but I want to log the time, and not `echo` it. Do I use the error_log?


Pass Query string to a 2nd Page Query

I am trying to pass a query string called postcode (zip code in the states) from one page to another. On the 2nd page I want to use postcode to filter some details of people to identify the person with the relevant postcode. My query string for example is - `/registration/?postcode = 2880` I know that on the following line of code - which is about line 25:               where tblcoordinator_id_contact_details.Postcode = postcode");      If I put in the actual value of the postcode i.e. `'2880'` it gives me the correct result.   If I put in the querystring name of postcode i.e. `'postcode'` it gives every person.   If I put in the function name of the postcode i.e. `$vars` it gives me no results.   So I am at a real loss simple process. But not wanting to do posts using a page and filtering. So the code that I am using on page 2 or the registration page is - (by the way I am using a short codeplugin - Shortcode exec PHP)               global $wpdb;     function add_query_vars_filter( $vars ){         $vars[] = "postcode";         return $vars;     }          add_filter( 'query_vars', 'add_query_vars_filter' );          $result = $wpdb->get_results( "SELECT tblcoordinator_id_contact_details.ID,          tblcoordinator_id_contact_details.Firstname,          tblcoordinator_id_contact_details.LastName,          tblcoordinator_id_contact_details.Fullname,          tblcoordinator_id_contact_details.Location,          tblcoordinator_id_contact_details.Street,          tblcoordinator_id_contact_details.Postal,          tblcoordinator_id_contact_details.Town,          tblcoordinator_id_contact_details.State,          tblcoordinator_id_contact_details.Postcode,          tblcoordinator_id_contact_details.Phone1,          tblcoordinator_id_contact_details.Phone2,          tblcoordinator_id_contact_details.Fax,          tblcoordinator_id_contact_details.Email         FROM tblcoordinator_id_contact_details         where tblcoordinator_id_contact_details.Postcode = postcode"     );     //echo "
"; print_r($result); echo "
";     echo "Firstname"."  "."LastName"."

";     foreach($result as $row)     {         echo $row->Firstname."  ".$row->LastName."
";     }      Thanks Peter


E-commerce-like solution

I've been asked to build a website that is basically like a web-store, but without the need to sell products, what I mean by this is, the client wants to keep track and let visitors know of his product's stock, be able to catalog the store's products and other store like features. We're talking heavy machinery here, so there's no interest in making the product available to buy right away as some products require customer specifications that are different for everyone, thus making online buying unpractical. What I came here for is, based on this, what do you recommend? I can use a template or a plugin, I would rather use free stuff even if they require more work because I didn't give a high price for the website, I want to use WordPress because I like it so much and I'm used to working with it, I doubt you'll point me in another direction since this is a WordPress answers Q&A, but I'm open to other platforms if you have well built arguments as to why it is better than WordPress. This is my first online store in this terms, I have worked with Magento, and for the type of shop this requires, I think it just isn't worth the trouble of going through a whole Magento web-store, what do you think? I'm looking into Woocommerce, it seems like the best option and its free and has translation files, that should be useful, do you recommend?


how or where wordress collect unlogged user session

i see the pattern in some theme where we can collect session of unlogged user. for example, in a comment form: After user commenting, user can see that the their comment is waiting for a moderation. i want to know in what hook (the file, the class, or the functions) we can collect the information. fyi i'm need this information to extaned theme capability to handle unlogged user. For example show them 'message' that they need register before submitting something or uploading something.


Load Index on "Earlier" Post, Prev and Next Links

how would i load the index of my blog at a later point in the reverse chronological feed while maintaining the chronology of the feed overall? i found this explanation of how to load the feed at a specific time (today's date): Modify the main loop to display current month / year which i can modify to be 1 month ago for instance. how would i then insert posts around those from that date and keep the chronology of the feed? say I loaded posts from a month ago, i'd want a link to "previous" posts which loads any posts before 1 month ago, and a "next" link to any posts 1 month after. any help is greatly appreciated. thanks. -c


Editing Links in the Footer of WordPress Themes with Base64 Encrypted Code?

Some WordPress themes have their links encrypted in the footer and I am not able to edit them if I want to edit the links. This is the example code I found: > `<?php` > `eval(base64_decode('Pz4gCQkNCg0KCQk8ZGl2IGNsYXNzPSJjbGVhciI+PC9kaXY+DQoNCgkNCg0KCTwvZGl2Pg0KDQoJPCEtLSAvTWFpbiAtLT4NCg0KCQ0KDQoJPCEtLSBGb290ZXIgLS0+DQoNCgk8ZGl2IGlkPSJmb290ZXIiPg0KDQoJPD9waHAgdGhlX3RpbWUoJ1knKTsgPz4gPD9waHAgYmxvZ2luZm8oJ25hbWUnKTsgPz4gLiAgV29yZFByZXNzIC4gPD9waHAgaWYoaXNfaG9tZSgpKSA6ID8+PGEgaHJlZj0iaHR0cDovL3dvcmRwcmVzc3RoZW1lc2ZvcmZyZWUuY29tLyIgdGl0bGU9IldvcmRwcmVzcyB0aGVtZXMiPldvcmRwcmVzcyB0aGVtZXM8L2E+PD9waHAgZW5kaWY7ID8+PC9kaXY+DQoNCgk8IS0tIEZvb3RlciAtLT4NCg0KDQoNCjwvZGl2PjwvZGl2PjwvZGl2Pg0KDQo8IS0tIC9QYWdlIC0tPg0KDQoNCg0KDQoNCjw/cGhwIHdwX2Zvb3RlcigpOyA/Pg0KPC9ib2R5Pg0KDQoNCg0KPC9odG1sPiA8Pw=='));?>` Does any one know how to find the footer link we want from them and edit them?


How can I get posts in a subcategory to display on it's parent categories archive page?

Currently when you display an archive category page, it only displays it for the main parent, and doesn't display any of the posts that may be in the subcategories under it's parent. How can I alter it so that for every category archive it will display all posts under it, including the subcategory posts?


How to use wp rewrite to hide form action url?

I have a widget that I'm making that builds a multi-step form which retrieves xml data from a third party plugin (http://xmlplugin.com/geoquote.php). While this plugin is available for use already it isn't wordpress friendly at all. In `widget.php` I have the php that displays the form like this:               <form method="POST" action="<?php echo plugins_url( 'step2.php' , __FILE__ ) ?>" name="Calculate" onsubmit="return checkInput(this)">      The form is then rendered on the page in html like this:               <form method="POST" action="http://example.com/wp-content/plugins/geoquote_plugin/views/step2.php" name="Calculate" onsubmit="return checkInput(this)">      When submitting step1 the url for step two is:               http://example.com/wp-content/plugins/geoquote_plugin/views/geoquote_step2.php      Is there a way to rewrite the URL for step two to become something like this:               http://example.com/quote/step2.php      Even if it's not possible in the html it would be nice to not have `/wp- content/plugins/geoquote_plugin/` displayed in the url after submitting step one and redirecting to steop two. I know I can change th wp-content folder and plugins folder name, but I'd rather rewrite this to make the plugin work for any site as a wordpress plugin. Each step is a form written to a seperate file. Without rewriting every file of the prebuilt plugin, how can I rewrite the URLS? I tried this but it didn't do anything:               RewriteRule ^/quote/step-2$ http://example.com/wp-content/plugins/geoquote_plugin/views/geoquote_step2.php [QSA,NC,L]


Use blog as base for tags and categories

I have a site: `example.com` build in wordpress. I set up the posts page as `example.com/news`. I want my tags and categories to be:               example.com/news/tag/mytag     example.com/news/category/mycategory      instead of               example.com/tag/mytag     example.com/category/mycategory      Any idea how I can do this? Thanks!


How can I make Disqus comments not show up on pages?

I use Disqus to manage my comments. I'd like it to appear only on posts, and not on pages. How can I do that? If there's a way to selectively show it on some pages that'd be great, but in general I'd like the default to be hidden on pages.


How To Force User to Enter Post Title First When Adding New Post

This is my first ever question here and In a wordpress newbie so please bear with me. Using a plugin, I set a custom upload directory, to save the uploaded media (post images and featured image) in folder "wp-contents/uploads/postname". However, I noticed when adding a new post, if I tried to set the featured image before setting the post title, the image is uploaded to folder "auto- draft" since the title is not yet set and hence the postname is not yet determined. The image stays in folder "auto-draft" even if I later set a title for the post. The only fix that came to my mind was to force the user to first enter a post title before allowing him to add media to the post content or to set the featured image. Maybe the way to do this is disable the "add featured image" and "add media" links and only enable them when a title is set. I don't really know where to start and any suggestion or any better solution or idea is most appreciated.


Where do I add my own configuration needs and how do I access them?

Somehow despite having been developing web sites since the late 90's I'm only now working on my first WordPress site. And I'm having a bit of trouble understanding the organization of WordPress and where the right places are for me to add my own PHP code. For example, I need to add some configuration info for a third party service that I'll be integrating with. This includes an API key that will be sent via JS at one point, then via PHP at another. Were this ASP.NET, I'd be adding the needed config info to the web.config XML file, then modifying a page to emit that info back out to the browser (as JS) while adding a server side handler that accesses the same. So with WordPress...   * Where would I store this custom config info? Is there a standard configuration spot, or do I need to roll my own?   * How would I access this from within the Page content? Pages, as I understand them, use a predefined theme and store their actual content in the database, so I'm not sure how to inject that code back into the HTML.   * Shortcodes look promising, but everything I've read online says the appropriate spot to register them is in **functions.php** in your theme. Doesn't that mean that if we change our theme, the custom code would disappear? Is there a layer above "theme" for things that are more global in nature?


Remove url parameter using wordpress

how can I remove a parameter from a URL in wordpress? for example if I have the following URL: http://domain.com/?cat=4&paged=2&order=DESC How can I remove paged from it?


Get User_id outside wordpress,

i am trying to get the User_ID outside of wordpress. I have a rating plugin and it needs the current user id, to cast votes. However it seems that something is going wrong. This is the part of the code i am using in my functions.php file:               function get_userid(){       $user = get_current_user_id( );       //i can correctly echo the user_id here       return $user;     }     function add_thumbsup(){        include './thumbsup/init.php';             echo ThumbsUp::javascript();     }     add_action('wp_head', 'add_thumbsup');      Within init.php i have a callback function to get_userid(). So far so good. Within the Plugin i have a block to check for the user_id:               public static function get_user_id()     {         // Cache         static $user_id = FALSE;              // This code only needs to be executed once per request         if ($user_id !== FALSE)             return $user_id;              // The callback config is left empty         if ( ! ThumbsUp::config('user_id_callback'))             return $user_id = NULL;              // Load the user id         $user_id = (int) call_user_func(ThumbsUp::config('user_id_callback'));                 //returns value from get_userid()                 //echo $user_id => 33         // Set user id to NULL if not found         return ($user_id) ? $user_id : $user_id = NULL;     }      It shows my correct user_id of 33 when echoed. However, when vote up/down is pressed, the function returns NULL. Can it be a Ajax/Javascript related problem? Or how can i fix this?


Facebook Like Button with NextGen Gallery

i'm following this tutorial: http://itc.webmaasters.com/nextgen-gallery-with- facebook-and-twitter-wordpress-tutorial-or-hack/ for implement Facebook Like Button on this plugin. It's working very well, but if you like the picture, this "like" does not appear in your timeline on facebook. On the photo you see the "countdown" of likes, but it not appearing on timeline... Any script that is missing so there is your "like"?


how to migrate wpmu from one host to the other?

this issus is different fromm How to migrate wordpress users from one blog to another since i am using WPMU, i have backup the database, and then import it to the other host, also i have changed the wp-config.php, but the web page just shows that i cannot connect to database, what's wrong? the error page is as follows: Error establishing database connection


Using Wordpress' WYSIWYG for comments

I've been trying to set up the comments section of a site I am working on to use the default Wordpress WYSIWYG (TinyMCE). But it's harder than expected. I used this tutorial to take me almost all the way there. The tutorial makes it so I can use the WYSIWYG as the comment form, and it even has a fix when you click on a comment reply link (so that it will work there too). The problem occurs when you click on a comment reply link, then cancel. This causes the original WYSIWYG (the one that first loads at the bottom of the comment stream) to break. I have no idea how to make this WYSIWYG work again. Any thoughts or ideas? Any help is greatly appreciated!


Socialite not displaying icons

I was looking into using Socialite.js to load my twitter/facebook icons. I found the following tutorial, which helped me to build the desired functionality. The links display, but just as text (with HTML-list bullet points). Everything seems to be in place (css/js/sprite). I know its a long shot, but anybody got any ideas? Thanks in advance. EDIT: Here is the code I've used...hopefully it will make sense to somebody haha :) **Function.php:**               function wptuts_load_socialiate() {         // Register Socialite         wp_register_script( 'socialite', get_template_directory_uri() . '/js/socialite.min.js', array(), '', true );         // Register social initialiser script         wp_register_script( 'wptuts-social', get_template_directory_uri() . '/js/wptuts-social.js', array('jquery', 'socialite'), '', true );              // Now enqueue Socialite         wp_enqueue_script( 'wptuts-social' );              // Register social CSS         wp_register_style( 'wptuts-social', get_template_directory_uri() . '/css/wptuts-social.css');              // Now enqueue social         wp_enqueue_style( 'wptuts-social' );     }     add_action( 'wp_enqueue_scripts', 'wptuts_load_socialite' );          function social_after_the_content( $content ) {         $custom_content .= $content;         $custom_content .= '

<a class="socialite twitter-share" href="http://twitter.com/share" rel="nofollow" target="_blank" data-text="<?php the_title() ?>" data-url="<?php the_permalink() ?>" data-count="vertical" data-via="twitter-username-here">Share on Twitter

<a class="socialite googleplus-one" href="https://plus.google.com/share" rel="nofollow" target="_blank" data-size="tall" data-href="<?php the_permalink() ?>">Share on Google+

<a class="socialite facebook-like" href="http://www.facebook.com/sharer.php" rel="nofollow" target="_blank" data-href="<?php the_permalink() ?>" data-send="false" data-layout="box_count" data-width="60" data-show-faces="false">Share on Facebook

     ';              return $custom_content;     }     add_filter( 'the_content', 'social_after_the_content' );      **JS**               jQuery(document).ready(function($)     {          $(‘.social-buttons’).one(‘mouseenter’, function()     {     Socialite.load($(this)[0]);     });          });      **CSS**               .social-buttons { display: block; list-style: none; padding: 0; margin: 20px; }     .social-buttons > li { display: block; margin: 0; padding: 10px; float: left; }     .social-buttons .socialite { display: block; position: relative; background: url('http://tuts-authors.s3.amazonaws.com/wp.tutsplus.com/AhmadAwais/2012/08/29/social-sprite.png') 0 0 no-repeat; }     .social-buttons .socialite-loaded { background: none !important; }          .social-buttons .twitter-share { width: 55px; height: 65px; background-position: 0 0; }     .social-buttons .googleplus-one { width: 50px; height: 65px; background-position: -75px 0; }     .social-buttons .facebook-like { width: 50px; height: 65px; background-position: -145px 0; }     .social-buttons .linkedin-share { width: 60px; height: 65px; background-position: -215px 0; }          .vhidden { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; }      the js is in the js folder (theme/js) along with Socialite.min.js and the css file is also in its own folder (theme/css).


Featured Images link to post parent

I want to reuse featured images for new posts. So a single featured image from the media library is attached to more than one post. When i use post_parent ); ?> on the attachment page to go back to the post, the user will be redirected to the first post the image was attached. How can i redirect the user to the actual post the user comes from?


Stop duplicate posts

I have three loops I want to stop them from displaying the same posts in each one. any help would be greatly appreciated               <?php     $i;     $args = array( 'numberposts' => 8);     $posts= get_posts( $args );     if ($posts) {         foreach ( $posts as $i => $post )              {             setup_postdata($post);              }     }     ?>     <div class="item" id="<?php echo $i; ?>" >     <?php     $a = 0;     foreach( $posts as $i => $post ) :     if ($a == 4) { break; }     ?>
                                      <?php the_post_thumbnail('large'); ?>

<?php the_title(); ;?>

<?php $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,15) . '...'; ?>
                                 <a href="<?php the_permalink() ?>" class="info">Read More >>

      <?php $a++; endforeach;  ?>
               <div class="item" id="<?php echo $i; ?>" >     <?php     $a = 0;     foreach( $posts as $i => $post ) :     if ($a == 4) { break; }     ?>
                                      <?php the_post_thumbnail('large'); ?>

<?php the_title(); ;?>

<?php $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,15) . '...'; ?>
                                 <a href="<?php the_permalink() ?>" class="info">Read More >>

      <?php $a++; endforeach;  ?>
                <div class="item" id="<?php echo $i+1; ?>" >     <?php     $a = 0;     foreach( $posts as $i => $post ) :     if ($a == 4) { break; }     ?>
                                      <?php the_post_thumbnail('large'); ?>

<?php the_title(); ;?>

<?php $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,15) . '...'; ?>
                                 <a href="<?php the_permalink() ?>" class="info">Read More >>

      <?php $a++; endforeach;  ?>


WordPress localization

In WordPress localization files (.po), does php map files by the line number eg. `comments.php:60` or msgid `msgid "<span class=\"meta-nav\">←</span> Older Comments"`. So basically, if I have said string in comments.php in line 60, and move it to line 74, does it still get localized by the msgid?


Attaching Metadata to a Taxonomy Item

I have a taxonomy of menus i.e. Coffee, Tea, Sandwiches, Cakes etc. I want to add more information 'about' the taxonomy such as an image that represents it alongside the other pieces of taxonomy information (slug,name,description). Is this possible, how would you go about it? Thanks, Stewart


How to make variables in URL look like the permalink structure?

I've been looking for the answer to this everywhere but with no success and that's why I'm asking here. I don't even know if the question is the right one. In any case, I'll try to explain. I have a WordPress page with variables in the URL, like this: http://planeta- beisbol.com/tal-dia-como-hoy/?dia=18&mes=04 The content changes depending on the day and month of the year because is gathered from the databse. My question is: How can I change the URL to look something like **planeta- beisbol.com/tal-dia-como-hoy/dia/18/mes/04** or **planeta-beisbol.com/tal-dia- como-hoy/18/04** Any help is apreciated. Thanks.


WPML Translated Term

Since I posted on their forum and I didn't got any answer, here I am, asking the same question again. So: I made a script that add the posibility to add an image and change the order for the terms of a custom taxonomy (called itinerary). So i use this way of getting each term, one by one (there are only up to 10 terms, so i don't think will be any performance penalties):               $term = get_term_by('id', $itinerary_id, 'itinerary' );      then get the image, description, url and so on. The problem i have, however, is that i must have multilanguage content in a way that keeps the custom order AND custom image, so the site admin doesn't have to add images for each language (10terms * 6 languages * other images every week doesn't sound like fun!) I tried to dig a little into WPML sql tables but I didn't found anything that relates to both (i'm playing now only with 2 languages, english and italian) languages So i was wondering if there is something like `get_translated_term()`? Thanks!


How can i retrieve default post per page value? from settings->reading. And total number of posts?

I want to retrieve the default value of Post per page (the value that is set in settings->reading. I've looked around and so far I've only found ways to query it. problem is i dont want to change what was set i just want to retrieve it for pagination purposes. i thought of using `$something->post_count.`(i might be wrong but as i understand it returns the amount of posts displayed currently) but this could be wrong in some cases. Also how can i get the total number of posts ?


Forms and WordPress Nonce

WordPress nonce is driving me nuts! I had this problem when I started my plugin and removed it but now I have come back to it and still don't know what to do. I have looked all over for a solution. My code is same/similar to other examples. I get an "undefined index 'mrlpt_client_check'" error. I also get the same error for 'mrlpt_client' when checking for permissions based on user capabilities, but that is the custom post type that I have created so I'm not sure why that doesn't work either? Here is the code where the nonce stuff is. The include just includes a short form with two input fields, one for an email address and one for a phone number, inside a custom meta box. I have tried including the wp_nonce_field() in with the HTML form include, but that doesn't work either, same error. Can anyone help? Thanks!!               function mrlpt_client_details( $client_post ) {              // Retrieve saved metadata if it exists         $mrlpt_clientEmail = get_post_meta( $client_post->ID, '_mrlpt_client_email', true );         $mrlpt_clientPhoneNum = get_post_meta( $client_post->ID, '_mrlpt_client_phone_num', true );              // Create a nonce field for verification         wp_nonce_field( 'mrlpt_submit_client', 'mrlpt_client_check' );              // Includes the form elements inside the meta box         require_once( 'includes/mrlpt-client-form.php' );     }          // Update/Save client meta data     add_action( 'save_post', 'save_client_metadata' );          function save_client_metadata( $client_post_id ) {              // Verify if this is an auto save routine.         // If it is our form has not been submitted, so we dont want to do anything         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {             return;         }              // Verify this came from the our screen and with proper authorization, because save_post can be triggered at other times         if ( !isset( $_POST['mrlpt_client_check'] )  && !wp_verify_nonce( $_POST['mrlpt_client_check'], 'mrlpt_submit_client' ) ) {             return;         }              // Check permissions - If the post type is mrlpt_client         if ( 'post' == $_POST['mrlpt_client'] ) {             // If the user cannot publish posts             if ( !current_user_can_for_blog( $blog_id, 'publish-post' ) ) { // Checks by capability, not role                 wp_die( 'Insufficient privileges: Sorry, you do not have access to this page.' );             }         }              // OK, we're authenticated: we need to find and save the data         // Verify the meta data is set         if ( isset( $_POST['mrlpt_client_email'] ) && isset( $_POST['mrlpt_client_phone_num'] ) ) {             // Save meta data             update_post_meta( $client_post_id, '_mrlpt_client_email', strip_tags( $_POST['mrlpt_client_email'] ) );             update_post_meta( $client_post_id, '_mrlpt_client_phone_num', strip_tags( $_POST['mrlpt_client_phone_num'] ) );         }     }


Filter by custom field (meta_key) using JSON API

Hi I'm using the great JSON API for Wordpress and would like to filter my custom post types by a specific custom field (using the meta_key and meta_value params). The query in my URL looks like this so far: > > http://example.org?json=get_recent_posts&post_type=mytype&custom_fields=myfield&include=title,custom_fields&meta_key=myfield&meta_value=myvalue However, it still returns all the posts (from that post type), no matter whether or not they contain the custom field mapping. What's wrong? Thanks in advance for any help.


On edit.php, Custom Status only using First Letter?

I've created a custom post type (positions) and a custom status (filled). In both cases, I used the snippets provided by generatewp.com to put things together. Things are actually working about 99% of the way I want them to except for one thing: ![edit.php?post_type=positions](http://i.stack.imgur.com/PxEe7.jpg) The weirdness is twofold: (a) only the first letter of the "Filled (%s)" status label_count property is displaying under the h2-element and (b) the single filled position doesn't appear under the "all" filter. Here's the code for the status followed by the code for the post type:                   $args = array(             'label'                     => 'Filled',             'label_count'               => 'Filled (%s)',             'public'                    => false,             'show_in_admin_all_list'    => true,             'show_in_admin_status_list' => true,             'exclude_from_search'       => true,         );              register_post_status('Filled', $args);              $labels = array(             'name'                => 'Positions',             'singular_name'       => 'Position',             'menu_name'           => 'Positions',             'parent_item_colon'   => 'Parent Position:',             'all_items'           => 'All Positions',             'view_item'           => 'View Position',             'add_new_item'        => 'Add New Position',             'add_new'             => 'Add New',             'edit_item'           => 'Edit Position',             'update_item'         => 'Update Position',             'search_items'        => 'Search Positions',             'not_found'           => 'Position Not Found',             'not_found_in_trash'  => 'No Positions Found in the Trash',         );              $rewrite = array(             'slug'                => 'positions',             'with_front'          => true,             'pages'               => true,             'feeds'               => true,         );              $args = array(             'label'               => 'positions',             'description'         => 'A post Type for job openings and internships.',             'supports'            => array( 'title', 'editor', 'excerpt', 'revisions', ),             'menu_icon'           => 'dashicons-businessman',             'taxonomies'          => array('categories'),             'rewrite'             => $rewrite,             'labels'              => $labels,             'public'              => true,             'show_ui'             => true,             'show_in_menu'        => true,             'show_in_admin_bar'   => true,             'can_export'          => true,             'has_archive'         => true,             'hierarchical'        => false,             'publicly_queryable'  => true,             'show_in_nav_menus'   => false,             'exclude_from_search' => false,             'capability_Type'     => 'page',             'menu_position'       => 5,         );              register_post_type('positions', $args);      Any thoughts?


How to check a filter are applied

I want to apply this filter from this question.               add_filter( 'the_content', 'pre_content_filter', 0 );          function pre_content_filter( $content ) {         return preg_replace_callback( '|<pre.*>(.*)</pre|isU' , 'convert_pre_entities', $content );     }          function convert_pre_entities( $matches ) {         return str_replace( $matches[1], html_entity_decode( $matches[1] ), $matches[0] );     }      But it seems there is no effect. So I want to check if the function `pre_content_filter` is really applied. How can I do it? I've tried `debug-bar` and `debug-bar-extender`, but I couldn't find if I can do it.


How to create a custom CSS class for a specific page template?

I created a page in called "mypage".   Then I created a custom template page called "page_mypage.php". Now, I just wanted to create some custom CSS classes in style.css. I tried with:               div.page-mypage-php #myclass{}      but I get no results. What's the correct way of doing this?


Illegal characters in URLs

I have some old permalinks (posts, pages, tags) that contain now-illegal characters in them - and these aren't working anymore. In previous versions of WP it was allowed to use the non-latin characters, but that changed in newer versions. Is there any way to clean the database from these permalinks (converting them to allowed format)?


What is the correct way to build a widget using OOP

I am working on a simple search form widget, with a built in autocomplete capability (You can download the current version here). The plugin is working, but I am currently rewriting all the code using OOP. One of the problems I came across was the fact the a Wordpress Widget is already a part of the WP_Widget class. I can divide the code into 2 classes. The first one loads all the scripts and css, and initializes the widget. Here is the outline of the code:               class wdSearchForm {                  public function __construct() {                 // Action hook to load widget                 // Register and enqueue styles                 // Register and enqueue scripts             }                  // register widget in WordPress so that it is available under the widgets section             public function wd_searchform() {                 register_widget( 'wd_searchform' );             }     }      And here is the outline to the widget class:               class wd_searchform extends WP_Widget {              // Constructor         function wd_searchform() {              }              // The widget itself         function widget( $args, $instance ) {             // The widget code         }              //Update the widget          function update( $new_instance, $old_instance ) {             // Update code         }              function form( $instance ) {             //Set up widget settings.         }     }      I would like to combine the two, in order to use `wp_localize_script` and load the script with the widget options. How should I do that? Any suggestions are welcome, even if you'll tell me i'm totally in the wrong direction...


Add quantity field with each product on shop page-wooCommerce

I want to add quantity field with each product on shop page. I have used               <input type="number" step="1" min="1" name="quantity" value="" title="Qty" class="input-text qty text"/>      code in woocommerce/templates/loop/add-to-cart.php But its not able to add quantity at the time of submission. Please give me any suggestion. Thanks in advance


get the attachement url for the medium sized image

Hi I'm using some code to create a slideshow with lytebox functionality - the following code is used in the loop to pull each image attached to a post in sequence. It seems to be only pulling the large image, even thought I've set the value to medium - any ideas how I can get .wp_get_attachment_url($attachment->ID, 'medium', false, false) to be pulling the medium sized images? thanks                                               <?php     $argsThumb = array(     'order'          => 'DESC',     'post_type'      => 'attachment',     'post_parent'    => $post->ID,     'post_mime_type' => 'image',     'post_status'    => null     );     $attachments = get_posts($argsThumb);     if ($attachments) {     foreach ($attachments as $attachment) {     echo '
ID, 'medium', false, false). '">ID, 'medium', false, false).'" />
'.apply_filters('the_content', $attachment->post_content).'

';     }      }


What is the difference between esc_html and wp_filter_nohtml_kses?

What is the exact difference between `esc_html` and `wp_filter_nohtml_kses`. Everywhere I look says that both strip **all** the html, the only difference I can see is to do with exactly how they do this. Does `esc_html` encode the tags and does `wp_filter_nohtml_kses` strip them altogether?


Shortcode to display all the post from a category in a page

I have 10 category, and when i select a category in the sidebar il list all the post from that category.... FINE, beautiful Now, i like a page, with some text and photos and then after that content, i like to have all the post from a category listed, just like the category view... Is there a plugin or a short code that just do that ?


How can I get a list of latest posts outside of my WP install?

I have a site with WP installed at /blog, and I'd like to just get a list of the latest blog posts to display on the site home page... that is to say, my custom (PHP) home page, NOT a Wordpress page. I found this, but it doesn't work-- the latest version of Wordpress is looking for Translate_Entry.php or some other kind of class that it can't find. Is there an easy way to do this, short of picking up and parsing the RSS feed on the fly?


Use wp_upload_dir() correctly

All, I'm using the Uploadify plugin to upload some images. I've included the uploadify folder in my themes folder. However, when I try and call uploadify.php I get the following error: Call to undefined function wp_upload_dir() My code looks like this:               global $cssPath, $jsPath, $themePath, $theLayout;     $upload_dir = wp_upload_dir();     echo $upload_dir['path'];      Any idea how I can use this properly? Thanks for any suggestions in advance!


query multiple posts by id using a string parameter, not array()

I'm looking for a way to query posts by id, and using a string as a parameter, instead of an array. Like this: query_posts('p=153'); But I need to get multiple posts. For example with ID 153 and 154. How would I do that with a string as a parameter? The reason that I'm using a string is because I'm generating that string with javascript and if I would do it otherwise it will get super complicated. Any ideas?


404 when Previewing an unsaved draft

I just started at a new job and I'm being thrown into some pretty heavy WordPress bugs on their heavily modified system. Basically what's going on is that they have their own CMS that handles most of a site, but if I site has a blog we inject wordpress there. The backend of all the sites (including the WP admin backend) is running off of one domain. Then we have the blog and site itself on a separate domain. So basically what I can deduce is happening is that the user session isn't being carried over from the backed to the frontend for the preview. Does anyone here have any thoughts about how to fix this?