title: Only show Previous & Next button in Pagination

text: I'm trying to alter the pagination of WP so that it shows ONLY a Previous and/or Next button, and NOT the pages in between. Using this snippet from the Codex:               <?php     global $wp_query;          $big = 999999999; // need an unlikely integer          echo paginate_links( array(     'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),     'format' => '?paged=%#%',     'current' => max( 1, get_query_var('paged') ),     'total' => $wp_query->max_num_pages     ) );     ?>      And these parameters:               <?php $args = array(     'base'         => '%_%',     'format'       => '?page=%#%',     'total'        => 1,     'current'      => 0,     'show_all'     => False,     'end_size'     => 1,     'mid_size'     => 2,     'prev_next'    => True,     'prev_text'    => __('« Previous'),     'next_text'    => __('Next »'),     'type'         => 'plain',     'add_args'     => False,     'add_fragment' => ''     ); ?>      But I can't get it right! It always shows: `1 2 next or previous 1 2` And I'm trying to get this: `next previous` Can this be done by altering the parameters?


title: Problem deleting posts from trash

text: My clients has recently had a problem with spam posts being added to their blog, under various usernames. The users have been deleted, but Wordpress is not able to remove the posts from the trash. Using the 'Empty Trash' button does not work either. Removing directly from the database appears to work, but as there are 4000+ entries this would take a long time. This is Wordpress v3.4.1 and has been upgraded recently. Can anybody help?


title: How to detect if a function has been fired on any page so scripts/styles can be loaded conditionally

text: I'm building a small gallery plugin and I'd like to only load scripts/styles onto the page IF the gallery has been loaded via the template tag. The template tag can take a post ID parameter when used to call a post's gallery from wherever you need within the theme. I know how to do this on singular pages (I can just lookup the meta_key and match it against the currently viewed post) but detecting if there's a gallery present on say the homepage (or any other page) is proving more difficult. So let's assume the template tag looks something like this:               if ( function_exists( 'my_gallery' ) )         echo my_gallery( '100' ); // gallery of image from post 100 will be shown      And the gallery function looks like this (simplified):               function my_gallery( $post_id = '' ) {         // whole bunch of stuff in here which is returned     }      The scripts and styles for the gallery would look like this (simplified):               function my_gallery_scripts() {             wp_register_script( 'my-gallery-js', MY_GALLERY_URL . 'js/my-gallery.js', array( 'jquery' ), '1.0', true );        wp_register_style( 'my-gallery-css', MY_GALLERY_URL . 'css/my-gallery.css', '', '1.0', 'screen' );              // need to load these conditionally, but how?         wp_enqueue_style( 'my-gallery-js' );         wp_enqueue_script( 'my-gallery-css' );          }     add_action( 'wp_enqueue_scripts', 'my_gallery_scripts' );      I've tried using `set_query_var` inside `my_gallery()` like this to kind of set a global variable inside $wp_query.                function my_gallery( $post_id = '' ) {              set_query_var( 'has_gallery', true );              // whole bunch of stuff in here which is returned     }          The problem though is that I can't use `get_query_var` inside the `wp_enqueue_scripts` action. So the following would be ideal for me I believe, loading has_gallery into the $wp_query object which would be available to me on every page (except it doesn't work).                function my_gallery_scripts() {             wp_register_script( 'my-gallery-js', MY_GALLERY_URL . 'js/my-gallery.js', array( 'jquery' ), '1.0', true );        wp_register_style( 'my-gallery-css', MY_GALLERY_URL . 'css/my-gallery.css', '', '1.0', 'screen' );              // does not work         $has_gallery = get_query_var( 'has_gallery' );              if ( $has_gallery ) {             wp_enqueue_style( 'my-gallery-js' );             wp_enqueue_script( 'my-gallery-css' );         }     }     add_action( 'wp_enqueue_scripts', 'my_gallery_scripts' );      Is there another way to set a global option similar to set_query_var but will work in my scenario? I'd like to obviously avoid the use of a global variable. I've also tried setting a constant to no avail.


title: WPSE Plugin Repository: The plugins that came out of WP-Answers

text: ### Link your WPSE-Plugins If you answered a question and made a plugin out of your code, than this is your place to share it. **The Idea:** An old comment from _@MikeSchinkel_ during the beta phase where he wrote something like "I wonder how many plugins will come out of WA". ### "Rules"   * Write a short - _one line_ \- description of what the plugin is intended to do.   * Tell how it's meant to be used: Template Tag, Shortcode, Widget, Plug & Play.   * Link to your plugins in an answer, on github/bitbucket/whatever or in the wp.org repo.   * Please _link one plugin per answer_.   * If you got some answers that would serve well as plugin, just modify your A and link it here.   * If your plugin became a commercial plugin later, it's ok to post the link here.   * If your plugin is not cc- _plus_ GNU GPL 2-licensed, please mention the license. * * * _Notes:_   * I added a tag named wpse-plugin to this answer. Please edit the Q (where your Answer ended up as a plugin) and add the tag, or ask a moderator to do so.   * I'll upvote any Answer/Plugin added here.   * Please also join the discussion about this on meta. * * * **Important:** About License As to a lot of discussion about copyright & open source licenses1), i want to mention that these plugins run under the cc-license _plus_ the GNU GPL 2-license, if the author didn't mention else. 1) Some related discussion examples:   * @EAMann   * Joost de Valk


title: add_menu_page include a php page from theme directory

text: I have added some custom tables to a wordpress and trying to add wp-admin section to manage them. By using following code I have successfully added a menu item in wp-admin but I'm unable to call the php page that resides into my theme folder               add_menu_page('Private Messages', 'Private Messages', 'manage_options',                   'message_admin', 'message-admin.php',                    get_bloginfo('stylesheet_directory').'/style/images/message.png');      in error_log it gives me this error > PHP Warning: call_user_func_array() expects parameter 1 to be a valid > callback, function 'message-admin.php' not found or invalid function name in > /var/www/idon.dev/wp-includes/plugin.php on line 470, referer: > http://idon.dev/wp-admin/admin.php?page=message_admin **Update:** The wordpress says > $function > > (string) (optional) The function that displays the page content for the menu > page. Default: None. Technically, the function parameter is optional, but if > it is not supplied, then WordPress will assume that including the PHP file > will generate the administration screen, without calling a function. **Most > plugin authors choose to put the page-generating code in a function within > their main plugin file. In the event that the function parameter is > specified, it is possible to use any string for the file parameter.** This > allows usage of pages such as ?page=my_super_plugin_page instead of > ?page=my-super-plugin/admin-options.php. I know what does it mean > PHP Warning: call_user_func_array() expects parameter 1 to be a valid > callback, function but what I'm trying to achieve is to call a page rather of function. what is according to wordpress is possible, or guide me if I'm wrong. Please note that I don't want to include page in functions, I will rather be happy to add my code into function.


title: Change News Story Layout Based on Date Range

text: My website has been up for 10 years and as such has gone through various layout changes. Whenever I have made a new layout, I have added all news stories that were made under that layout into a new Wordpress category so I could target said stories and keep the same layout applied to them. This is the code I've used:               <?php rewind_posts(); ?>     <?php if (have_posts()) : ?>     <?php while (have_posts()) : the_post(); ?>     <?php if ( in_category('2563') ): ?> (layout coding)     <?php elseif ( in_category('919') ): ?>  (layout coding)     <?php elseif ( in_category('3') ): ?> (layout coding)     <?php else: ?> (layout coding)     <?php endif; ?>     <?php endwhile; ?>      I'm once again changing my layout, but I don't want to keep making new categories since it just makes things look messy. So I was wondering if there was a way to instead of basing the news story layouts on category, to base them on their creation date. So I would like to be able to do something like... "if X story was published between 7/15/03 at 1:03 PM and 9/19/07 at 11:34 AM, use the following layout." Like the code above, but with time/date ranges. Does anyone know if this is possible? Thank you so much!


title: is_user_logged_in() isn't working

text: I'm making a login form for my site, and I've this section:               <?php     if (is_user_logged_in()) {         echo 'Hello, ', $user_login, '. Logout';     } else {         wp_login_form();     }     ?>      And after loggin in, it returns to the page with no indication of logging in.   I suspect is_user_logged_in() isn'tw orking, but I don't know how to debug this problem. EDIT: Whenever I do this:               global $current_user;          var_dump($current_user);      I always get:               ect(WP_User)#3 (7) { ["data"]=> NULL ["ID"]=> int(0) ["caps"]=> array(0) { } ["cap_key"]=> NULL ["roles"]=> array(0) { } ["allcaps"]=> array(0) { } ["filter"]=> NULL }      No matter if i"ve 'logged' in with the above form.


title: How to display comments on different page

text:
I am creating a reviews site and I want to display the customer reviews (comments) on a separate page from the single-restaurant.php. I'll just have a link that says (Read reviews/ add yours). I created a custom comments template and called it comments-side.php and this is what I have in it:               <?php     /**      * Comments Template      *      */          ?>

                      <?php if ( have_comments() ) : ?>                          <?php do_atomic( 'before_comment_list' );// supreme_before_comment_list ?>
                     <?php $args = array(         'walker'            => null,         'max_depth'         => '10',         'style'             => 'ul',         'callback'          => 'mytheme_comment',         'end-callback'      => null,         'type'              => 'all',         'reply_text'        => 'Reply',         'length'            => '10',         'page'              => '',         'per_page'          => '3',         'avatar_size'       => 32,         'reverse_top_level' => null,         'reverse_children'  => '',         'format'            => 'xhtml', //or html5 @since 3.6         'short_ping'        => false // @since 3.6     ); ?>                         <?php wp_list_comments( $args, $comments); ?>
                                      <?php endif; ?>
                  <?php $comment_args = array( 'fields' => apply_filters( 'comment_form_default_fields', array(                             'author' => '
' .                                         '<input id="author" name="author" type="text" value="' .                                         esc_attr( $commenter['comment_author'] ) . '" size="30"' . @$aria_req . ' PLACEHOLDER="'.__('Your name','supreme').'"/>' .                                         ( $req ? ' *' : '' ) .                                         '
',                             'email'  => '
' .                                         '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . @$aria_req . ' PLACEHOLDER="'.__('Email Address','supreme').'"/>' .                                         ( $req ? ' *' : '' ) .                                 '
',                             'url'    => '
' .                                         '<input id="url" name="url" type="text" value="' . esc_attr(  $commenter['comment_author_url'] ) . '" size="30"' . @$aria_url . ' PLACEHOLDER="'.__('Website','supreme').'"/>'.'
')),                             'comment_field' => '
' .                                         '<textarea id="comments" name="comment" cols="45" rows="8" aria-required="true" PLACEHOLDER="'.__('Comments','supreme').'"></textarea>' .                                         ( $req ? ' *' : '' ) .                                         '
',                             'comment_notes_after' => '',                             'title_reply' => __( 'Add a comment', 'supreme' ),                         );                         if(get_option('default_comment_status') =='open'){                             comment_form($comment_args); } // Loads the comment form.  ?>

      However, when I try to go to the comments template (http://myurl.com/post- slug/comments-side/), the page throws a 404 error. I changed permalinks to the default setting and switched it back to /%postname%/ but I still get the 404. How do I get this to work properly? I don't know if it is relevant but this is what I have in my functions.php for the comments:               function mytheme_comment($comment, $args, $depth) {             $GLOBALS['comment'] = $comment;             extract($args, EXTR_SKIP);                  if ( 'div' == $args['style'] ) {                 $tag = 'div';                 $add_below = 'comment';             } else {                 $tag = 'li';                 $add_below = 'div-comment';             }     ?>             <<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">             <?php if ( 'div' != $args['style'] ) : ?>             <div id="div-comment-<?php comment_ID() ?>" class="comment-body">             <?php endif; ?>
             <?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>             <?php printf(__('%s says:'), get_comment_author_link()) ?>
     <?php if ($comment->comment_approved == '0') : ?>             <?php _e('Your comment is awaiting moderation.') ?>
     <?php endif; ?>
<a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>">                 <?php                     /* translators: 1: date, 2: time */                     printf( __('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?><?php edit_comment_link(__('(Edit)'),'  ','' );                 ?>
                  <?php comment_text($comment_ID); ?>                   <a href="comments-side/#comment-<?php comment_ID() ?>" class="comment-more">read more
             <?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
             <?php if ( 'div' != $args['style'] ) : ?>
             <?php endif; ?>     <?php             }      This is what I have in single-restaurant.php to show the recent comments for that each single post from the "restaurants" post type

Recent Reviews
       <?php comments_template( '/comments-side.php', true ); // Loads the comments-side.php template. ?>


title: Self-installed WP: blog posts not appearing on homepage

text: I run the website for our company. I'm not a programmer. It's a small two- person company, so I basically have to do it alone. We're changing to a new server host soon, so I tried backing up and duplicating our website to a test area in our new server. With a few minor exceptions, most things went by without a hitch... except that the blog entries are not appearing on the homepage, as it's supposed to. Please check out what I'm describing:   * the actual website with the first 10 blog entries bellow the big banner: http://www.audiolog.pt   * the test website (note: the banner is missing on purpose. It's the missing blog posts below that are puzzling me): http://www.the-microphone-spa.com/audiologtest Could someone please advise on how to proceed? How can I make the blog entries appear to complete the website duplication? Not sure how to go from here... Thanks!


title: Use Cron to modify posts via sql

text: Hi to all I need to run this twice a day:               UPDATE wp_posts SET post_content = REPLACE ( post_content, '[img]', '<img src="' );     UPDATE wp_posts SET post_content = REPLACE ( post_content, '[IMG]', '' );     UPDATE wp_posts SET post_content = REPLACE ( post_content, '[/IMG]', '" />' );     UPDATE wp_posts SET post_content = REPLACE ( post_content, '[b]', '' );     UPDATE wp_posts SET post_content = REPLACE ( post_content, '[B]', '' );     UPDATE wp_posts SET post_content = REPLACE ( post_content, '[/b]', '' );     UPDATE wp_posts SET post_content = REPLACE ( post_content, '[/B]', '' );      How can do it? I don't want to run it manually and I can't do it each time a post is published because I'm running a MU website and my authors are too lazy to modify their code from bbCode to HTML. I'm using cPanel so I can add a CronJob easily if you teach me how to do it. Thanks to all!


title: How to remove date from showing in meta description

text: When my results show in Google for the respective keywords, in the meta description I see the date as well. Is there a way to remove the date? Example meta description shows up as: 15 Jun 2009 ... My meta description I use FV Simplr SEO and very pleased with it.. Would like to know if there's a hack for this.


title: How do I order by multiple custom fields using wp_query?

text: I have a rating system where the user can enter a custom field of either "Stars" or "Hearts", but whichever one they choose they have to enter a value of 1 thru 5. Using wp_query, I can successfully sort by one of these custom fields, but I'm not sure how to sort by both. Here is the code I'm using to sort by one of the custom fields "Stars":               $args=array(     'posts_per_page' => $con_review_num,     'post_type' => 'con_product_reviews',     'paged' => $paged,     'orderby' => 'meta_value',     'order' => 'DESC',     'meta_key' => 'Stars'        );      Here is what I wish this function would do (notice the last line):               $args=array(     'posts_per_page' => $con_review_num,     'post_type' => 'con_product_reviews',     'paged' => $paged,     'orderby' => 'meta_value',     'order' => 'DESC',     'meta_key' => 'Stars Hearts'         );      Is there another way to do that?


title: Click on banner to register to the blog

text: Hi to all I would like to add a "premium" section to my wordpress blog and I would like to force users to click on a banner before being allowed to register to my blog, any step 2 step idea on how to solve this problem? The banner will be html or js. Thanks a lot to all!


title: tinymce "Link" popup throwing error, not working

text: I am unable to access the new lightbox-style link popup window. When I try to open it, I get an "error on page" message, and the popup doesn't appear. I've tried on ffx, ie & chrome, on a pc and a mac. I go to work and all is well, on all those same browsers, pc & mac. I can't find any pattern. I've logged out & back in again, cleaned cache, refresh, yada, yada. Does anyone have any idea what could be causing this and how i might fix it?


title: How can I make this WordPress site actually record the edits I make in the HTML editor?

text: For a WordPress site I'm editing, the HTML editor will not transfer any of the updates I save in the HTML code to the actual website. All of the pages are left completely blank when I check them despite there being a lot of content on the actual page. How do I edit this HTML content? Where could this WordPress be saving its HTML code to? The last WordPress site I edited always had HTML code saved in the text editors for the pages and always saved the code I wrote there to the actual page.


title: Posts are being posted in two categories instead of 1

text: When I create a post and assign the relevant category, the post ends up in the category I've assigned it to and another category. For example when I load a post to graphic design it automatically goes to blog as well. I want my graphic design and my blog to be separate. I've done some research but I don't know what to do.


title: Image uploading stuck on "crunching"

text: I have a problem to upload images to the media library when is used multi-file uploader on WP 3.5.2. Single file media uploader works fine. I have tested it with 1k PNG image, which was stuck on "crunching" anyway. Debug log for that part came with those messages:               [23-Jul-2013 13:41:28] PHP Notice:  has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in /home/animals/public_html/mysite.com/wp-includes/functions.php on line 2925     [23-Jul-2013 13:41:28] PHP Notice:  has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in /home/animals/public_html/mysite.com/wp-includes/functions.php on line 2925     [23-Jul-2013 13:41:28] PHP Notice:  get_theme_data is deprecated since version 3.4! Use wp_get_theme() instead. in /home/animals/public_html/mysite.com/wp-includes/functions.php on line 2841      Also when I try to use Image Uploader from Featured Image it comes with that error message:               An error occurred in the upload. Please try again later.      Looks like it is WP related issue rather than hosting/permissions. WP_MEMORY_LIMIT is set to 128M, PHP mem limit is same and PHP upload limit is 5M. As further testing it looks like is related to the Media Library. If I will reset DB and leave all as is it works. When I will re-upload DB with almost 12,000 image it crashes. Thanks


title: Split the content of single.php by more tag and split texts and photos

text: I am trying to sprit the_content() by more tag. But I cannnot think of how to write the code for the photos(images) before and after more tag. Photos exists none or more by the post. If anyone know what to do or the code               <?php if(is_user_logged_in()): ?>                  <?php             $content = get_the_content();             $content = preg_replace("|(]+>)|si","",$content);             echo $content;         ?>     <?php else: ?>                  <?php              global $more;             $more = 0;             $content = get_the_content('' , FALSE, '');             $content = preg_replace("|(]+>)|si","",$content);             echo $content;                 if ($pos=strpos($post->post_content, '')):                     echo '<button>LOGIN</button>';                 endif;          ?>     <?php endif; ?>               <?php if(is_user_logged_in()): ?>         Images before more     <?php else: ?>         Images after more     <?php endif; ?>


title: Error - only variables can be passed by reference

text: I've Googled quite a bit to find out details, but all of the pages that come up have nothing to do with the file that's generating this error. For me, it's `plugin.php` in `wp-admin/includes`, on line 535. Here's the code:                   if ( !in_array($plugin, $current) ) {                 if ( !empty($redirect) )                         wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error                 ob_start();                 include_once(WP_PLUGIN_DIR . '/' . $plugin);      The `wp_direct` call is line 535. Why is this happening and how can I fix it? I think this is causing blank pages to come up.


title: Who to echo custom post type on submenu page

text: i have custom post type and i want to echo the content of it in submenu page like these                   <?php          function codex_custom_init() {       $labels = array(         'name'               => 'Books',         'singular_name'      => 'Book',         'add_new'            => 'Add New',         'add_new_item'       => 'Add New Book',         'edit_item'          => 'Edit Book',         'new_item'           => 'New Book',         'all_items'          => 'All Books',         'view_item'          => 'View Book',         'search_items'       => 'Search Books',         'not_found'          => 'No books found',         'not_found_in_trash' => 'No books found in Trash',         'parent_item_colon'  => '',         'menu_name'          => 'Books'       );            $args = array(         'labels'             => $labels,         'public'             => true,         'publicly_queryable' => true,         'show_ui'            => true,         'show_in_menu'       => true,         'query_var'          => true,         'rewrite'            => array( 'slug' => 'book' ),         'capability_type'    => 'post',         'has_archive'        => true,         'hierarchical'       => false,         'menu_position'      => null,         'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )       );            register_post_type( 'book', $args );     }     add_action( 'init', 'codex_custom_init' );               function bookf() {         //Add Submenu Page         add_submenu_page( 'edit.php?post_type=book', 'to edite Teams', 'EDite Teams', 'manage_options', 'bookf', 'bookout' );     }     add_action( 'admin_menu', 'bookf' );               function bookout() {          Echo "the content of book Custom post type same that show on all book : edit.php?post_type=book ";          }                         ?>


title: How to properly modify get_userdata in plugin to get roles to update in database

text:
I wasn't sure if starting a new question was appropriate, but the questions are completely different from my original ones and code has changed since originally asking for help. This is still the same project but I'm trying to fix code so it works. Thanks to those who explained using get_userdata in the plugin caused roles being added to everyone and not just the currently logged in user. **Plugin Concept** : Login a user from a forum into WordPress, assign role based on the secondary user group of the forum. So far - I can almost get this working by using get_userdata() and calling a class which assigns the roles. Unfortunately this assigns all roles to the user if the current user goes to a post belonging to a different author. Here is the current code. This adds the role to the database for the user_id. It's just adding all roles because - as someone suggested - get_userdata is for all users.               In plugin file /includes/users.php          if ( !function_exists('get_currentuserinfo') ) :          /**      *      * @return void|boolean      */          function get_currentuserinfo() {         global $current_user, $user_ID, $XF;              if ( ! empty( $current_user ) ) {             // same as get_currentuserinfo() in pluggable         }              if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ) {             wp_set_current_user( 0 );             return false;         }              $visitor = $XF->visitor;              $user_ID = $visitor->get('user_id');              //This is the faked Wordpress login and logout routines          if ( is_blog_admin() || is_network_admin() || empty( $_COOKIE[LOGGED_IN_COOKIE] ) && $visitor->get('user_id') != 0 ) {                  global $wpdb;                  /* Logged in XF session but no WP session */             if (!function_exists('wp_set_auth_cookie')) {                      wp_set_auth_cookie( $visitor->get('user_id') );                  }         }              elseif( !empty( $_COOKIE[LOGGED_IN_COOKIE] ) && $visitor->get('user_id') == 0 ) {                  /* we have a logged in WP session but no XF session */             wp_clear_auth_cookie();         }              /* If no XenForo user is logged in */         if ( $visitor->get('user_id') == 0 ) {             $current_user = null;             wp_set_current_user( 0 );             return false;         }              $current_user = get_userdata( $visitor->get('user_id'), true );         wp_set_current_user( $visitor->get('user_id') );     }          endif;          if ( !function_exists('get_userdata') ) :          /**      * Retrieve user info by $user_id      *      * @param unknown $user_id      * @return boolean|unknown|WP_User      */          function get_userdata( $user_id ) {         global $wpdb, $XF, $WP_User;              if ( !is_numeric( $user_id ) )             return false;              if ( empty( $user_id ) )             return false;              $user_id = absint( $user_id );         if ( !$user_id )             return false;              /**          * Check $user is in cache object          */              $user = wp_cache_get( $user_id, 'users' );              if ( $user ) {             return get_user_by( 'id', $user_id );         }              /**          * Initialize new $user          */              $user = new WP_User;              XFUserData::fillUserData($XF->visitor, $user, $user_id);              update_user_caches( $user );              /**          * This is a check for has_prop. Will remove later.          */              if ( $user->has_prop( 'twitter' ) ) {             echo '';         }              return get_user_by( 'id', $user_id );     }          endif;          In file /public/xfuserdata.php          class XFUserData {          public static function fillUserData($visitor, $classObj, $user_id) {         global $XF;                  if( $user_id != 0 ) {                      $userModel = $XF->getModelFromCache('XenForo_Model_User');                      $user = $userModel->getUserById( $user_id, array('join' => XenForo_Model_User::FETCH_USER_FULL) );                      $classObj->userObj = $user;                      if( $user_id == $visitor->get('user_id') ) {                          // Calls set_user_roles to establish WordPress Roles                          XFUserData::get_user_roles($classObj, (string)$visitor->get('user_group_id'), $visitor->get('secondary_group_ids'));                          // $classObj->ID =                           return $classObj;                      } else {                          // Fill in permission based fields                     // $user['user_id']                          XFUserData::get_user_roles($classObj, (string)$user['user_group_id'], $user['secondary_group_ids']);                               // $classObj->ID =                          return $classObj;                      }             }              }          public static function get_user_roles( &$classObj, $user_group_id, $secondary_group_ids )  {         /**          * Function get_user_roles(&$classObj, $user_group_id, $secondary_group_ids)          *          * This function sets the current user role based on the secondary group          */         global $XF, $wp_roles;              $user_groups = explode( ',', $secondary_group_ids );         $user_groups[] = $user_group_id;              /**          * Loop through the user_roles and find the WP role equivalent for each          */         $user_roles = array();         foreach( $user_groups as $user_group ) {                  $user_roles[] = $XF->options['xf_user_role'][$user_group];                  $new_roles = $XF->options['xf_user_role'][$user_group];                  $user_id = $XF->visitor->get('user_id');                  $user = new WP_User( $user_id );                      echo '
Before Conditional
';                 echo 'This is the user_id ' . $user_id . '
';                 print_r( $classObj->userObj );                 echo '
';                  if( $new_roles === 'administrator' ) {                 $user->set_role('administrator');             }                  elseif( $new_roles === 'editor' ) {                 $user->set_role('editor');                      echo '
Editor Area
';                 echo 'This is user_id ' . $user_id . '
';                 var_dump( $user );                 echo '
';             }                  elseif( $new_roles === 'author' ) {                 $user->set_role('author');             }                  elseif( $new_roles === 'contributor' ) {                 $user->set_role('contributor');             }                  elseif( $new_roles === 'subscriber' || $new_roles === '' || $new_roles === null ) {                 $user->set_role('subscriber');             }                  return false;         }              return;     }      My hope was to simply rename get_usermeta to get_xf_usermeta ... but after the past 10 plus hours of trying all types of changes, I'm at a loss. Changing the function name almost works. The role is available for just that single user (var_dump shows this) but the role is never added to the database as it is when get_userdata is the function name. Clearly I'm missing a step to get the role added to the database when the get_userdata is no longer used. Does anyone have any suggestions? The codex and a plugin development book I have just don't go into this type of detail for me (or I'm completely misunderstanding) and I'm too new to this but after weeks of struggling I've been asking here. I appreciate any direction and suggestions. **UPDATE** This is not exactly right but the wp_capabilities are now written to the database. Unfortunately the user gets the "You do not have sufficient permissions to access this page." despite having editor role and capabilities. This is the change in xfuserdata.php                           elseif( $new_roles === 'editor' ) {                      $capabilities = array (                     "editor",'delete_others_pages','delete_others_posts','delete_pages','delete_post','delete_private_pages','delete_private_posts','delete_published_pages','delete_published_posts','edit_others_pages','edit_others_posts','edit_pages','edit_posts', 'edit_private_pages','edit_private_posts','edit_published_pages','edit_published_posts','manage_categories','manage_links','moderate_comments','publish_pages','publish_posts','read','read_private_pages','read_private_posts'                 );                 $user->add_role('editor');                 update_user_meta( $user_id, 'wp_capabilities', $capabilities );                  }      **UPDATE** I finally solved this problem after watching Nacin's WordPress TV talk regarding Roles & Capabilities as well as looking at many different options. If you see a better way then please let me know. But first recognize add_cap and add_role failed in this class's method. I have no idea why but update_user_meta works as long as the array is done with a true.                           $user_id = $XF->visitor->get('user_id');                  $user = new WP_User( $user_id );                  if( $new_roles === 'administrator' ) {                           if ( is_multisite() && is_super_admin() ) {                           grant_super_admin($user_id);                      } else {                      $capabilities = array ( 'administrator' => true );                      update_user_meta( $user_id, 'wp_capabilities', $capabilities );                      }                 return;             }                  elseif( $new_roles === 'editor' ) {                      $capabilities = array ( 'editor' => true );                 update_user_meta( $user_id, 'wp_capabilities', $capabilities );                 return;                  }                  elseif( $new_roles === 'author' ) {                      $capabilities = array ( 'author' => true );                 update_user_meta( $user_id, 'wp_capabilities', $capabilities );                 return;                  }                  elseif( $new_roles === 'contributor' ) {                      $capabilities = array ( 'contributor' => true );                                 update_user_meta( $user_id, 'wp_capabilities', $capabilities );                          return;             }                  elseif( $new_roles === 'subscriber' || $new_roles === '' || $new_roles === null ) {                      $capabilities = array ( 'subscriber' => true );                 update_user_meta( $user_id, 'wp_capabilities', $capabilities );                 return;                  }


title: Str_replace using shortcode with multiple changes

text: I am using a feed importer plugin which gives the option to use a short code in case I need to change data (in this case data for a custom field) on import, using for example:                   [str_replace('This','that',{feedfield})]      But how do I use this when I have more to change? Because it's a shortcode I can't use an array like:                   $a = 'this', 'another this';         $b = 'that', 'another that';         echo str_replace($a, $b, get_post_meta($post->ID, 'feedfield', true));      Can anyone enlighten my lack of knowledge?


title: Is it possible to use WP_USER_QUERY to search by username using a wildcard?

text: As above guys, I'm trying to build an AJAX search that works within BuddyPress WITHOUT modifying core code, but that allows me to use a wildcard when I'm searching by username. Any suggestions?


title: Permalink structure as code in back-end?

text: I have this `permalink structure`: `/%year%/%monthnum%/%postname%/` What I want to is, output the link of a post in the back-end and let users input a postname, that will automatically lead to that post (if it exists, otherwise 404)... So, I have this:               function transform_pseudo_anchor_wpse_101201($match) {       if (isset($match[1])) {         return '(link: '.$match[1].')';       }     }          $content = preg_replace_callback(       '%\(link: ?(.*?) ?\)%',        'transform_pseudo_anchor_wpse_101201',        $content     );      echo $content;       Of course, this does not work... But how can I make it work? So I want the get the exact link if someone links to a post that exists... So after example.com, the year/monthnum and postname has to come...


title: Add custom ID to wp_nav_menu list items

text: Is it possible to assign specific ID's to wp_nav_menu list items? For example, if my menu contained links for "Home", "About" and "Contact", could I assign the "Home" list item and ID of "home"?


title: adding a button to the media uploader

text: I am writing a plugin for Wordpress and am wondering how to add an extra button to the media uploader that says something like "add to album". I can't seem to find info on how other developers have managed to get this done. Thanks :)


title: Displaying a custom taxonomy term's name & description

text: How can I display a term's name & description for a custom taxonomy within The Loop (single post page template)? Currently I can show its name like this:               the_terms( $post->ID , 'director', 'director: ');      but can't get the description **EDIT**   I dont want to use extra php coding like:               $directors = get_the_terms($post->ID ,'director');     foreach($directors as $director){         $director_name = $director->name;         $director_desc = $director->description;     }


title: How can I send an id over the url?

text: I need to send an id that I am going to collect and use in a plugin. Plugin will collect it in a page where I use plugins shortcode. The url I am trying to get is like www.example.com/device/devicename-id. Any idea on how can I do this?


title: Issue with hide and display horizontal scroll accoucement bar

text: **I am using horizontal-scrolling-announcement plugin to announce a news bellow the header.I have added some custom code to hide and display scrolling news announcement at one event if the admin change the status display no or yes from back end and its working good for Firefox browser. Before the customize the plugin if i set the status display no it was scrolling news with text "No announcement available.   But the problem is that in chrome browser when i set status display no from back end code work properly and if i set status yes this time it's not scroll the news in chrome but work with fire fox. Now the display status is yes from back end.** Site link:- click here                if ( ! empty($data) )                  {             //Display news                   }             else                 {                  ?> <style >                      .breaking-news{             visibility:hidden;                  height:0;             width:0;             opacity:0;                   }        </style>             <?php                 /*  $what_marquee = $what_marquee . "No announcement available.";                     if($group <> "")                     {                         $what_marquee =  $what_marquee . " Please check this group " . $group;                     }                    */                  }                       return $what_marquee;                  }


title: WooCommer Product Category Loop - How to change the display order of the rating and price?

text: I want to do a very very simple thing : To re-order the display of the rating and price information on a WooCommerce product category loop. Now in the product category page I got 5 products, all of the same layout: \--THUMBNAIL--   | Product name   | Rating   | Price   | Add to Cart   Now I just want to make it like this: \--THUMBNAIL--   | Product name   | Price   | Rating   | Add to Cart   I know the code just lies somewhere between the hooks; but just cannot find anyway to make it work. If anyone has ever dealt with this problem, please help show me a way to work with this. I would appreciate this very very very much. Thank you.


title: How to check if the current page's parent is one of 2 different ID's

text: I'm using this little snippet right now to check if the current page is the child of a particular page;               $studies_parent = 5860;     if ($studies_parent == $post->post_parent) {      Which is working fine, although now I need to check if the current page is a child of one of 2 different ID's and I'm not sure how to go about it. Basically I need to check if the current page's parent is either 5860 or 1047. Any ideas how I'd do that?


title: Error 404 for JQuery import "jquery-1.10.2.min.map"

text: I got my WordPress 3.6 installation running using a theme I have bought. When I'm using my theme the console says:               GET ...xyz.de/landing/wp-includes/js/jquery/jquery-1.10.2.min.map 404 (Not Found)      This error does not appear when using the default theme. This seems like a broken import of a jQuery file. The site seems to work with the theme enabled. Where should I start looking to fix this in a theme not written by me? Best regards, Chris


title: Array of user ids to list of user names

text: I'm outputting an array of user ids from metadata like so:   `$awaygoalby = unserialize($post_meta_data['report_away-scorers'][0]);` and I want to change each user id to the user name. So I was hoping to do something like this:               foreach($awaygoalby as $string){     $name = get_userdata( $string );     echo $name;     }      Unfortunately I get an error saying that the "Object of class WP_User could not be converted to string." What is the best way of doing this?


title: How to receive notifications when a new user registers

text: I am running a WordPress site for real estate and I cannot seem to figure out how to receive an email when a new user registers or downloads information from my site. If anyone could help me figure out how to turn these notifications on or what plugin I should use to receive these notifications that would be greatly appreciated.


title: Category Name with Custom Post Type

text:
Hopfully I can explain this, I'm confusing myself now. I have Template called 'Landing' that is the template for a number of different pages in Wordpress. Each of the pages using this template will contain different blocks of information. These blocks contain a title, an image, text and a link, I'm calling them Content_Widgets, they are not Widgets in the Wordpress sense. My Content_Widgets are each posts and I have created a custom post type called Content_Widget. Now I need to load the correct posts on the correct page. I thought I could do this by having a category on the page in Wordpress and then the same category on the post for that page. So it would be like load the post that have a category the same as this page. Is this a good way to load the correct post on the correct page? So this is the code I'm using but it's not outputting anything.(I'm using Advanced Custom Fields in the Custom post type.) The correct category name outputs in the h1 but nothing else. Anyone have any ideas why this isn't working, or is this the wrong way to do this??
                      <?php                                         // get category name for page                     $cat = get_the_category($post->ID);                     $catName = $cat[0]->name;                     echo $catName;                          $content_args = array(                         'post_type'         => 'Content_Widget',                         'category_name' => $catName                                      );                          $content_loop = new WP_Query($content_args);                          if($content_loop->have_posts()):                         while($content_loop->have_posts()):                             $content_loop->the_post();                          $linkImg = get_field('image');                     $txt = get_field('text');                     $link = get_field('link');                      ?>
<?php echo $catName;?>

<?php the_title(); ?>

<img src="<?php echo $linkImg; ?>" alt="">

<?php echo $txt; ?>

<a href="<?php $link; ?>">Find out more

                           <?php                          endwhile;                     endif;                          wp_reset_postdata();                      ?>


title: Menu System: Custom Links

text: Is there a way to set default values for options selected in the WordPress menu system? My example would be if the "Custom Link" option was chosen, can this default to a _blank target? Thanks!


title: wordpress 3.4 template files in subdirectories

text: i've been organizing my sites template files into a sub directory, which is now possible with wordpress 3.4. but when i move a custom post-type single file (ie. single-news.php) into the sub directory, it is not recognized. anybody have any experience with this new feature?


title: Individual page data in one page template

text:
So I am trying to create a one page template but still allow the user to add separate pages in the admin panel. What I did to output all the pages in one template file is as followed:                   <?php         $args = array(             'sort_order' => 'ASC',             'sort_column' => 'menu_order'         );         $pages = get_pages($args);         foreach ($pages as $page_data) {             $title = $page_data->post_title;                  if (has_post_thumbnail($page_data->ID) {                 $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $page_data->ID), 'full');             }             $section .= '
;             $section .= $thumbnail[0];             $section .= apply_filters('the_content', $page_data->post_content);             $section .= '
                  echo $content;         }         ?>      Now this nicely outputs 3 `<section>` tags with the page title as their `id`. But whenever I try to grab data like the `page-thumbnail` or a custom meta box data for video embed, it will return that thumbnail inside all `<section>` tags. Each `<section>` should function as their own `page` and grab their respective data. Am I doing something wrong?


title: Redirect page to default subpage

text: On a site that I'm working on I have a particular page that has four subpages, which act like process steps. I want the parent page to always redirect to the first of these as a default, should the user type in or click on a url that only points to the parent page. Is there a way to accomplish this without the use of mod_rewrite? Thanks in advance.


title: localize inline css

text: I'm providing a theme setting to define a group of images for the frontpage background. On page load, I want to pick an image at random from this pool. My approach is to add a line of inline CSS styling the html element with the given image url like this:               <style>       html {          background: url(images/random_image_3.jpg) no-repeat center center fixed;          -webkit-background-size: cover;         -moz-background-size: cover;         -o-background-size: cover;         background-size: cover;       }     </style>      Is there a preferred way of doing this ? Should i use a localize_style function I haven't found out about, or just echo the css out using the right hook? And what's the best hook for this, only targeting the front facing site?


title: How to add custom text editor in add post section?

text: How can I add custom text editor in wordpress? Is there any way to do that? If not, How can I add or remove certain features from it? Thanks in advance.


title: When does next Cron Job run (time from now)?

text: I would need to know how much time is left between _now_ and the next time a specifc Cron Job is done. For another answer I built a basic cron inspector plugin which can be found here. Reason I'm asking is that I'm already that wasted from working that I can't think straight at the moment. :/ Thanks in advance.


title: How to check if current page is a parent item or child item in a given menu

text:
I'm trying to build a submenu into my theme, and I've got it working except it shows even on top-level pages that don't have children. How could I check that the current page (or current menu item) is either a parent or a child item (I'm pretty sure that logic holds up) in a given menu? At the moment I'm trying to do this check outside of the menu function, because it has wrapper divs and a title that I won't want to show at all in cases where the page isn't a parent or a child. However, if the best answer to my problem is to output the whole thing via a custom walker I'm open to how that might work too. Thanks in advance. Edit: I've gotten a bit further but am now stuck, I can capture the submenu as a variable, but I can't do the check "If there's nothing in the submenu, show nothing". In the below code, `$submenu` doesn't return false when there are no items even with that `fallback_cb => false`.               $main_menu_id = 2; // Change to the main menu id for this install     $top_menu_id = 4; // Change to the top menu id for this install     $in_menu = '';          // Check what menu the page is in, if any     if( coepio_is_in_menu( $main_menu_id ) ) {         $in_menu = 'main-nav';     } else if( coepio_is_in_menu( $top_menu_id ) ) {         $in_menu = 'top-nav';     }          // If the page is in a menu...     if( $in_menu != '' ) {              // Capture submenu as a variable         $args = array(                      'theme_location' => $in_menu,                     'echo'           => '0',                     'sub_menu'       => true,                     'falback_cb'     => false             );         $submenu = wp_nav_menu( $args );              // If the menu has items         if( $submenu ) {             echo 'Menu is good to go';             ?>

In This Section

                         <?php                          echo $submenu;                          ?>

             <?php         }          }      You may have noticed that `'sub_menu' => true` in the `$args`. Here's the code that handles that, taken from another SO post.               // Submenus - required for the submenu (above) to work     // filter_hook function to react on sub_menu flag     function coepio_submenu( $sorted_menu_items, $args ) {       if ( isset( $args->sub_menu ) ) {     $root_id = 0;          // find the current menu item     foreach ( $sorted_menu_items as $menu_item ) {       if ( $menu_item->current ) {         // set the root id based on whether the current menu item has a parent or not         $root_id = ( $menu_item->menu_item_parent ) ? $menu_item->menu_item_parent : $menu_item->ID;         break;       }     }          $menu_item_parents = array();     foreach ( $sorted_menu_items as $key => $item ) {       // init menu_item_parents       if ( $item->ID == $root_id ) $menu_item_parents[] = $item->ID;            if ( in_array( $item->menu_item_parent, $menu_item_parents ) ) {         // part of sub-tree: keep!         $menu_item_parents[] = $item->ID;       } else {         // not part of sub-tree: away with it!         unset( $sorted_menu_items[$key] );       }     }          return $sorted_menu_items;       } else {     return $sorted_menu_items;       }     }     add_filter( 'wp_nav_menu_objects', 'coepio_submenu', 10, 2 );


title: change recent posts based on category

text:
I am writing a code to display the recent posts of different categories. On clicking category 1, I want to display the recent posts from cat1 and on clicking cat 2 the recent posts from cat2 and so on. The code I have written was displaying the same posts on **all** cats. What should I do?                <?php       $rPosts = new WP_Query();     $rPosts->query('showposts=4&category_name=category1');          while ($rPosts->have_posts()) : $rPosts->the_post(); ?>
POSTS FROM THIS CAT

<?php the_post_thumbnail(array(300,221)); ?>

<?php echo get_the_title();?>

<a class="btn btn-white" href="<?php the_permalink(); ?>">Read Full Story
          <?php      endwhile;      ?>


title: Accidentally deleted active_plugins portion of the wp_options DB table

text: Ok, so I'm pretty sure I'm screwed here, because I do not have a database backup, but I figured I'd ask just in case. Within PhpMyAdmin, I meant to just go to the wp_options table and empty out active_plugins portion of this table due to not being about to login because of a plugin error. Well I hit the delete button instead of just emptying it out. Is there any way I can manually add in the active_plugins part of this table? I tried the repair database thing, but that didn't work.


title: Display posts count in front of the tag, for each tag

text: I needed to list all existing tags so I have some code that does it. Now I would like to put the count (the number of posts the tag is associated with) in front the tag like in the example given below.                   first_tag  - 18         second_tag - 24         third_tag  - 48      I found a solution given here that displays count for **one** specific tag, but I need the counts for **each and every tag**. So, could this be modified to my need. Or do you have any other ideas. Will appreciate your help.               $taxonomy = "post_tag";      $term_slug = 'some-tag';     $term = get_term_by('slug', $term_slug, $taxonomy);     echo $term->count;


title: Resource Issues: Importing external data into custom post type and keeping records up to date

text: I have a custom post type that imports external data nightly. When the import script runs for the first time, it imports approximately 4,000 records (data will grow). Each record consists of a post title, body and 15 additional meta fields. After the import has run at least once, all subsequent nights it updates at least one meta field from each record to indicate that the record existed in the external data set and that it is up to date. The external data contains a modified date field which indicates when a record has changed outside of WordPress. If the import script detects that a record changed, it will update all fields. At the very end of the import, an internal script will look at all records and find the ones that didn't update. If a record didn't update, a delete flag is set and the published status is changed. Eventually that record is deleted. Lastly, each record can be overwritten in WordPress, which sets a flag that this post should not be updated during an import. This was one of the reasons why we decided to place them in a custom post type, as it provides data control before the record is displayed on the site. I'm using `wp_insert_post` to insert and update records, `update_post_meta` to insert and update meta fields, a `WP_Query` to get all current and expired records, and eventually I delete the records that need to be deleted with `wp_delete_post` and `delete_post_meta`. The problem is that this script is too resource intensive to run and eventually WordPress will timeout and not complete the script. I figure I have two options:   1. I break this script into batches. For example, I could process 1,000 records at a time and store an index so that it would know where to pick-up during the second iteration.   2. I could try using different functions. For example, during the initial import, I run `update_post_meta` once per field (15x). I could probably find a way to make that one query via a custom query. My question is if anyone has ever run into resource issues in WordPress when synchronizing data with an external source, and how they've managed to mitigate those issues. Was it via option #1, #2 or perhaps an entirely different method?


title: Does Wordpress has an automatic link parse function?

text: Does wordpress has an automatic link parse function? I want the HTML to be generated automatically when writing               www.url.com -> www.url.com


title: Custom links or pages from Media Gallery

text: I have a simple Wordpress Media Gallery running on a page and every time you click an image it takes you to the attachment page. This is fine as I can write an article in the description and that page will contain text and the main image. The issue is I would like each image to have it's own article/post on my website. As I look at it there are two solutions I can see, but I may be missing something. 1) Use the attachment page as the article and somehow get WordPress to use these as posts. 2) Set a custom link in the gallery so that it links to an actual article. Neither are brilliant and I would like to know if anyone knows of a better way to accomplish this. Any advice and help would be greatly appreciated.


title: Suggestions for allowing basic users to view their own posts?

text: I have a client that needs to give access to her clients certain documents. She wants the ability to give them user name and password, so once they log in, they go directly to their page or post which will list the documents available for download. Plugins don't seem to help here and some are way too complicated. I have read many articles and tried several concepts but can't get it right. It's almost a membership to access info, but it's free and members can only be allowed to see what was written for them. This is a tough one for me. Any suggestions?


title: Using plus (+) sign insread of space (-) in WordPress URL

text: How to change space (-) sign to plus (+) sign in clean URL WordPress? Like: `http://www.whitelotuscorporation.co.in/anax_wp/about-us/` to: `http://www.whitelotuscorporation.co.in/anax_wp/about+us/` You can see where the change need to be done-- `about+us` instead of `about- us` in the URL.


title: Memory consumption in w3-total-cache vs wp-super-cache?

text: I've been suggested by my hosting to move from w3-total-cache to wp-super- cache since the later is supposed to be using less memory then the first. Is there any knowledge about this comparison? Is there a way to test it on my own site? (I am on a managed VPS) Thanks.


title: Stumped - Ajax Response Returns 0

text: I can't seem to figure it out. No matter what I do, the ajax call keeps giving a 0 response. I've tested my PHP funtion and it works fine but whenever I call it through ajax I receive nothing (only a 0 response). Any help/suggestions is much appreciated.               add_action('wp_ajax_get_ldapattr', 'get_ldap_attr');     add_action('wp_ajax_nopriv_get_ldapattr', 'get_ldap_attr');          function get_ldap_attr() {              header("Content-type: application/json");         $lanid = $_POST['lanid'];         $dn = get_site_option ( "ldapServerOU" );         $usr = get_site_option ( "ldapServerCN" );         $pw = get_site_option ( "ldapServerPass" );         $addr = get_site_option ( "ldapServerAddr" );         $ids = array();         $ad = ldap_connect ( $addr )             or die ( "Connection error." );         ldap_set_option ( $ad, LDAP_OPT_PROTOCOL_VERSION, 3 );         ldap_set_option ( $ad, LDAP_OPT_REFERRALS, 0 );         $bind = ldap_bind ( $ad, $usr, $pw );         if ( $bind ) {             $SearchFor ="cn=".$lanid;                 $result = ldap_search ( $ad,$dn,$SearchFor );                 $entry = ldap_first_entry ( $ad, $result );                 if ( $entry != false )  {                     $info = ldap_get_attributes ( $ad, $entry );                 }                 $comm  = stripos ( $info['manager'][0], ',' );                     // find position of first comma in CN=Mxxxxxx,OU=Users,OU=MCR,DC=mfad,DC=mfroot,DC=org  (directReports field)                 $eq = stripos ( $info['manager'][0], '=' );                     // find position of first =                 $s_lanid = substr ( $info['manager'][0], $eq+1, ( ( $comm-1 ) - ( $eq ) ) );                     //get substring between = and comma...                  $sup = getLDAPInfo ( $s_lanid, $bind, $ad, $dn );                      // get supervisor's info...         }              echo json_encode($sup);         die();     }               jQuery(document).ready(function() {              jQuery('#empLanId').on('blur', function() {             var lanid = jQuery('#empLanId').val(),                 data = { action: "get_ldapattr", lanid: lanid};                      jQuery.ajax({                 url: ajaxurl,                 data: data,                 dataType: 'json',                 type: 'post',                 success: function(response) {                     console.log(response);                   }             });              });     });


title: Custom Social Share Buttons

text: I am using the default buttons from Twitter, Facebook and Google Plus on my website. (Top and Bottom - Six buttons). The individual scripts slow my website a lot and I've been suggested to add custom social buttons. How to start developing the custom buttons? How actually will it improve my load time?


title: Can't get full post title if there a spaces in title

text: I want to make a custom query that checks the post title and puts in a different URL like this:               <a href=bing.com/search?q=<?php echo single_post_title(); ?>>Blablabla      But it does not work for me if I have a post with a space in it, like `Hello World`. Then it only shows me `Hello` in the link. How can I get the full post title? I tried this too, but did not work, just like the first one.               <?php     $titletest = get_the_title();          echo " $titletest ";     ?>


title: How to make all posts in a category sticky?

text: Total WP and web development noob here. As the title suggests, I'm trying to make all the posts in one of my categories into "stickied" posts. But so far I've had no luck. What I've tried is this sexy little snippet of code:               <?php      if (in_category('bestcategoryever')) {     stick_post(); }     ?>      ...but to no avail. Perhaps I'm not putting it in the right place (not quite sure where I should put it really) or perhaps it's wrong to start with. Please explain thoroughly and plainly, my terminology in these things isn't the best. I hope you can help me! Cheers!


title: "Read More" link not displaying

text: I am using the Sideshow theme which I received as part of a bundle hence I don't receive any support from Themezilla themselves. I am trying to insert a `"Read more"` link when I insert a `"More"` tag. I have tried following instructions from Wordpress Codex using the_content and the_excerpt but haven't been able to crack it. The site I'm using it on is onespectator.com From the themes functions.php               /*-----------------------------------------------------------------------------------*/     /*  Change Default Excerpt Length     /*-----------------------------------------------------------------------------------*/          function tz_excerpt_length($length) {     return 55; }     add_filter('excerpt_length', 'tz_excerpt_length');          /*-----------------------------------------------------------------------------------*/     /*  Configure Excerpt String     /*-----------------------------------------------------------------------------------*/          function tz_excerpt_more($excerpt) {     return str_replace('[...]', '...', $excerpt); }     add_filter('wp_trim_excerpt', 'tz_excerpt_more');


title: Single callback with multiple setting fields

text: Is there anyway you can use a single callback with multiple setting fields? Maybe there is a way to pass the setting field used through the callback?


title: how to change some of the rules in the database

text: I need to add a rewrite rule for a WP page. I noticed that the rule is already part of the existing set, but apparently it is not correct. With the hope some internal mechanism would have replaced the existing rule, I unsuccessfully hook the generate_rewrite_rules action:               function my_insert_rewrite_rules( $rules )     {         $newrules = array();         $newrules['faqs/([^/]+)/page/?([0-9]{1,})/?$'] = 'index.php?faqs=$matches[1]&paged=$matches[2]';         return $newrules + $rules;     }     add_filter( 'rewrite_rules_array','my_insert_rewrite_rules' );      What's the best way to proceed?


title: Custom Taxonomy Breadcrumb Navigation

text:
I'm completely new to custom post types and custom taxonomies, so bear with me. I'm trying to create a breadcrumb navigation for the custom taxonomy `project-category` within the custom post type `projects`. Essentially, I need it to work like this: Custom Post Type > Custom Taxonomy Level 1 > Custom Taxonomy Level 2 > Custom Taxonomy Level 3 > etc. Each heading needs to be linked to the corresponding page. I have this _kind of_ working, but it's not very dynamic, and it only links three levels of navigation. Here's my code for that:

Projects
         <?         $term = get_term_by("slug", get_query_var("term"), get_query_var("taxonomy") );         $parent = get_term($term->parent, get_query_var("taxonomy"));         if ($parent->name != "") {             echo "
slug . "\">" . $parent->name . "
";         }         if (is_tax("project-category")) {             $term = get_term_by("slug", get_query_var("term"), get_query_var("taxonomy"));             $tax_term_breadcrumb_taxonomy_slug = $term->taxonomy;             echo "
slug . "\">" . $term->name . "
";         }         ?>
      Up to the second level, this works currently, as below: Custom Post Type > Taxonomy Level 1 > Taxonomy Level 2 But if I go to a third level, it ends up being: Custom Post Type > Taxonomy Level 2 > Taxonomy Level 3 The deeper I go, the deeper the levels get off. I know the issue is that Im just checking for one parent, but I can't figure out how to check for all possible parents. UPDATE: I managed to get it working a bit better, but it's listing things backwards. Here's my updated code:

<a href="<? echo home_url(); ?>/projects">Projects
         <?         $term = get_term_by("slug", get_query_var("term"), get_query_var("taxonomy") );         $parent = get_term($term->parent, get_query_var("taxonomy"));         while ($parent->term_id) {             echo "
slug . "\">" . $parent->name . "
";             $parent = get_term($parent->parent, get_query_var("taxonomy"));         }         echo "
slug . "\">" . $term->name . "
";         ?>
      Instead of listing Custom Post Type > Taxonomy Level 1 > Taxonomy Level 2 > Taxonomy Level 3, it's listing Custom Post Type > Taxonomy Level 2 > Taxonomy Level 1 > Taxonomy Level 3. It's something to do with the while loop, but I can't seem to reverse it. Thanks.


title: Remove Permalink Meta Box not working?

text: For some reason the slug / permalink meta box is not being removed on the Edit Page screen. Code in `functions.php`               function mjp_edit_meta_boxes() {              // Remove Meta Boxes         remove_meta_box( 'commentsdiv', 'page', 'normal' ); // Works         remove_meta_box('slugdiv', 'page', 'normal'); // Fails?          }          add_action( 'add_meta_boxes', 'mjp_edit_meta_boxes' );      **Update:** These are the hooks I've tried:               add_action( 'add_meta_boxes', 'mjp_edit_meta_boxes', 1 );       add_action( 'add_meta_boxes', 'mjp_edit_meta_boxes', 999 );       add_action( 'admin_menu', 'mjp_edit_meta_boxes', 1 );       add_action( 'admin_menu', 'mjp_edit_meta_boxes', 999 );


title: Displaying and searching Custom Posts

text: I'm trying to convert my existing web site from old-school HTML to WordPress, and have created a series of Custom Posts for my whisky tasting notes. However, I'm stuck trying to set up a page that will let users search by the name of the whisky, region (saved as custom taxonomies) and score (0-100 scale), as well as display all three of those variables plus the ABV value (proof). Score and ABV are saved as custom metadata. The name of the whisky serves as the post title, and the tasting notes are in the text of the post. I've tried adapting templates in the `single.php` file to make this work, but don't get any of them to display. How to code this or a plug-in that will automate the process?


title: Stackoverflow type of badge plugin giving warnings in Wordpress 3.5

text: I modified an abandoned Stackoverflow form of badge plugin to work with Wordpress 3.4.2 and it does indeed. The full script for it is here: http://pastebin.com/Ta91zXiL When upgrading to Wordpress v3.5, I receive these warnings when publishing a post (or post a comment):               Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 342 and defined in /public_html/wp-includes/wp-db.php on line 990          Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 342 and defined in /public_html/wp-includes/wp-db.php on line 990          Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 342 and defined in /public_html/wp-includes/wp-db.php on line 990          Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 355 and defined in /public_html/wp-includes/wp-db.php on line 990          Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 355 and defined in /public_html/wp-includes/wp-db.php on line 990          Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 342 and defined in /public_html/wp-includes/wp-db.php on line 990          Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 342 and defined in /public_html/wp-includes/wp-db.php on line 990          Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 342 and defined in /public_html/wp-includes/wp-db.php on line 990          Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 355 and defined in /public_html/wp-includes/wp-db.php on line 990          Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 355 and defined in /public_html/wp-includes/wp-db.php on line 990          Warning: Cannot modify header information - headers already sent by (output started at /public_html/wp-includes/wp-db.php:990) in /public_html/wp-includes/pluggable.php on line 876      So it seems to be related to lines 342 and 355:               function rhb_get_user_comment_count( $args = '' ) {                  global $wpdb;                  $comment_count = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*)                     FROM " . $wpdb->prefix . "comments                     WHERE user_id = " . $args['user_ID'] . "                     AND comment_approved = '1'" ) ); // line 342                  return $comment_count;     }          function rhb_get_user_post_count( $args = '' ) {                  global $wpdb;                  $post_count = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*)                     FROM " . $wpdb->prefix . "posts                     WHERE post_author = " . $args['user_ID'] . "                     AND post_status = 'publish'                     AND post_type = 'post'" ) ); // line 355                  return $post_count;     }      I have been trying to understand these warnings all day but failed. Can someone kindly assist me to fix this issue so that we can have a working version of this very useful badge system for WP 3.5?


title: Problem since update 3.5

text: > **Possible Duplicate:**   >  Stackoverflow type of badge plugin giving warnings in Wordpress 3.5 I have updated my wordpress website simpliblog.org 2 days ago. And now I can read that on top: Missing argument 2 for wpdb::prepare(), called in /home/simplib/public_html/wp-content/themes/gonzo/includes/widget_areas.php on line 154 and defined in /home/simplib/public_html/wp-includes/wp-db.php on line 990 I don't know what to do, I don't want to download and install wordpress 3.5 because I have changed the css. Another problem : my website is in french and english and since the update my qtranslate plugin doesn't work. I can't post anything!! What should I do?


title: Adding signature at end of tiny mce editor

text: How can I append signature to tiny mce editor content. I need signature to appended at end of the content in tiny mce editor.


title: How to order posts by number of Vimeo Likes

text: I have number of posts that contain embeded video from Vimeo, I can get vimeo likes and display them inside the post using vimeo API but how can I order those posts by number of Vimeo likes?


title: Display all images from specific CPT

text:
I have a CPT for "Band Members", and I want to list all of them at the top of a template, above all the posts (which will just be featured images) - a sort- of Navigation for all members. I can't think of how to do this... is there two loops? Any help would be appreciated!
     <?php               $args=array(       'post_type' => 'band_member',       'post_status' => 'publish',       'posts_per_page' => -1,       'caller_get_posts'=> 1 // WHAT IS THIS??       );          $my_query = null;     $my_query = new WP_Query($args);     echo '
';      if( $my_query->have_posts() ) {            while ($my_query->have_posts()) : $my_query->the_post();            ?>               <a href="<?php the_permalink() ?>" rel="bookmark" ><?php the_title(); ?>               <?php       endwhile;     }     echo '
';          wp_reset_query();  // Restore global post data stomped by the_post().          ?>          <?php     // PUT ALL CPT FEATURED IMAGES HERE...     ?>
      END OF ORIGINAL CODE..... NEW CODE WITH HELP.....
      <?php     $args=array(       'post_type' => 'band_member',       'post_status' => 'publish',       'posts_per_page' => -1,       );          $my_query = null;     $my_query = new WP_Query($args);     echo '
';      if( $my_query->have_posts() ) {            while ($my_query->have_posts()) : $my_query->the_post();            ?>         <a href="<?php the_permalink() ?>" rel="bookmark" ><?php the_title(); ?>          <?php       endwhile;     }     echo '
';          wp_reset_query();  // Restore global post data stomped by the_post().          ?>     <?php          $args=array(         'post_type' => 'band_member',         'post_status' => 'publish',         'posts_per_page' => -1,       );            $my_query = null;       $my_query = new WP_Query($args);                 if( $my_query->have_posts() ) {                 while ($my_query->have_posts()) :  $my_query->the_post();            ?>         <a href="<?php the_permalink() ?>" rel="bookmark" ><?php the_post_thumbnail(); ?>      <?php          endwhile;       }            wp_reset_query();  // Restore global post data stomped by the_post().          ?>


title: Restricting certain blog posts by date?

text: I'm building my friends blog and he asked me a rather odd request. He wants the latest five blog posts to be visible to non-registered members but not to others. I'm using s2Member for membership handling. My Initial attempt was just limiting the number of blog posts to 5 and hiding the pagination button based on if someone's logged in and of the right user level. This works fine, but people can manually add ?page_id=x&paged=y to view more content. Also, if they know the name of the post, they can view it as well. My thoughts were to add some sort of auto-categorizing, where if the posts aren't in the 5 newest, they would be auto tagged with the category "archive" which then can be protected using s2members built-in functionality. I just have no clue where to begin with auto tagging a category. I would appreciate any insight on where to begin with all of this? Also, if you have a better idea of how to do something similar, I'm open to suggestions. Thanks in advance! Tre


title: get next/previous post name

text: i know that : `<?php $pagename = get_query_var('name'); ?>` get the name of the current page/post. But I dont know how to get the name of the next and the previous post. I will use it for a hover tip and the alt of the image that will lead to the previous/next post


title: New WP installation due to language issues

text: My current WP installation is in English, I dowloaded the theme (So cute by YIT) My objective is to set up a store in swedish. I've been struggeling to translate strings etc, I've tried the WPML plugin and I also tried creating new .mo and .po files with Poedit according to general recommendations. I have now decided to use the Swedish WP installation and my question before I do this is if I simply can overwrite current English files via FTP? There is a wp-config-sample.php in the new installation file but I guess this serves no function as I have the original wp-config.php with the correct "define" settings plus database settings etc? Thank you!


title: Get the parameter, compare it in the array, check and display

text:
I have:   * Wordpress custom post types;   * Two hotels registered in the custom Wordpress admin area;   * A variable named `$hotels` which get the field where the hotels registered are listed;   * The hotels are printed in the page and get shuffled on every refresh of the page; I need:   * Recognize the parameter `?hotel=Hotel%20Name` and show only the selected hotel in the `select` field So, as I mentioned, I have a select field where the hotels registered are listed. When selecting one, the parameter is in the address. Here is my code:               //Starts the loop     <?php if ( have_posts() ) : while ( have_posts() ) : the_post();        //Get the field in Wordpress where hotels are listed       $hotels = get_field('produtos_hotel');            //Check if hotel exists, prepare the shuffle and check the parameters       if($hotels) {         #Make it shuffle         shuffle($hotels);              #Set index to zero if none of the hotels is selected and let it shuffling         $selectedIndex = 0;              #Check the parameter and compare it to the array object. If it is equal, let it displayed.         if(isset($_GET['hotel'])) {           $selectedIndex = array_search($_GET['hotel'], $hotels);         }              #Field registered in Wordpress where display the hotels name and check the index.         $hotelName = get_field('hotel_name', $hotels[$selectedIndex]->ID);     ?>
<?php echo "Selected hotel is: " . $hotelName ?>
          <?php } ?>      I believe that I am in the right approach, however I know that I have to set up somethign to get the objects. Something like this, but I don't know where:                   #Search the post_title object in the $hotels array;         $key       = array_search($theName, $hotels);         $theObject = $hotels[$key]->post_title;      **Note:** I'm going to print here the `print_r` of the `$hotels = get_field('produtos_hotel');`! I neeed the `post_title` object where `Ocean Maya Royale` and `Flamingo Cancun Resort` are set.               Array (         [0] => WP_Post Object (             [ID] => 1113             [post_author] => 1             [post_date] => 2014-06-11 16:18:59             [post_date_gmt] => 2014-06-11 19:18:59             [post_content] =>              [post_title] => Ocean Maya Royale             [post_excerpt] =>              [post_status] => publish             [comment_status] => open             [ping_status] => open             [post_password] =>              [post_name] => ocean-maya-royale             [to_ping] =>              [pinged] =>              [post_modified] => 2014-06-18 14:41:25             [post_modified_gmt] => 2014-06-18 17:41:25             [post_content_filtered] =>              [post_parent] => 0             [guid] => http://localhost/mydocs/advtour/newsite/wordpress/?post_type=add_content&p=1113             [menu_order] => 0             [post_type] => add_content             [post_mime_type] =>              [comment_count] => 0             [filter] => raw         )              [1] => WP_Post Object (             [ID] => 1302             [post_author] => 1             [post_date] => 2014-06-12 01:19:36             [post_date_gmt] => 2014-06-12 04:19:36             [post_content] =>              [post_title] => Flamingo Cancun Resort             [post_excerpt] =>              [post_status] => publish             [comment_status] => open             [ping_status] => open             [post_password] =>              [post_name] => flamingo-cancun-resort             [to_ping] =>              [pinged] =>              [post_modified] => 2014-06-18 14:40:19             [post_modified_gmt] => 2014-06-18 17:40:19             [post_content_filtered] =>              [post_parent] => 0             [guid] => http://localhost/mydocs/advtour/newsite/wordpress/?post_type=add_content&p=1302             [menu_order] => 0             [post_type] => add_content             [post_mime_type] =>              [comment_count] => 0             [filter] => raw         )     )


title: Wordpress plugin to auto execute php script on a specific time?

text: Is there a WordPress plugin that can auto execute php script on a specific time? Or an other way to do this? At this moment I execute every 30 minutes (from 00:00 to 08:00) a php script with cpanel (Cronjobs). Is there some way to handle this in WordPress itself?


title: add_filter on "the_excerpt" only works when post does not have excerpt

text: class my_menu extends WP_Widget     {          function widget($args, $instance)     {          // Excerpt length filter         $new_excerpt_length = create_function('$length', "return " . $excerpt_length . ";");              if ( $instance["excerpt_length"] > 0 ) {         add_filter('excerpt_length', $new_excerpt_length, 999);         }      //...      }}      This filter works great if the post does not have an excerpt. How do I apply the same filter to a post that has an excerpt? In other words, when the post has an actual excerpt, its not filtering it at all, the whole excerpt is displayed. However, when the post does not have an excerpt, the get_the_excerpt() call gets filtered so that it only returns the number of words specified by "excerpt_length"


title: Need Help with Custom ModRewrite

text: How can I correctly send all traffic from: > **http://my-domain.com/about/case-studies/clientName/** to > **http://my-domain.com/about/case-studies/?clientName=$clientName** (not seen by visitors) Using mod-rewrite so that when I hit that URL I see the /case-studies/ **page** in Wordpress (in the database) with "Hello $clientName"? Do I need to create a custom page _file_ , or can I get by with my Wordpress **page** in the database? Thank you!!


title: Deleting Certain terms from appearing on the front end as links

text:
I've put some thought into this but Can't really figure out what direction I take in getting rid of certain terms in my testimonial_category called 'home', 'homeone', hometwo. I only want to stop these displaying in a link format on the relevant page. Here is the code the process's all the terms within testimonial_category, I was thinking I need to somehow add a filter that stops these 3 named terms appearing as links but could really do with some advice on how to do this.

Testimonials

All
                     <?php                     $terms = get_terms("testimonial_category");                     $count = count($terms);                     if ($count > 0) {                         foreach ($terms as $term) {                             ?><li class="<?php echo $term->slug; ?>"><?php echo $term->name; ?>
<?php                         }                     }                     ?>

      Many thanks for any help.


title: get_permalink to attachment not working

text:
I have following code                   <?php                $args = array(        'post_type' => 'attachment',        'numberposts' => 12,        'post_status' => null       );            $attachments = get_posts( $args );          if ( $attachments ) {             foreach ( $attachments as $attachment ) {                echo '
ID ).'">';                echo wp_get_attachment_image( $attachment->ID, array('100', '100') );               echo '
';               }          }          ?>      The point of this script is to show last added 12 photos (thumbs of it). And this works perfect. But I want to add second funcionality - link to the page where it comes from (usually native gallery embed into post/page) The problem is that in this case the link is corrupted. It always links to the very first post. What I am doing wrong?


title: Rename .dat to .xml when cron job runs

text: I'm using WPAllImport to import content to WP, and then running a cron job on that same file to update the import frequently. The client’s article writing company originally provided a .dat file for the import, in a password protected folder, on his server. Because I can’t use a .date with WPAllImport, I downloaded the file and changed the extension to .xml, which then worked fine (but of course, I then had a NEW file on MY server, not his). I’ve asked him if he could provide a .xml originally, and he said that .date IS a legacy form of .xml and that I could just rename the file upon runtime. How does one do that?


title: How to display public user profile with 2 additional fields? (GitHub source code included)

text: As a WordPress newbie I am trying to create a plugin, which will force users to specify their **city** and **gender** while registering and then display a personal profile page for each user showing this information. I have checked in my plugin in GitHub: wp-city-gender.php. For the registration part I have followed the Customizing the Registration Form doc and it seems to work fine - the additional **city** and **gender** fields are displayed in the registration form and stored later in the `wp_usermeta` table. They are also editable in the **Users** part of the dashboard: ![Users screenshot](http://i.stack.imgur.com/DiqQa.png) Also, I redirect commenter links to `/user/user_id` by using this code:               define('PROFILE', '%s');          function get_comment_author_link($cid) {         global $comment;         return sprintf(PROFILE, $comment->user_id, $comment->comment_author);     }          add_action('get_comment_author_link',  'get_comment_author_link');      ![screenshot](http://i.stack.imgur.com/L2xGz.png) **My question is:** How can I add a personal profile page for each user, displaying his/her name and the 2 additional fields? **What I don't want:** I can not just create a plain PHP script fetching data from `wp_usermeta` for a certain numeric `user_id` \- because it wouldn't be integrated in my WordPress website, i.e. it won't display the logo at the top and the footer at the bottom.


title: Using Wordpress as a Mobile App Backend

text: I'm searching for a fast way to develop a backend for Mobile Apps. The idea is to use Wordpress as a backend. My problem is: How can i serve the information to the Mobile App? I saw the JSon plugin but you can't use it for custom post types. I was thinking at xml, is there a plugin i can use or should i code specific pages that serves xml? Thanks.


title: Is it alright for two people to simultaneously be logged into a WP site as administrator?

text: I have given the admin log-in details of my site to a friend who is helping me sort out a problem. If I log in at the same time she is logged in, will it cause a problem? Or can we both be logged in at the same time?


title: Can't fetch custom taxonomies from a plugin file

text: I set up a custom taxonomy last week and everything seemed to be working correctly, until I realised that from one plugin file I could only fetch some taxonomies, whereas from another plugin file I could fetch them all. [Those are two different plugins] I have no idea why this is happening. I only run `var_dump(get_taxonomies())` when each of the plugins is almost done with whatever it has to do, which gives me the impression that the problem is not related to _order of loading_ issues.


title: How to hide wordpress error message?

text: how to hide wordpress error message "You do not have sufficient permissions to access this page" and show 404 error page for all non administrator's request like e.g mydomain.com/wp-admin/plugin.php and all such requests. And they should be redirected to 404 error page.


title: Different header image 'Home' and Pages

text: I want to use two images in the header. In the home page and single.php is the image I've uploaded in the panel (named logo.png). For pages I want use the image 'logopage.png' (directory: /images/logopage.png). Just the image I'm using in home page is working. In the pages nothing appears. How can I do that? Ps.: The code I'm trying to use: function.php:               add_theme_support( 'custom-header', array(       'default-image' => get_template_directory_uri() . '/images/logo.png',       'random-default'         => false,       'width'                  => 1050,       'height'                 => 100,       'flex-height'            => true,       'flex-width'             => true,       'default-text-color'     => '',       'header-text'            => false,       'uploads'                => true,       'wp-head-callback'       => '',       'admin-head-callback'    => '',       'admin-preview-callback' => '',     ));      In the header.php:                 <?php       if ( is_home() ) echo theme_heading();       if ( is_single() ) echo theme_heading();           elseif ( is_page() ) get_template_directory_uri() . '/images/logopage.png';       ?>      Sorry my english :X


title: Where To Find bb_profile_data(); In bbPress?

text:
I posted this same question on WP Forum, but it's completely dead. So, there is a great tutorial in this blog about showing post count in bbPress at this link. According to that article, to show post count in bbPress, I should replace `<?php bb_profile_data(); ?`> with the following code               <?php bb_profile_data(); ?>
      <?php      global $bb_table_prefix;      $query1 = "SELECT COUNT(*) FROM ".$bb_table_prefix."posts WHERE poster_id = $user_id AND post_status = 0";      $query2 = "SELECT COUNT(*) FROM ".$bb_table_prefix."posts WHERE poster_id = $user_id AND post_status = 0 AND post_position = 1";      echo "Forum Posts: ".$bbdb->get_var($query1)."   ";      echo " Topics Started: ".$bbdb->get_var($query2).""; ?>
      But I've only one question. Where in the world is that bb_profile_data(); tag. Please help me, it's very important for me...Thanks you guys!!


title: Using AJAX with Forms

text: I am attempting to validate and submit a form using AJAX in WordPress, however, the response that I am getting is 0. According to the codex, this would seem to indicate that admin-ajax is unable to find the functions that I defined. What am I doing wrong? ### Code (Simplified for Demonstration Purposes)               <script type="text/javascript">          jQuery(function()     {         jQuery(document).on('click', '#test-button', function()         {             var name = jQuery("#name").val();             var AdminAJAX = <?php echo json_encode(admin_url('admin-ajax.php')); ?>;                  var ajaxparams = {                 action: 'jp_ajax_request',                 name: name                 };                  jQuery.post( AdminAJAX, ajaxparams, function( response )             {                 alert(response);             });         }     }     </script>          <?php     add_action( 'wp_ajax_jp_ajax_request', 'jp_ajax_process');     add_action( 'wp_ajax_nopriv_jp_ajax_request', 'jp_ajax_process');          function jp_ajax_process()     {         echo 'ajax response';         die();     }     ?>          <form action="">         <input type="text" id="name">         <button id="test-button">Submit</button>     </form>


title: Display on page every post in blog WITH comments

text:
I am trying to create a page which displays **all** the posts in the blog, with the comments to each post listed below the respective post. By looking around the internet I figured out how to create a page template with the following code:                 <?php     $args = array( 'numberposts' => -1);     $posts= get_posts( $args );     if ($posts) {         foreach ( $posts as $post ) {             setup_postdata($post);             Echo "
"; the_title(); Echo "
";             Echo "
";the_time('jS F Y'); Echo "
";             the_content();         }     }     ?>      This works and an an happy with it. **But** I am stumped as to how to get the individual post _comments_ to appear as well. Everything I have tried so far doesn't work. Any help would be much appreciated. Thanks!


title: Change the edit page for a custom post type?

text: I've been looking for this all day and can't find it. I'm working on a custom contacts page and I am using the custom post type feature so that I can have more control over it. I'm looking to change the edit page to be a custom template, (example when I go to `/wp- admin/post.php?post=1234&action=edit`), I want it to show a custom page. I don't need any meta boxes or anything. Perhaps the editor, but near the bottom of the page (not at the default top). I've found how to remove the meta boxes, but I haven't found how to get a clean slate on the CPT edit page.               function remove_metaboxes(){         remove_meta_box('postexcerpt', 'obpcontacts', 'normal'); // Excerpt box         remove_meta_box('commentstatusdiv', 'obpcontacts', 'normal'); // Comment status box         remove_meta_box('commentsdiv', 'obpcontacts', 'normal'); // Comment box     }     add_action( 'add_meta_boxes', 'remove_metaboxes',11 );      Thoughts on how to create a custom template in the wp-admin edit section for my custom post type?


title: Search Query: how to construct a search string from two select elements?

text:
Im trying to create a wordpress search widget. The final search string Im trying to submit is made up of two keywords, one each from a select element. I'd like the final search query to be '/search.php?s=first-select- element,second-select-element Here's the HTML form code at present:               <form class="" method="POST" action="" id="search-box">

                         Make:                          <select name="make" id="make">                             <option value="1">1</option>                             <option value="2">2</option>                         </select>

                         Model:                          <select name="model" id="model">                             <option value="11">11</option>                             <option value="12">12</option>                         </select>

                         <input type="submit" class="btn" value="Search Motorcave">

                 </form>      I dont have any jQuery processing set up. I's like to avoid including any PHP in the header (every page) to detect and run this transformation, if possible - just return one clean string to Wordpress' search page. **I want the resulting query string from this form to end up like this:** (assuming the first item in each of the elements is selected):               http://example.com/?s=1,10      Does this make sense? What does everyone think the best method for achieving this is? A PHP processor in the head? Some crafty javascript that processes the form before submit, and concatenates the values into one new string? Any help on this is greatly appreciated! Rick, Melbourne AU.


title: How can I assign two post term with each other?

text: I have a custom taxonomy named "ingredients" which have terms "salt","egg", "sugar". And another taxonomy "measurements" which have terms "1 spoon", "500 gr", "one ons". I want to assign terms to each other. for each post. For ex. I writed a post "Some Meal", this post have terms of "salt" and "egg". I want to assign a value for the term "salt" to "1 spoon", only for this post. Is this possible? Maybe it can be by assigning terms with each other ( term "1 spoon" to term "salt") or it can be an text input for term "salt"?


title: Pagination issue in archive.php

text: I can´t get works fine the pagination in archives for wordpress when i want limite the posts by page , if i let pagination by default as 10 from backend i haven´t problems but if i use this no works               $wp_query->posts_per_page = 5;     if ( have_posts() ) : while ( have_posts() ) : the_post();      For example in other pages i can limit the posts by page without problems but in archive always have problems for paginate , or give errors 404 in some pages or paginate bad , etc Thank´s


title: Controlled publishing in Wordpress

text: We are currently rebuilding our corporate website and I'm looking for a way to control the publishing of pages. The flow to create or amend pages would be something like this: 1) New page is built or existing page is amended. 2) Page is promoted to a staging level where the business can review and approve layout or suggest changes. 3) Approval is received from business, page is added to a queue where it will be published at specific time. Any advice on this appreciated, I've done a bit of digging but haven't found anything that would work the way I want it. Regards...