title: Child theme functions randomly broke while editing a page -- no errors

text:
My client was editing pages in the admin area of their site, which is currently being hosted on my server. Two of them were logged in simultaneously, but that shouldn't matter. We're using a child theme of a premium theme. I'm a developer. I hadn't touched any files in hours and was not even around when they were editing. All of a sudden they say, all posts and pages were rearranged. Custom post type "portfolio" suddenly got moved to the regular post type (the blog), all pages disappeared (and thus caused 404s), etc. But upon inspecting the database, all is fine. I deactivated every plugin and the problem persisted. But then I switched the theme to twentyfourteen and the problem was GONE! I switched to the parent theme, the problem is also not there either, everything is in order. I repaired tables, I deleted and reuploaded the child theme, nothing is fixing it. On my local server, the problem does not exist with the child theme. I checked the functions.php, but how can anything be amiss there if it's working fine locally? So I am at a loss as to what could have possibly happened, but ironically, we were planning to launch the site tomorrow or the day after. Nothing like this has ever happened to me before, so I hope someone can help. Thank you so much! EDIT: I've identified that it is something in the functions.php of the child theme that is causing the problem, because if I delete the child functions.php, the problem resolves. But I'm stumped as to why this isn't a problem locally, and why the problem started hours after last editing code? If posting the code to the functions.php would help, I can do that. I also copied some of the code to the parent theme's functions, and there was no problem. EDIT: To add the code. Another developer suspects that custom_pre_get_posts was the problem. He commented out the code, and yes, that does fix the problem, but the client really needs the /portfolio-item/ slug to be dropped from the urls. I wonder if this part is conflicting only with the hidden-pages code I added? Either way, it is still a mystery why this code would function for weeks and suddenly break.               <?php          function evol_child_scripts() {     wp_enqueue_style( 'style', get_stylesheet_directory_uri() .         '/stylesheets/css/style.css' );           }     add_action( 'wp_enqueue_scripts', 'evol_child_scripts' );          /*function codex_custom_init() {     $args = array(       'public' => true,       'label'  => 'Hidden Pages'     );     register_post_type( 'hidden', $args );     }     add_action( 'init', 'codex_custom_init' );     */          /**      * Register a custom post type but don't do anything fancy      */     register_post_type( 'hidden', array( 'label' => 'Hidden Pages', 'public' =>         true, 'capability_type' => 'post',  'show_ui' => true, 'query_var' => true,        'supports' => array( 'title', 'editor', 'thumbnail' ) ) );     /**      * Remove the slug from published post permalinks. Only affect our CPT  though.      */     function vipx_remove_cpt_slug( $post_link, $post, $leavename ) {          if ( ! in_array( $post->post_type, array( 'hidden' ) )          || 'publish' != $post->post_status )         return $post_link;          $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );          return $post_link;     }     add_filter( 'post_type_link', 'vipx_remove_cpt_slug', 10, 3 );          /**      * Some hackery to have WordPress match postname to any of our public       * post types. All of our public post types can have /post-name/ as       * the slug, so they better be unique across all posts. Typically core       * only accounts for posts and pages where the slug is /post-name/      */     function vipx_parse_request_tricksy( $query ) {          // Only noop the main query     if ( ! $query->is_main_query() )         return;          // Only noop our very specific rewrite rule match     if ( 2 != count( $query->query )         || ! isset( $query->query['page'] ) )         return;          // 'name' will be set if post permalinks are just post_name,      // otherwise the page rule will match     if ( ! empty( $query->query['name'] ) )         $query->set( 'post_type', array( 'post', 'hidden', 'page' ) );     }     add_action( 'pre_get_posts', 'vipx_parse_request_tricksy' );          function remove_search_filter () {     remove_filter( 'pre_get_posts', 'tr_search_filter' );     }     add_action( 'init', 'remove_search_filter');          function remove_icons() {     wp_dequeue_style( 'icons' );     }          add_action( 'wp_enqueue_scripts', 'remove_icons' );          function tr_widgets_init_2() {          if ( ot_get_option( 'tr_sidebars' ) ) :         $tr_sidebars = ot_get_option( 'tr_sidebars' );         foreach ( $tr_sidebars as $tr_sidebar ) {             register_sidebar( array(                 'id' => $tr_sidebar["id"],                 'name' => $tr_sidebar["title"],                 'before_widget' => '
',                 'after_widget' => '
',                 'before_title' => '
',                 'after_title' => '
',             ));         }     endif;     };     add_action( 'widgets_init', 'tr_widgets_init_2' );               add_filter('post_type_link','custom_post_type_link', 10, 3);      function custom_post_type_link($permalink, $post, $leavename) {               $url_components = parse_url($permalink);          $post_path = $url_components['path'];          $post_name = end(explode('/', trim($post_path, '/')));               if(!empty($post_name)) {              switch($post->post_type) {                  case 'portfolio':                      $permalink = str_replace($post_path, '/' . $post_name . '/',          $permalink);                  break;              }          }          return $permalink;      }           function custom_pre_get_posts($query) {          global $wpdb;               if(!$query->is_main_query()) {              return;          }               $post_name = $query->get('name');          $post_type = $wpdb->get_var( $wpdb->prepare( 'SELECT post_type FROM ' .          $wpdb->posts . ' WHERE post_name = %s LIMIT 1', $post_name ) );               switch($post_type) {              case 'portfolio':                  $query->set('portfolio', $post_name);                  $query->set('post_type', $post_type);                  $query->is_single = true;                  $query->is_page = false;              break;          }               return $query;       }                 add_action('pre_get_posts','custom_pre_get_posts');          function fb_add_search_box ( $items, $args ) {          // only on primary menu     if( 'primary' === $args -> theme_location )         $items .= '
' . get_search_form(          FALSE ) . '
';          return $items;     }      add_filter( 'wp_nav_menu_items', 'fb_add_search_box', 10, 2 );          // Callback function to insert 'styleselect' into the $buttons array     function my_mce_buttons_2( $buttons ) {     array_unshift( $buttons, 'styleselect' );     return $buttons;     }     // Register our callback to the appropriate filter     add_filter('mce_buttons_2', 'my_mce_buttons_2');          // Callback function to filter the MCE settings     function my_mce_before_init_insert_formats( $init_array ) {       // Define the style_formats array     $style_formats = array(           // Each array child is a format with it's own settings         array(               'title' => 'Image Text',              'block' => 'p',               'classes' => 'image-text',              ),           array(               'title' => 'Image Text no Overlay',              'block' => 'p',               'classes' => 'image-text-2',              ),           array(                'title' => 'w/ gray background',              'inline' => 'span',               'exact' => true,                  'classes' => 'gray-background',          ),           array(                'title' => 'w/ white background',              'inline' => 'span',               'exact' => true,                  'classes' => 'white-background',          ),           array(               'title' => 'Image Text no Indent',              'block' => 'p',               'classes' => 'image-text-3',              ),          array(                'title' => 'Button',              'inline' => 'a',               'exact' => true,                  'classes' => 'button small',          ),           array(               'title' => 'Blog Image Caption',              'block' => 'p',               'classes' => 'caption',              ),          array(                'title' => 'Signature',              'inline' => 'span',               'exact' => true,                  'classes' => 'sign',          ),     );       // Insert the array, JSON ENCODED, into 'style_formats'     $init_array['style_formats'] = json_encode( $style_formats );            return $init_array;            }      // Attach callback to 'tiny_mce_before_init'      add_filter( 'tiny_mce_before_init', 'my_mce_before_init_insert_formats' );


title: Media upload freezes according to metabox order

text: I created a custom post type and 3 metaboxes for it in the admin section. It looks great and the admin panel for that custom post has, indeed, the 3 boxes. These boxes have all the same code (with a simple change of indentation in the functions names in order to avoid any conflict) and they each are supposed to allow the user to upload a picture. My problem is that, the first metabox always freezes on the upload while the two others work just fine. When I try to upload a picture through the fist metabox, the media-uploader popup shows up, the drag n' drop and preview features are ok (the picture is loaded) but when I try to validate the upload, the tb_close() event never happens. Basically, it freezes... First I thought that my first metabox was badly coded which is weird as it is a clone of the two others but after some tests, I realized that if I swap the order of the metaboxes in the admin panel, the first metabox is always failing while the two others are working just fine. This means that any of the three metaboxes will work or not, depending on its position in the admin panel. This is strange as it tends to prove that it is not related to the code of the metaboxes themselves so I'm stuck as I don't know where to look to debug the issue. Any help would be appreciated. PS: I don't plan to use a plugin for the metaboxes as this website is 90% done and already uses about 25 hand-made custom metaboxes that work very well. FYI: the metaboxes here above are already used in other custom post types with success. The only difference is that this is the first custom post type with more than 2 uploaders at once whithin the same admin panel.


title: Limit permissions for authors' fields in Types Custom Field

text: At a bit of a loss. Took over a WordPress project from outsourced coders who left the project a mess. My issue is this: We have a number of authors who can post using a custom type of post created in the 'Types' plugin. In this custom post form, there is a selection box on what 'author' to associate the post with. Yes, you read that correctly. The form is currently set up so that there is no link between post and author. All of our posts are being generated via this custom post form. Is there any way I might be able to lock the selection box to match the intended author, or should I just look into creating a new post form and scrap this one? Thanks.


title: Using POST method in meta box, no results

text:
I'm having trouble figuring out what's going wrong with my code. I created a meta box for a custom post type (project) that adds people to the project via the edit project page. The box also displays the users who have been added to the projects, but the POST method doesn't seem to be working so none of the code that inserts the data into the database occurs. I tried to echo a value from the form but there is no result so I know the post method is not working. I checked for syntax errors as well. Here is the code for the POST method once form is submitted -               <?php     // Process add form if sent               if(isset($_POST['mro_add_user'])) {                   $_POST = stripslashes_deep($_POST);                   $add_username = $_POST['mro_add_user'];                   if (username_exists($add_username) != NULL) {                     // Check not already registered                     $add_userid = username_exists($add_username);                     $extra_userdata = get_userdata($add_userid);                     $add_firstname = $extra_userdata->first_name;                     $add_lastname =  $extra_userdata->last_name;                     $a_registered = $wpdb->get_var("SELECT user_id FROM ".$wpdb->prefix."mro_attendees WHERE event_id = ".$project_id." AND user_id = ".$add_userid);                     // If not already registered                     if ($a_registered == "") {                         $user_comment = $_POST['mro_add_comment'];                         $wpdb->insert($wpdb->prefix.'mro_attendees', array( 'event_id' => $project_id, 'user_id' => $add_userid, 'first_name' => $add_firstname, 'last_name' => $add_lastname, 'user_comment' => $user_comment ) );                         ?>

<?php _e('User ' . $add_username . ' added.' ); ?>

                         <?php                     } else {                         ?>

<?php _e('User ' . $add_username . ' already on list.' ); ?>

                         <?php                     }                 } elseif(username_exists($add_username) == NULL) {                     ?>

<?php _e('User ' . $add_username . ' not found.' ); ?>

                     <?php                 }                    }               ?>      And here is the form that has the action both of these are in the same code document.               <form id="add_user" name="add_user" method="post" action="post.php?post=<?php echo $project_id; ?>&action=edit">
                                      Username
       <input name="mro_add_user" type="text" id="mro_add_user" size="40" maxlength="150" />

Comment
                                      <input name="mro_add_comment" type="text" id="mro_add_comment" size="40" maxlength="40" />

                   <input type="submit" name="mro_add_user_submit" id="mro_add_user_submit" value="Add User" />
       </form>      I have a GET method for something else in this code that does work.               <a href="post.php?post=<?php echo $project_id; ?>&action=edit&remove_attendee=<?php echo $user->id; ?>&place=<?php echo $num; ?>">Remove User      I'm just confused as to why the GET method works but POST doesn't? Is this something that meta box can't do? Is there another way I can do this in the meta box? Any help or insight would be greatly appreciated!


title: WPAlchemy Metabox rewriting slug

text:
So here's my problem: I've created a Custom Post Type called "Projects". I've successfully added several metaboxes via WPAlchemy already. Those work fine. Where I'm having a problem is when I create a metabox with checkboxes for Related Projects, I can list out all the Project titles with checkboxes, but when I choose at least one and save the Custom post, it rewrites the Slug. I'm assuming it's because I'm calling `<?php the_title(); ?>`. Here is my code for the meta PHP file:

Add or subtract Athena projects related to this project.
          Available Projects
          <?php          $items = new WP_Query(array(                 'post_type' => 'athena_project',                  'posts_per_page' => 1000         ));          while ( $items->have_posts() ) : $items->the_post();     ?>             <input type="checkbox" name="<?php $mb->the_name(); ?>" value="<?php echo the_title(); ?>"/><?php the_title(); ?>
         <?php endwhile; wp_reset_query(); ?>
         <input type="submit" class="button-primary" name="save" value="Save" />
      Does anyone have a good suggestion for getting around this problem?


title: Sorting Custom Posts by Custom Field

text:
I'm currently trying to sort custom post types called 'Donors' by the 'County' they live in. I have a custom field setup called County that they can fill in on the Donor post. Is it possible to echo the County name and sort all the custom donor posts with that County name under it in alphabetical order? So it'd look like this: Grant County <---- custom field called 'County' not a link   * Lesner, Brock <---- links to custom post type (donors) (title of post)   * Mathias, Carl Kanwha County   * Applegate, Christy    * Snow, John Here's my current loop:               <?php $custquery = new WP_query (         array(         'post_type'=> 'Donor',         )     );          while ( $custquery -> have_posts() ) : $custquery -> the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
          <?php          endwhile;             wp_reset_query();  ?>


title: How to get list of posts from permalinks?

text: I am using an API which tracks metrics on parts of my site. The only useful bit it saves though is the URL (permalink). What is the most efficient way to query up all the posts that match those permalinks, given the fact that I don't have access to the ID's to use `post__in` with `WP_Query`.


title: Include a php file that is above WP installation hierarchically?

text: I've come across a number of ways to call the WP "root" folder But what if I want to include a php file that is in a parent folder of WP? Example http://www.site.com/, where the WP blog is in http://www.site.com/blog/ So far I can't find anything on this topic, and including the absolute URL to the file isn't working


title: Search template error when search is path ?s=

text:
When make a search the path is www.xxxx.com?s=xxxx. This retrieve an error: Notice: Trying to get property of non-object in /home/codetoco/public_html/wp- includes/post-template.php on line 29. If I change "s" by "search" it don`t retrieve an error, but it show a previous version of the template. In the seach form I use name="s". Nobody knows what happens? Searchform.php               <form action="<?php echo home_url(); ?>/" class="searchform" method="get">         <input type="text" name="s" class="search form-control" value="<?php _e('Search...') ?>" onfocus="if(this.value=='<?php _e('Search...') ?>') this.value=''" onblur="if(this.value=='') this.value='<?php _e('Search...') ?>'"/>      </form>      Search.php               <?php get_header(); ?>

                            <?php if ( have_posts() ) : ?>
<?php printf( __( 'Search Results for: %s', 'pukka' ), '' . get_search_query() . '' ) ?>
                              <?php while (have_posts()): the_post(); ?>                                  <article id="post-<?php the_ID(); ?>" <?php post_class('blog-item') ?>>             <?php if (has_post_thumbnail()) { ?>
                 <a href="<?php the_permalink() ?>"><?php the_post_thumbnail('quins-1000', array( 'class' => "img-responsive" ) ) ?>
             <?php } ?>

                         <?php echo quins_display_date_link () ?>

                         <a href="<?php comments_link(); ?>"><?php comments_number( esc_html__('0 comments', 'quins' ), esc_html__( '1 comment', 'quins' ), esc_html__('% comments', 'quins') ); ?>

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

                          <?php _e('Posted by ', 'quins' ) ;  the_author_posts_link() ?>

                         <?php _e( 'In ', 'quins' ) ; the_category(', ') ?>

                   <?php the_excerpt() ?>
                      <a href="<?php the_permalink() ?>" class="btn-border"><?php echo esc_html( $quins_opt['excerpt_more_link'] ) ?>

                              <?php endwhile; ?>                                  <?php echo quins_pagination(); ?>                              <?php else : ?>                                  <?php get_template_part('content', 'none'); ?>                              <?php endif; ?>

                                             <?php get_sidebar(); ?>

                <?php get_footer(); ?>


title: Plugin custom Action Hook not working

text: I am trying to create one basic plugin where I want to create my own action hook. Here is the code for the same.               <?php     /*     Plugin Name: Demo Plugin     Version: 1.0     */          do_action('basic_action_demo');     ?>      Now after activating this plugin I want to use this action hook in my current theme's function.php file, code for the same is as below:               add_action('basic_action_demo','action_demo');          function action_demo()     {         echo "I am inside";     }      Now the problem is my hooked action never gets called, we can see that do_action is called unconditionally so it will be called on each page load but it never gets into "action_demo" method. What I have figured out far is plugin is loaded before my theme'e function.php file is executed. So here do_action is called first and then add_action. A hint would be really appreciated. Update: Below plugin action works.               <?php     /*     Plugin Name: Demo Plugin     Version: 1.0     */          add_action('basic_action_demo','action_demo');     do_action('basic_action_demo');          function action_demo()     {         echo "I am Inside";         die;     }     ?>


title: Display multiple page contents under single page

text: Is it possible to display the content of all the pages under a single page?? Like, I have Home, About and Contact us pages. I want all of its contents to display under a single frontend page. Is it possible and how can we do it?


title: Any easy way to automatically set the first inline image in a post as the thumbnail, for relative images?

text: I stumbled upon a problem in this post if you use a link like i.e. a relative URL, it won't work is there a neat trick around this problem? this solution should be URL independent. I.e. use a php snippet to get current url in the place of ../ ?


title: Wordpress MU - Creating a site takes ages

text: I have 2 dedicated servers. I have Wordpress MU on both. When I try to create a site   1. WP MU 1 on server 1 does it in 3-5 seconds    2. WP MU 2 on server 2 does it in 45-50 seconds What can cause this delay? How can I debug PHP and MySQL? PS: Both WP MU are test installations. No plugins activated. Both OS are CentOS.


title: Strange Deadlock database error for the query "Delete From wp_options"

text: I'm experiencing a strange Database error in these days, and it could the the cause of the slowness of my website (tasc.it) in these days. I found this error in the PHP error log, I can see about 4-5 times every day, without a logical time distribution. (I translated the error from italian to english) > WordPress database error Deadlock found when trying to get lock; try > restarting transaction for the query DELETE FROM tb_options WHERE > option_name = '_transient_doing_cron' executed by require('D:\tasc\wp-blog- > header.php'), require_once('D:\tasc\wp-load.php'), require_once('D:\tasc\wp- > config.php'), require_once('D:\tasc\wp-settings.php'), do_action('init'), > call_user_func_array, wp_cron, spawn_cron, get_transient, delete_option What does it mean? How can I solve it? I have PHP 5.5, MySql 5.6 both recently upgraded, and Wordpress 3.9.1.


title: How to embed custom HTML code with no plugins?

text: I'm trying to embed this code into a post:               <script src="http://www.stokerposter.com/swfobject.js"></script>     <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="422" height="750">         <param name="movie" value="http://www.stokerposter.com/Stoker_Poster_04.swf" />         <!--[if !IE]>-->         <object type="application/x-shockwave-flash" data="http://www.stokerposter.com/Stoker_Poster_04.swf" width="422" height="750">         <!--<![endif]-->           <img src="http://www.stokerposter.com/Stoker_Poster.jpg" alt="" />         <!--[if !IE]>-->         </object>         <!--<![endif]-->     </object>      But the result in the preview always falls back on the image, and the comment tags `<!--` are visible for some reason. Is there any way to embed this without a plugin? Thanks


title: Allow Profile HTML for select users

text: I know there are a ton of post out there about how to allow html in profiles. Most of these warn about the security risk of doing so. My thinking is there has to be a way to only allow users to use html for certain users. I tried this but It doesn't work. I think it's because you can't remove a filter from inside a filter. Any help would be awesome.               add_action('edit user profile update', 'nifty_strip_html');           function nifty_strip_html($user_id) {          if ($user_id == 2){             //if user id is 2 then allow html             remove_filter('pre_user_description', 'wp_filter_kses');                  }           else{                 return; //keep the filtered html           }       }


title: Combining multiple javascript and css files

text: Is there any plugin which can automatically combine all the javascript and css files that are used on a page? While I can combine them manually I would like to avoid them as some plugins add their scripts and css. Also different scripts might be needed on different pages so I do not want to have one large script on every page. I am not looking for gzipping, minifing or cache-control as I already have them implemented. Thanks.


title: Show the First Post from Each of 3 Different Post Types on a Web Page?

text: I have 3 different custom post types: 1.) `"events"`, 2.) `"winners"` and 3.) `"offers"`. How would I go about retrieving the first (latest) post in each of these post types on a single web page (i.e a home page). Would I use `get_posts()` or would I have to manipulate `the_loop()`?


title: Unable to load "wpColorPicker" on theme customize page

text: Whether I'm using a Wordpress default theme or a custom one, I see the JS error: `Uncaught TypeError: Object [object Object] has no method 'wpColorPicker'` when I click "Customize" on the theme. I've also noticed that on the widgets page nothing is draggable. I believe these issues may be related as I just moved this site to a new server. I've verified all files are chmod `755`. I'm a bit unfamiliar with the inner workings of Wordpress. Is there a debug mode or something I can enable? I recognize with the widgets I can enable accessibility mode, but the bigger issue there is I can't Customize my theme due to the JS error. _I've verified that this error persists when all plugins are disabled_


title: Give users acces to admin a single post or set up WP network?

text: I have a directory styled site in which companies are listed. I would like to give the owners of the companies(the ones on my site) the option to take control of the content in their company entry. Some entries would still be controlled by myself. The question arises should I give owners admin access to their respective entry through user roles and some custom plugin code, or set up a WP multi- user site/network. Not sure how the WP network works in great detail but figured I would ask for opinions. I'd need to transfer the site over to the network version somehow, or set a function to go to the Network site if one exists for that company/entry. Not sure how that would work. Things I need the owners to be able to do: Update Categories, images, pot thumb nails and content(includes some additional met boxes with text input) as well as several other meta boxes. While I can still control content on the entries without an external admin. Thanx for any and all help/opinions in advance


title: How can I modify the Capability needed to access a plugin's options?

text: I have the following **3 different Roles** : `Admin`, `Editor`, and `SEO`. I have installed WordPress SEO by Yoast, and I want to get this:   * **I don't want the editors to see the SEO options** , because they only write posts and don't know about SEO. There is a person with the `SEO` role, who will do the optimization.   * **I don't want the SEO person to see other plugins options**. I just want to have the same capabilities that Editors, but with the SEO functions enabled. I have been trying with some snippets from this site, and I am able to hide the _meta box_ to the `Editors`, but **not the little 'rating box' over the _Publish_ button**. Also I don't know how to deal with the second point, because all the plugins uses the same `manage_options` capability, so I can't assign that capability to the `SEO` role. And **I don't know how to change the capability needed** without modifying the plugin files (what will be lost on plugin update). Thanks in advance.


title: Link to search page without search parameter

text: I'm a bit stuck with my actual project. Actually I wanted to link a search icon to the search page (where there's a form & the results). Actually I tried to link like this: `/project/?s=` but it redirects to the index page when `s=` empty - when I assign a parameter like `s=ipsum` it directs to the search page with its results. Is there a way to link to the search page with a clean URL (without doing a search)?


title: How to order by just the Time Field in Advanced Custom Fields

text:
I'm using Advanced Custom Fields to create a class schedule. I need to get the time field to sort correctly to display the class schedule in the correct order. Currently it is not, and I don't understand what I need to do to get it sorting correctly. Here is the live link: http://studio34yoga.com/yoga-movement/class-schedule/ You can see on Monday that the classes are not in the correct order. "start_time" is my time picker field that I am hoping to sort on. What follows is an abridged version of my PHP code. Any help is appreciated.               <?php          $args = array( 'post_type' => 'Classes', 'posts_per_page' => 70, 'meta_key' => 'start_time', 'orderby' => 'meta_value_num', 'order'=>'ASC' );            $loop = new WP_Query( $args );               while ( $loop->have_posts() ) : $loop->the_post();          if(get_field('day') == "2monday") :          {         echo '
';         echo get_field('start_time');         echo ' - ';         echo get_field('end_time');         echo '
';     }          endif;          endwhile;          ?>


title: Count post views in loop

text: I'm trying to show the post views for every post on a blog page (so in a loop). I tried it with the following code in the functions.php:                 // function to count views.     function setAndViewPostViews($postID) {         $count_key = 'views';         $count = get_post_meta($postID, $count_key, true);         if($count==''){             $count = 0;             delete_post_meta($postID, $count_key);             add_post_meta($postID, $count_key, '0');         }else{             $count++;             update_post_meta($postID, $count_key, $count);         }         return $count; /* so you can show it */     }      Then in the loop function I used this code:               <?php echo setAndViewPostViews(get_the_ID());  ?>      However, every post gets a count added every time the blog page is reloaded, strange thing is that the id is different for every post. How can I make this it will only count the every posts? And, if possible, how would I make it so that it only counts every individual views? Thanks in advance! Btw. I know there are a lot of plugins that do this, it's not my intention to use one, so please don't suggest a plugin.


title: Data validation

text: I find Data Validation page on Codex a bit confusing. It highlights what all functions do but not how one differs from another and which one should be the right choice in a particular use case. Like earlier, Rarst created an awesome chart to show the difference between `WP_Query`, `query_posts()`, `get_posts()` and it was so much easy to understand the difference among them & I could point anyone to that chart to make them understand the difference. Examples of different validation functions will help developers understand them better and not leave them confusing to an extent. Having it sounds like a good idea?


title: Membership & Event Registration/Management plus-ins for non-profit

text: I maintain the website for a non-profit organization for historians/archivists. I'm migrating a static HTML site to WP. One of the main reasons for the transition is to utilize plugins for membership mgmt. and event registration. The free plugins in both these areas have not been all that user-friendly, so I'm looking for recommendations for plugins that achieve these goals. I need PayPal integration, not so sure about credit card transactions. One main problem I have in selecting a free/premium membership plugin is that I'm not trying to create premium content or a firewall. Our members haven't expressed in features such as: forums, member directories, etc.), so I'm really looking for a plugin(s) which let me and event planners facilitate event registration & mgmt., and creation/renewal of memberships & paying dues. I've looked at Event Espresso, S2Member, WP-Member, Magic Members, and played with all the free plugins. If I'm going to write a request for funds to purchase premium plugins to make these tasks easier, what plugins have any of you had success with? Thanks a lot for any advice.


title: Responsive dropdown menu with smaller screen sizes

text:
Working on a theme template and trying to make the menu responsive, so that it will change from a horizontal layout into a block format at a certain screen resolution. I have tried one tutorial which I couldn't get to work, lack of experience on my behalf but also a little unsure how to implement in to WordPress as the menu is generated dynamically, and the tutorial was based on a fixed HTML structure menu. Now attempting a second but hitting a wall at the moment, hence my question. The tutorial I am following is located below, the author has been helpful but I don't want to push his patience. I have some comments on his blog, which explains a little but will reiterate all below. http://www.justinwhall.com/responsive-drop-down-menu-with-css-media-queries- jquery/#comment-8391 I have copied his Java script into a file called mobile-menu.js then registered and enqueued this in the correct way within functions.php I am using a test website http://www.simples.net23.net The CSS I am using is as follows:               /*=========== helper classes =====================*/     p.mobile-nav {       display: none;       margin-bottom: .5em;       font-size: 1.4em !important; }     p.mobile-nav span {       font-size: 1.3em; }     .mobile li {       display: block;       width: 43%;       border-bottom: 1px solid #ccc;       float: left;       padding: 10px 0;       font-size: 1.2em;     }     @media only screen     and (max-width : 768px) {       p.mobile-nav {       display: block; }     }      I haven't placed all the Java code here as it's about 30 lines, and is possibly better read on his blog. Below is some of the code from my `header.php` file, regarding the menu:
                Menu +     <?php   /* Adding the menu called 'main' to the header, within HTML5 tag */     wp_nav_menu( array( 'theme_location' => 'main' ) );     ?>
                I think my issue lies with my HTML and CSS, and using the correct selectors so the Java script can work it's magic. I have looked at the generated menu with Firebug, but as it's generated by WordPress having a bit of an issue understanding the structure, and then the correct selectors to use. Cheers, Ant


title: Change media URL (images)

text: Similar questions have been posted, but none have been resolved. I'm looking to, programmatically on upload, change the URL of a media file to its URL on a CDN. I.e. modify site.com/wp-content/uploads/file.jpg to be cdn.site.com/wp- content/uploads/file.jpg. Essentially what I'm asking is: which hook should I tie into? If anybody has more code help, that's great, but I think hook is the big question. People before seem to have been wondering this, so I think it'll be helpful to resolve. Note also: I'm aware that W3 Total Cache and other plugins do this; I'd actually like it changed in the database (not just filtered on post render/output), and need to use some of my own logic, so I need to code snippet in my code. Many thanks.


title: How to to stop html editor from addig <p> tags to shortcodes, images, etc

text: I know this this is covered as individual topics but What I am looking for is a single function that stops `<p>` tags from being wrapped around via the Wordpress editor to shortcodes and images and also removes empty `<p>` tages, for example:   * remove `<p>` tags that get wrapped around shortcodes, i.e., `<p>[shortcode]</p>`   * remove empty `<p></p>` tags   * remove `<p>` tags with whitespace, i.e., `<p> </p>` or `<p> </p>` etc.   * remove `<p>` tags that get wrapped around `<img>` tags, i.e., `<p><img blabla /></p>` I have been using a few different functions that take `$content` and strips out the `<p>` tags via `preg_replace()` but I can not figure out how to get all four requirements to work in a single function. Its seems like too much overhead to run `$content` through four different functions before `$content` is displayed. Also can you recommend a good source to learn how to use all the agreements for preg_replace()?


title: Hook into the rendering of a WordPress Template

text: I have to use WordPress as some meta templating system and include some `JSP` snipptes which will be evaluated later with Tomcat after rendering the page statically. But naturally the `JSP` Code could not be interpreted by the php parser. This results in plain text strings mixed with the interpreted template parts. **Is there any way to hook into the (pre) rendering of a WordPress Template?** I need way get access the rendered template so i can strip out the `JSP`-Tags. Maybe wrapped between some unique tags or something else. But this ist not part of this question. ## Example               <?php get_header(); ?>          <render:jsp>         <%= request.getParameter("title") %>     </render:jsp>          <?php get_footer(); ?>


title: problem saving/ retrieving custom meta with wp alchemy metabox

text: I am using WPalchemy metabox class to add a extra meta field to the pages editor which will allow me to attach galleries to pages. I use the class:               $gallery_metabox = new WPAlchemy_MetaBox(array(         'id' => '_gallery_meta',         'title' => 'Gallery',         'template' => STYLESHEETPATH . '/inc/custom/gallery_meta.php',         'types' => array('post', 'page', 'events'),         'priority' => 'high',             'lock' => WPALCHEMY_LOCK_AFTER_POST_TITLE     ));      Here's my gallery_meta.php:               <div class="my_meta_control">      <?php $metabox->the_field('attachedGallery'); ?>         <label>Attached gallery </label>         <p>                  <select name="<?php $metabox->the_name(); ?>">             <option value="0">select gallery</option>                    <?php             //global $post;             $selected = 'selected="selected"';             $args = array( 'post_type' => 'galleries', 'posts_per_page' => 999, 'orderby' => 'title', 'order' => 'ASC' );             $loop = new WP_Query( $args );             while ( $loop->have_posts() ) : $loop->the_post();?>                 <option value="<?php the_ID(); ?>" <?php echo $mb->is_value(get_the_ID())? $selected :''; ?>><?php the_title(); ?></option>             <?php endwhile; wp_reset_query(); ?>             </select>         </p>          </div>      The input field appears in the WP admin for posts/ pages and events. When I save the value it seems it doesn't save. I checked the mysql db and for this particular page I am testing there is a row with: meta_key `_gallery_meta` meta_value `a:1:{s:16:"attached-gallery";s:3:"109";}` I can't retrieve the value of the $gallery_metabox or make the select element mark the option as selected though. Can anyone help?


title: What is wrong with this dbDelta syntax?

text: I know there's a million questions about this, but I've searched a bunch and haven't found any solutions that fix my problem. This is the function which I hook upon plugin activation:               global $wpdb;     $src = $wpdb->prefix . "source";     $via = $wpdb->prefix . "via";     require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );     $query = "CREATE TABLE " . $src . "(             source_index bigint NOT NULL AUTO_INCREMENT,                         post_id bigint,                         source_id int,                         source varchar(100),                         source_title varchar(100),                         PRIMARY KEY  (source_index)                 );";         dbDelta($query);     $query = "CREATE TABLE " . $via . "(             via_index bigint NOT NULL AUTO_INCREMENT,                         post_id bigint,                         via_id int,                         via varchar(100),                         via_title varchar(100),                         PRIMARY KEY  (via_index)                 );";         dbDelta($query);      It does nothing at all, and I don't understand why. I thought for certain that I'd corrected all issues. Any assistance would be appreciated.


title: Wordpress Native Function To Show Publish Box, Select Categories Form etc On Plugin Page

text: ![enter image description here](http://i.stack.imgur.com/ttsZU.jpg) The picture above showing the default forms those are available on metabox of wordpress post/page editor screen. Is there a wordpress native function to show those forms on a custom plugin page outside of metabox? Best Regards


title: Why I can't load my JavaScripts using an hook inside my functions.php file?

text: I am pretty new in WP (I came from Joomla) and I have the following problem: I am carrying this pure HTML theme (that use BootStrap CSS framework) into a WordPress theme. This is the original pure HTML demo theme (I have the entire source code because it is a downlodable example): http://www.html.it/guide/img/bootstrap/demo/home.html And this is my personal WP theme on wich I am working on: http://onofri.org/WP_BootStrap/ As you can see the only difference from the original demo website and my personal WP theme is that in the second one the JavaScript is not loaded (so the upper horizontal main menu can't work well and the header SlideShow is fixed on a single immage) I have do the following operations: 1) In my **footer.php** file I have disabled the JavaScript loading commenting them, in this way:                       <!--             <script src="http://code.jquery.com/jquery.js"></script>             <script src="/wordpress/wp-content/themes/AsperTheme/assets/bootstrap/js/bootstrap.min.js"></script>             <script src="/wordpress/wp-content/themes/AsperTheme/assets/plugins/flexslider/jquery.flexslider.js"></script>             <script src="/wordpress/wp-content/themes/AsperTheme/assets/plugins/fancybox/jquery.fancybox.pack.js"></script>             <script src="/wordpress/wp-content/themes/AsperTheme/assets/js/scripts.js"></script>             -->      2)I have insert the following code into my **functions.php** file to load all the previous JavaScript using the WP standard way:               /* Function automatically executed by the hook 'load_java_scripts':      * 1) Load all my JavaScripts      */     function load_java_scripts() {              // Load JQuery:         wp_enqueue_script('jquery');         // Load bootstrap.min.js:         wp_enqueue_script('bootstrap.min-js', get_template_directory_uri() . '/assets/bootstrap/js/bootstrap.min.js', array(), 'v3.0.3', true);         // Load FlexSlider JavaScript         wp_enqueue_script('flexSlider-js', get_template_directory_uri() . '/assets/plugins/flexslider/jquery.flexslider.js', array(), 'v2.1', true);         // Load FancyBox:         wp_enqueue_script('fancy-js', get_template_directory_uri() . '/assets/plugins/fancybox/jquery.fancybox.pack.js', array(), 'v2.1.5', true);         // Load scripts.js:         wp_enqueue_script('myScripts-js', get_template_directory_uri() . '/assets/js/scripts.js', array(), '1.0', true);         // Load Modernizer:         wp_enqueue_script('myodernizer-js', get_template_directory_uri() . '/assets/js/modernizr.custom.js', array(), '2.6.2', true);          }     add_action('wp_enqueue_scripts', 'load_java_scripts');      But as you can see seem that the JavaScript is not loaded and can't work. If I enamble the JavaScript loading inside my **footer.php** file (deleting the comments) it work well but I think that in WP this is not a good way to use. What am I missing? What is it wrong?


title: Unregistering custom tinymce plugin?

text: I want to unregister a custom tinymce plugin in one of my child themes. The custom tinymce plugin uses basically: http://codex.wordpress.org/Plugin_API/Filter_Reference/mce_external_plugins excerpt:               add_filter( "mce_external_plugins", "foo_add_buttons" );     add_filter( 'mce_buttons', 'foo_register_buttons' );      What is the best way to remove this such that performance is the best? The two options I came up with are:   1. remove_filter("mce_external_plugins"); & remove_filter( 'mce_buttons', 'foo_register_buttons' );?   2. add_filter('tiny_mce_before_init', 'disable_mce_buttons'); and simply remove the buttons that the parent theme adds?


title: Hide custom metabox value from custom fields

text: Before I ask the question, I tried to added _ to the custom field, but it's not working, at least with my code. I just want to hide the value of my meta box from appearing in the custom fields. When I added _ to the code, the metabox stopped working. Here's the code:               //Creating a MetaBox for Posts to enter audio Code.     add_action('add_meta_boxes','audio_meta_box');     function audio_meta_box(){         add_meta_box('audio_box_id', 'Enter Audio ' , 'audio_box_cb','post','normal','default');     }     function audio_box_cb($post){         $value = get_post_meta($post->ID,'_audio_box',true);              echo '<textarea rows="1" style="width: 98%;" id="audio_box", name="audio_box">';             echo $value;         echo '</textarea>';     }          add_action('save_post','save_audio_box');     function save_audio_box($post_id){         $box_data = $_POST['audio_box'];         update_post_meta($post_id,'_audio_box',$box_data, true);     }


title: Possible to hide parts of the slug from get_template_directory_uri and bloginfo('template_directory')

text: At the moment i am running and building a wp site on a local install with mamp. Additionally i have moved the wp files from the root directory to a folder. i've included files then e.g. with               <?php $url = get_template_directory_uri(); ?>      or               <link rel="apple-touch-icon" href="http://localhost:8888/myhomepage/vHGNd37wDb/wp-content/themes/mytheme/touchicon.png">      but if i take a look at the resulting html source of the latter i get               <link rel="apple-touch-icon" href="http://localhost:8888/myhomepage/vHGNd37wDb/wp-content/themes/mytheme/touchicon.png">      somehow i hoped the wp-content wouldn't show up and also the move of the wp files from the root to the vHGNd37wDb folder seems useless if that directory name is visible to everybody. :/ Is the latter cuz i am on a local install right now? So would it be possible to prevent both from showing up? best regards ralf


title: Change display wp post type to wp custom post type

text:
i have this code below to display wp post based on category but what i want to display wp custom post called 'wiki' based on its category. CPT wiki is from plugin, so i think already defined.               class Pyre_Homepage_1col_Widget extends WP_Widget {          function Pyre_Homepage_1col_Widget()          {         $widget_ops = array('classname' => 'pyre_homepage_1col', 'description' => 'Homepage 1-column recent posts widget.');         $control_ops = array('id_base' => 'pyre_homepage_1col-widget');         $this->WP_Widget('pyre_homepage_1col-widget', 'Avenue Theme: Home 1-column', $widget_ops, $control_ops);     }          function widget($args, $instance)          {         extract($args);         $title = $instance['title'];         $post_type = 'all';         $categories = $instance['categories'];         $posts = $instance['posts'];         $images = true;         $rating = true;         $show_excerpt = isset($instance['show_excerpt']) ? 'true' : 'false';              echo $before_widget;         ?>         <?php         $post_types = get_post_types();         unset($post_types['page'], $post_types['attachment'], $post_types['revision'], $post_types['nav_menu_item']);         if($post_type == 'all') {             $post_type_array = $post_types;         } else {             $post_type_array = $post_type;         }              ?>

<a href="<?php echo get_category_link($categories); ?>"><?php echo $title; ?> »
             <?php             $recent_posts = new WP_Query(array(                 'showposts' => $posts,                 'cat' => $categories,             ));             ?>             <?php             $big_count = round($posts / 9);             if(!$big_count) { $big_count = 1; }             ?>                  <?php $counter = 1; while($recent_posts->have_posts()): $recent_posts->the_post(); ?>             <?php             if(has_post_format('video') || has_post_format('audio') || has_post_format('gallery')) {                 $icon = 'ID) . '-icon">';             } else {                 $icon = '';             }             ?>                  <?php if($counter <= $big_count): ?>             <?php if($counter == $big_count) { $last = 'block-item-big-last'; } else { $last = ''; }?>                  <div class="block-item-big <?php echo $last; ?>">                 <?php if($images && has_post_thumbnail()): ?>                 <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'widget-image'); ?>
<a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>" width='290' height='160' /><?php echo $icon; ?>
                 <?php else: ?>
<a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php bloginfo('template_directory'); ?>/images/thumbnail.png&w=290&h=160" alt="<?php the_title(); ?>" width='290' height='160' /><?php echo $icon; ?>
                 <?php endif; ?>
<a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><?php the_title(); ?>

<?php echo ' - ' ?><?php the_time('F j, Y'); ?>
                 <?php if($show_excerpt == 'true'): ?>
<?php echo string_limit_words(get_the_excerpt(), 15); ?><a href='<?php the_permalink(); ?>'> [...]
<?php endif; ?>
                  <?php else: ?>

<?php echo the_time('d/n'); ?><?php echo ' - ' ?><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><?php the_title(); ?>

                  <?php endif; ?>                  <?php $counter++; endwhile; ?>
              <?php         echo $after_widget;     }          function update($new_instance, $old_instance)     {         $instance = $old_instance;         $instance['title'] = $new_instance['title'];         $instance['post_type'] = 'all';         $instance['categories'] = $new_instance['categories'];         $instance['posts'] = $new_instance['posts'];         $instance['show_images'] = true;         $instance['show_rating'] = true;         $instance['show_excerpt'] = $new_instance['show_excerpt'];              return $instance;     }          function form($instance)     {         $defaults = array('title' => 'Recent Posts', 'post_type' => 'all', 'categories' => 'all', 'posts' => 4, 'show_excerpt' => null);         $instance = wp_parse_args((array) $instance, $defaults); ?>
             <label for="<?php echo $this->get_field_id('title'); ?>">Title:             <input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" />

             <label for="<?php echo $this->get_field_id('categories'); ?>">Filter by Category:              <select id="<?php echo $this->get_field_id('categories'); ?>" name="<?php echo $this->get_field_name('categories'); ?>" class="widefat categories" style="width:100%;">                 <option value='all' <?php if ('all' == $instance['categories']) echo 'selected="selected"'; ?>>all categories</option>                 <?php $categories = get_categories('hide_empty=0&depth=1&type=post'); ?>                 <?php foreach($categories as $category) { ?>                 <option value='<?php echo $category->term_id; ?>' <?php if ($category->term_id == $instance['categories']) echo 'selected="selected"'; ?>><?php echo $category->cat_name; ?></option>                 <?php } ?>             </select>

             <label for="<?php echo $this->get_field_id('posts'); ?>">Number of posts:             <input class="widefat" style="width: 30px;" id="<?php echo $this->get_field_id('posts'); ?>" name="<?php echo $this->get_field_name('posts'); ?>" value="<?php echo $instance['posts']; ?>" />

             <input class="checkbox" type="checkbox" <?php checked($instance['show_excerpt'], 'on'); ?> id="<?php echo $this->get_field_id('show_excerpt'); ?>" name="<?php echo $this->get_field_name('show_excerpt'); ?>" />              <label for="<?php echo $this->get_field_id('show_excerpt'); ?>">Show excerpt
     <?php }}


title: display URL or permalink instead of page title in dashboard

text: Is there a way to display the page url or permalink instead of the page title on               example.com/wp-admin/edit.php?post_type=page      I am doing some A/B testing and some pages have the same title, but a different URL. Also I may experiment from time to time with a different title. I know all my pages by URL and would prefer to see this in the list of pages.


title: How can I sort the order of multiple custom field values in a custom post type?

text:
Here's the website: KunzlerIP At the bottom of the website, you see a slider using Fancybox. Each thumbnail pops up some content from an individual custom post type post. For this custom post type, I've enabled the following:                   function post_type_lawyers() {         register_post_type( 'lawyers',             array(                  'label' => __('Lawyers'),                 'public' => true,                 'show_ui' => true,                 'hierarchical' => true,                 'supports' => array(                     'title',                     'thumbnail',                     'page-attributes',                     'post-thumbnails',                     'custom-fields',                     'revisions',                     )             )         ); //end register_post_type         register_taxonomy( 'lawyer', 'lawyers', array( 'hierarchical' => true, 'label' => __('Rank') ) );     }     add_action('init', 'post_type_lawyers');      The info for each pop-up is a custom field value and key. Currently, there are 4 values per individual post. What I would like to do is order these custom field values in the following order:   * Height   * Fueled By   * Favorite Quote   * Areas of Expertise If you go through these pop-ups, you'll see that a couple of them don't follow the same order for some reason and I can't figure out how to control how they display. To call this slider, here's the query:
         <?php query_posts('post_type=lawyers&orderby=date&order=DESC&posts_per_page=-1'); while (have_posts()): the_post(); ?>
                 <a href="#<?php the_ID(); ?>" class="fancybox"><?php the_title(); echo the_category(); if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?>                 <div id="<?php the_ID(); ?>" class="profile"><?php if ( has_post_thumbnail() ) { the_post_thumbnail('large', array('class' => 'baseball')); } ?>
<?php the_title(); ?>
<?php echo(the_meta()); ?>

         <?php endwhile; ?>
      Does it have something to do with `the_meta()`?


title: Why won't my preg_replace work with content_save_pre?

text: I've written a filter function to replace all image URLs in a post with URL from the Uploads directory of my site. However, when using the `content_save_pre`, filter it won't actually work - but if I use the `content_edit_pre` filter, it works. Here is my code:               $oldPostContent = $post->post_content; // pass old content into function as argument     function get_the_post_imgs($oldPostContent) {         global $post;         $newPostContent = $oldPostContent;         $newPostContent = preg_replace_callback(             ￼"/<img.*src=[\"']([^\"']*)[\"'].*>/i", // pattern to match to (i.e the contents of an <img src="..." /> tag)             function ($match) {                 return "hello world"; // obviously it's a lot more complicated than this but for your sake i've massively simplified it so the src="..." content is just replaced with "hello world" for now             },             $oldPostContent         );              return $newPostContent; // return new manipulated content     }          add_filter('content_save_pre', 'get_the_post_imgs'); // this doesn't work on the content, but if I use content_edit_pre, it does work      I've added some comments along the way to help you out. I'm pretty sure it's not a problem with the regex (http://regex101.com/r/aP4fU9) so it's something to do with my code not working the way `content_save_pre` needs it to work. Thanks for any help :)


title: Renaming or Moving WP-Content Pros/Cons

text: I'm still learning WP. Previously I had done a 1-click installation of WP. Everything worked fine. But now, I'm planning to install it manually. What are the Pros/Cons of these? 1 Renaming wp-content   (I have heard some plugins won't work. Could I maybe just rename wp-content in the plugin code?) 2 Moving wp-content or wp-uploads Any harm in doing this? Thanks.


title: When to check if a function exists

text: I've just started developing a WP plugin, and i've been reading some code from other plugins as a way to get started. I've seen a couple of plugins that wrap all or some of their functions in the following code:               if(!function_exists('my_function')) {         function my_function() {             // a cool function         }     }      Is it considered good practice to wrap all functions in this code to avoid naming conflicts with other plugins? Thanks


title: How can I highlight specific pieces of text within a blog post?

text: I have searched for a simple method to allow a user to highlight a specific piece of text with a user chosen color but have not found one readily apparent. I have found a few methods related to syntax / code highlighting. I am not trying to highlight code but merely text within a blog post. Preferably I would like a simple method that provides a UI button within the editor itself as some users that post articles are not technically savvy and may have issues with short codes. I am currently running Wordpress version 3.5.1.


title: wp_handle_upload error "Specified file failed upload test" but still creates attachment?

text:
Having a bit of trouble with an image upload custom meta box. What happens is the uploaded image is created as an attachment but the wp_handle_upload seems to kick back the error "Specified file failed upload test" rather than updating my post meta? Seem odd though that the attachment is created without issues? Heres the code:               // Make the forms multipart     add_action('post_edit_form_tag', 'post_edit_form_tag');     function post_edit_form_tag() {        echo ' enctype="multipart/form-data"';     }          /* Setup custom meta boxes for posts */     $new_meta_boxes =         array(         "xxxx_kw1" => array(             "name" => "xxxx_kw1",             "std" => "",             "title" => "Keyword 1",             "type" => "text"             ),         "xxxx_url1" => array(             "name" => "xxxx_url1",             "std" => "",             "title" => "URL 1",             "type" => "text"             ),         "xxxx_kw2" => array(             "name" => "xxxx_kw2",             "std" => "",             "title" => "Keyword 2",             "type" => "text"             ),         "xxxx_url2" => array(             "name" => "xxxx_url2",             "std" => "",             "title" => "URL 2",             "type" => "text"             ),         "xxxx_kw3" => array(             "name" => "xxxx_kw3",             "std" => "",             "title" => "Keyword 3",             "type" => "text"             ),         "xxxx_url3" => array(             "name" => "xxxx_url3",             "std" => "",             "title" => "URL 3",             "type" => "text"             ),         "xxxx_image" => array(             "name" => "xxxx_image",             "std" => "",             "title" => "Image Upload",             "type" => "file"             )          );          function new_meta_boxes() {          global $post, $new_meta_boxes;              foreach($new_meta_boxes as $meta_box) {             $meta_box_value = get_post_meta($post->ID, $meta_box['name'], true);                  if($meta_box['type'] == 'file') { $meta_box_value = get_post_meta($post->ID,'xxxx_attached_image', true); }                  if($meta_box_value == "")             $meta_box_value = $meta_box['std'];                   echo'<input type="hidden" name="'.$meta_box['name'].'_noncename" id="'.$meta_box['name'].'_noncename" value="'.wp_create_nonce( plugin_basename(__FILE__) ).'" />';                  echo'
'.$meta_box['title'].'
';                  echo'<input type="'.$meta_box['type'].'" name="'.$meta_box['name'].'" value="'.$meta_box_value.'" size="55" />';         }     }          function create_meta_box() {         global $theme_name;         if ( function_exists('add_meta_box') ) {             add_meta_box( 'new-meta-boxes', 'PR xxxx Paid Information', 'new_meta_boxes', 'post', 'normal', 'high' );         }     }          function save_postdata( $post_id ) {         global $post, $new_meta_boxes;              $_POST = array_map('mysql_real_escape_string', $_POST);              foreach($new_meta_boxes as $meta_box) {             // Verify             if ( !wp_verify_nonce( $_POST[$meta_box['name'].'_noncename'], plugin_basename(__FILE__) )) {                 return $post_id;             }                  if ( !current_user_can( 'edit_post', $post_id ))                 return $post_id;                  if($meta_box['type'] == 'file') : // if data is a file we'll need to treat if differently...                      $data = $_FILES[$meta_box['name']];                      // If the upload field has a file in it                 if(isset($data) && ($data['size'] > 0)) {                          // Get the type of the uploaded file. This is returned as "type/extension"                     $arr_file_type = wp_check_filetype(basename($data['name']));                     $uploaded_file_type = $arr_file_type['type'];                          // Set an array containing a list of acceptable formats                     $allowed_file_types = array('image/jpg','image/jpeg','image/gif','image/png');                          // If the uploaded file is the right format                     if(in_array($uploaded_file_type, $allowed_file_types)) {                              // Options array for the wp_handle_upload function. 'test_upload' => false                         $upload_overrides = array( 'test_form' => false );                               // Handle the upload using WP's wp_handle_upload function. Takes the posted file and an options array                         $uploaded_file = wp_handle_upload($data, $upload_overrides);                              // If the wp_handle_upload call returned a local path for the image                         if(isset($uploaded_file['file'])) {                                  // The wp_insert_attachment function needs the literal system path, which was passed back from wp_handle_upload                             $location = $uploaded_file['file'];                                  // Generate a title for the image that'll be used in the media library                             $file_title = $uploaded_file['file'];                                  // Set up options array to add this file as an attachment                             $attachment = array(                                 'post_mime_type' => $uploaded_file_type,                                 'post_title' => preg_replace('/\.[^.]+$/', '', basename($file_title)),                                 'post_content' => '',                                 'post_status' => 'inherit',                                 'post_parent' => $post_id,                                 'guid' => $uploaded_file['url']                             );                                  // Run the wp_insert_attachment function. This adds the file to the media library and generates the thumbnails. If you wanted to attach this image to a post, you could pass the post id as a third param and it'd magically happen.                             $attach_id = wp_insert_attachment( $attachment, $location, $post_id );                             require_once(ABSPATH . "wp-admin" . '/includes/image.php');                             $attach_data = wp_generate_attachment_metadata( $attach_id, $location );                             wp_update_attachment_metadata($attach_id,  $attach_data);                                  // Before we update the post meta, trash any previously uploaded image for this post.                             // You might not want this behavior, depending on how you're using the uploaded images.                             $existing_uploaded_image = (int) get_post_meta($post_id,'xxxx_attached_image', true);                             if(is_numeric($existing_uploaded_image)) {                                 wp_delete_attachment($existing_uploaded_image);                             }                                  // Now, update the post meta to associate the new image with the post                             update_post_meta($post_id,'xxxx_attached_image',$attach_id);                                  // Set the feedback flag to false, since the upload was successful                             $upload_feedback = false;                                   } else { // wp_handle_upload returned some kind of error. the return does contain error details, so you can use it here if you want.                                  $upload_feedback = 'There was a problem with your upload: '.$uploaded_file['error'];                             update_post_meta($post_id,'xxxx_attached_image',$attach_id);                              }                          } else { // wrong file type                              $upload_feedback = 'Please upload only image files (jpg, gif or png).';                         update_post_meta($post_id,'xxxx_attached_image',$attach_id);                          }                      } else { // No file was passed                          $upload_feedback = false;                      }                      // Update the post meta with any feedback                 update_post_meta($post_id,'xxxx_attached_image_upload_feedback',$upload_feedback);                  else : // valid the input as normal                      $data = $_POST[$meta_box['name']];                      if(get_post_meta($post_id, $meta_box['name']) == "")                     add_post_meta($post_id, $meta_box['name'], $data, true);                 elseif($data != get_post_meta($post_id, $meta_box['name'], true))                     update_post_meta($post_id, $meta_box['name'], $data);                 elseif($data == "")                     delete_post_meta($post_id, $meta_box['name'], get_post_meta($post_id, $meta_box['name'], true));                  endif;              }     }          add_action('admin_menu', 'create_meta_box');     add_action('save_post', 'save_postdata');      If anyone can help I'd send a virtual thumbs up and a beer! :-) Cheers, Dave


title: How to show only Standard Format post in my custom taxonomy page -wordpress 3.8.1

text:
I want to exclude photo and video categories (ID's 1 and 2 respectively) from my custom taxonomy page. Any suggestions on how can I exclude these two categories from the loop?               <?php     /**      * Locations taxonomy archive      */     get_header();     $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );     ?>

<?php echo apply_filters( 'the_title', $term->name ); ?> News
                  <?php if ( !empty( $term->description ) ): ?>
                 <?php echo esc_html($term->description); ?>
             <?php endif; ?>                  <?php if ( have_posts() ): while ( have_posts() ): the_post(); ?>                  <div id="post-<?php the_ID(); ?>" <?php post_class('post clearfix'); ?>>
<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?>

<?php the_time(get_option('date_format')); ?> by <?php the_author_posts_link(); ?>

                         <?php the_content( __('Full story…') ); ?>

                  <?php endwhile; ?>

<?php next_posts_link('« Previous Entries') ?>

<?php previous_posts_link('Next Entries »') ?>

                  <?php else: ?>
No News in <?php echo apply_filters( 'the_title', $term->name ); ?>

It seems there isn't anything happening in <?php echo apply_filters( 'the_title', $term->name ); ?> right now. Check back later, something is bound to happen soon.

                  <?php endif; ?>

             <?php get_sidebar(); ?>
          <?php get_footer(); ?>


title: Child theme template value for style.css for parent in different folder

text: I am making a child theme in the `.../wp-content/themes/` folder however the parent theme that I am building on is in the `.../wp-content/plugins/` directory. I am able to import the parent `style.css` file using a directory path but when I try to do the same for the Template value, it does not work. Similarly, the simple name of the parent theme folder does not work either, presumably because the parent theme is in a different directory. Any ideas on how to fix this?


title: How to use the WordPress header as the global header for apps across a site?

text: I am running Wordpress as the main site, and a few other php CMS apps for other specific purposes (let me call it subsites for the purpose of this question). Now when designing templates for subsites, is there a way to call the WordPress header and menu, making it the global header across my entire site?


title: Using Customizer Options in a Plugin

text: I am fooling around with the Customizer code for the first time. The end goal will be to add some options to a plugin. I am off to a bad start because even adding the most basic code is throwing an error (Sorry I am new user here and I tried about 100 times to add the code below properly but it didn't work???)...               Fatal error: Call to a member function add_setting() on a non-object in... (my path)      Here is the basic code I am using (keeping in mind this is a plugin and not a theme)               function mb_wp_logo_customize_register ($wp_customize) {         //Settings, Sections, and Controls are defined here     }     add_action( 'customize_register', 'mb_wp_logo_customize_register' );               $wp_customize->add_setting( 'link_color' , array(         'default'           => 'FF00FF',         'type'              => 'option',         'transport'         => 'refresh',         'sanitize_callback' => 'sanitize_hex_color_no_hash',     ));          $wp_customize->add_section( 'customizer_content_customizations' , array(         'title'           => __('Content Customizations', 'wplogocustomizer'),         'description'     => __('Customize the colors', 'wplogocustomizer'),         'priority'        => 30,     ));


title: Change custom featured image size in twentythirteen child theme

text: I need to change the post thumbnail size in my child theme. I have read several answers on how to do this in twenty twelve, which is very similar, but nothing is happening when I use similar code for my 2013 child theme. This is the only code I have in my functions.php file:                   function watercolor_setup() {                     set_post_thumbnail_size( 604, 310, false );             }              add_action('after_setup_theme', 'watercolor_setup', 20);      I deleted the old images, regenerated the old images, but the new ones being created are using the 2013 size parameters and not the new ones set in my child theme. I also tried this code - not to mention a few others - with and without the false:               if ( ! function_exists( 'watercolor_setup' ) ):            function watercolor_setup() {         if ( function_exists( 'add_theme_support' ) ) {             add_theme_support( 'post-thumbnails' );             set_post_thumbnail_size( 604, 310, false );         }       }     endif;          add_action('after_setup_theme', 'watercolor_setup', 20);      But, nothing is having any effect. What am I missing?


title: How to use Iris color picker on front-end?

text: I am trying to use new Iris color picker on the front-end. I succeed in using it on back-end: while using it on theme options I just enqueued the color picker like this …               wp_enqueue_script( 'wp-color-picker' );     wp_enqueue_style( 'wp-color-picker' );      … and hooked it to `admin_enqueue_scripts`. It worked. However, I don't think the same process will work on the front-end by just hooking to `wp_enqueue_scripts`. Should I have to include the core file of new Iris color picker myself, or there is some way I can enqueue the color picker from front-end as I have done in my theme option code?


title: Get the category from an ID of a product?

text: I have the `ID` from a product (`1345`) how can i get the category name of that specific product? I try               $post_categories = wp_get_post_categories( $post->ID );     print_r( $post_categories );      but it outputs:               Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( )      What those it means ? Thanks


title: WordPress index page is returning 404 and admin page requires /index.php in url

text: My WordPress installation is in a different folder from my main site: `/var/www/html/wordpress` <= WP installation `/var/www/html/main-site` <= main site I would like to have WP display when someone visits /blog from my main site: http://www.main-site.com/blog (Note: main-site is used as a generic placeholder for the real site because it is not launched yet) I have set up an alias in my httpd conf file:               Alias /blog /var/www/html/wordpress      <Directory /var/www/html/main-site>         DirectoryIndex index.php         Options -MultiViews         AllowOverride All         order allow,deny         allow from all      </Directory>      I have the following as my .htaccess file for WP:               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /blog     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /blog/index.php [L]     </IfModule>      I get a 404 when I visit http://www.main-site.com/blog but when I visit http://www.main-site.com/wp-admin/index.php, it works (but I get a 404 if I visit /admin). Visiting the sample blog post and sample page also works for me. http://www.main-site.com/blog/hello-world/ http://www.main-site.com/blog/sample-page/ It looks like rewrite is working but my /blog index page doesn't work. Any suggestions would be greatly appreciated. Thanks, Allen


title: Problem with custom menus

text: On the menu, I'm talking about custom menus, I have a footer with several columns, each column will have a list of items, each column menus needs to be updatable from the menus option on wp admin, so I created the section on functions.php that calls the menus and also added each menu on the footer.php document, something like:               <?php wp_nav_menu( array('menu' => 'f-1', 'menu_class' => '', 'container' => 'nav' )); ?>     <?php wp_nav_menu( array('menu' => 'f-2', 'menu_class' => '', 'container' => 'nav' )); ?>     <?php wp_nav_menu( array('menu' => 'f-3', 'menu_class' => '', 'container' => 'nav' )); ?>     <?php wp_nav_menu( array('menu' => 'f-4', 'menu_class' => '', 'container' => 'nav' )); ?>      This is how I call the menus:               add_theme_support('nav-menus'); if ( function_exists('register_nav_menus')) {     register_nav_menus( array(     'main' => 'Main Nav',     'footer-noticias-financieras' => 'Footer Noticias Financieras',     'footer-otras-publicaciones' => 'Footer Otras Publicaciones',     'footer-foro' => 'Footer Foro'     ) );     }      The thing is, when I place the menus using the theme menus area it prints automatically on my footer the column with 2 options, home and about, the "Automatically add new top-level pages" is not selected so not sure what's going on, anybody with the same problem? Thanks so much! A.-


title: add_filter doesn't work

text: I'm developing a plugin to replace a character for some user agents in titles, posts and comments but the filter doesn't work. Here is the plugin:               <?php     /*     Plugin Name: WP-HalfSpace     Description: نمایش فاصله به‌جای نیم‌فاصله برای گوگل برای خراب‌نشدن نوشته در نتایج جست‌وجوی گوگل     Version: 1.0.0     Author: ahmadalli     Author URI: http://2barnamenevis.com     */     function HalfSpace_filter($content)     {              $u_agent = $_SERVER['HTTP_USER_AGENT'];         echo "hi";         if(($u_agent=="Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" )         || ($u_agent=="Googlebot/2.1 (+http://www.googlebot.com/bot.html)")         || ($u_agent=="Googlebot/2.1 (+http://www.google.com/bot.html)")         || ($u_agent=="Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)")         )         {              echo "aaaaaaaaa";             $content=str_ireplace(""," ",$content); //"" is not empty. it's a persian character names halfspace.         }         return $content;     }          register_activation_hook( __FILE__, 'HalfSpacePlugin_activate' );          function HalfSpacePlugin_activate()     {         add_filter('the_title','HalfSpace_filter',1,1);         add_filter('the_content','HalfSpace_filter',1,1);         add_filter('comment_text','HalfSpace_filter',1,1);     }                    register_deactivation_hook( __FILE__, 'HalfSpacePlugin_deactivate' );          function HalfSpacePlugin_deactivate()     {         remove_filter('the_title','HalfSpace_filter');         remove_filter('the_content','HalfSpace_filter');         remove_filter('comment_text','HalfSpace_filter');     }     ?>      The filter doesn't work at all because `echo "hi";` in `HalfSpace_filter` doesn't do it's job! Can anybody help me?


title: Include a specific post to the query_posts and remove it if it is already in the returned list

text:
Bare with me. Firstly, here is my whole script for my featured slider articles:               <div id="featured" class="<?php if ( $responsive ) echo 'flexslider' . $featured_auto_class; else echo 'et_cycle'; ?>">     <?php esc_html_e('Previous','Aggregate'); ?>     <?php esc_html_e('Next','Aggregate'); ?>          <?php if ( $responsive ) { ?>
     <?php } else { ?>
     <?php } ?>     <?php global $ids;     $ids = array();     $arr = array();     $i=0;          $featured_cat = get_option('aggregate_feat_cat');     $featured_num = (int) get_option('aggregate_featured_num');          if (get_option('aggregate_use_pages') == 'false') query_posts("showposts=$featured_num&top=billboard"); // set which slug in custom taxonomy TOP it should filter     else {         global $pages_number;              if (get_option('aggregate_feat_pages') <> '') $featured_num = count(get_option('aggregate_feat_pages'));         else $featured_num = $pages_number;              query_posts(array         ('post_type' => 'page',             'orderby' => 'menu_order',             'order' => 'ASC',             'post__in' => (array) get_option('aggregate_feat_pages'),             'showposts' => (int) $featured_num         ));     } ?>     <?php if (have_posts()) : while (have_posts()) :         global $post;         if (!$first_time) // START custom first post         {             $post_id = 105; // This is the ID of the first post to be displayed on slider             $post = get_post($post_id);             $first_time = 1;         }         else the_post(); // END custom first post         ?>         <?php if ( $responsive ) { ?>
             <?php } else { ?>
             <?php } ?>         <?php         $width = $responsive ? 960 : 958;         $height = 340;         $small_width = 95;         $small_height = 54;         $titletext = get_the_title();              $thumbnail = get_thumbnail($width,$height,'',$titletext,$titletext,false,'Featured');              $arr[$i]['thumbnail'] = get_thumbnail($small_width,$small_height,'',$titletext,$titletext,false,'Small');         $arr[$i]['titletext'] = $titletext;              $thumb = $thumbnail["thumb"];         print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, ''); ?>

         <div class="featured-bottom-shadow feat<?php $category = get_the_category(); echo $category[0]->category_nicename; ?>">

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

<?php $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,20); ?>

          <?php if ( $responsive ) { ?>
          <?php } else { ?>
          <?php } ?>         <?php $ids[] = $post->ID; $i++; endwhile; endif; wp_reset_query(); ?>     <?php if ( $responsive ) { ?>
      <?php } else { ?>
      <?php } ?>
       It `query_posts` a set amount of posts from the custom taxonomy `top=billboard`. The following part of the code:               <?php if (have_posts()) : while (have_posts()) :         global $post;         if (!$first_time) // START custom first post         {             $post_id = 105; // This is the ID of the first post to be displayed on slider             $post = get_post($post_id);             $first_time = 1;         }         else the_post(); // END custom first post         ?>      Adds the post ID `105` to the first post of the returned list. This allows me to control which post is displayed first. **The problem is** : If post ID `105` is already included in the custom taxonomy `top=billboard`, then it will appear twice in the list... so once because it was added in the above `custom first post` script, and once because it was added in the custom taxonomy `top=billboard`. How do I adjust my code so that if post ID `105` exists in custom taxonomy `top=billboard`, then it should **not** appear twice (only as the first post).


title: How to show custom static content at top of each category page?

text: I want to display custom static content, essentially an image and a small description, at the top of each category page (different for each category and sub category), displayed above a list of titles of the category posts with excerpts. Is there an automated solution/plugin available for this? I need an automated way to insert text/image too because I want to pass this to my content writer and he will take care of the new categories. A rich text editor where I can insert image and text, which will be assigned to a category and can be shown on top of the category page.


title: Is there a way to remove the option to modify the Slug in post.php

text: I am trying to remove the option to edit the **Permalink**. I know how to hide it with CSS and I have. But a hacker could simply just go to Inspect Element and change `display: none;` to `display: block;` and then be able to modify the Permalink. So is there a way to block that option? Or can I check if the user submits to verify that the permalink was not modify?


title: Custom search with meta fields

text: I made a custom search form with text fields and dropdown. Now, my form is in its own template file - sidebar-search.php. I have also made the searchform.php which should get the data from sidebar and then display results. I'm using this method for the query. **My problem** is this: When I put the "action" to "bloginfo('home')" - nothing happens.   When I put the "action" to "TEMPLATEPATH . 'searchform.php'" - shows a blank page. (this is now updated - see last lines) Here is the code from searchform.php. Here is the sidebar-search (removed links, check update at the bottom) Thanks! **UPDATE**   I now placed my code in search.php, and here is how it looks like: link It still just reloads the page and no results are shown.   My action is now like this: `action="<?php echo get_bloginfo('home') ?>"`


title: Tools for styling code snippet in a web page

text: I'm a software developer and I've started my first blog on Information Technology. Since I'm using wordpress (hosted free plan) as blogging platform, I'm wondering if there's a fast and useful way for styling code snippet in my posts.


title: How to debug failed changes to posts?

text: I just rebuilt my server with Ubuntu 14.04, Nginx 1.6.0, PHP 5.5.9 and Wordpress 3.9. I am able to complete the Wordpress install and login to the Wordpress dashboard, however, I can't make any changes. If I try and delete a post, Wordpress says the action is completed, but when I hit the Posts menu again, the post comes back. If I try and create a post, Wordpress says the action is complete, but when I hit the Posts menu option, it disappears from the table. What's even more weird is if I wait a couple seconds and press the Posts menu option again (to refresh the Posts table) my changes will be there - but it doesn't always happen. This problem exists all throughout the Dashboard and I'm starting to wonder if there's an issue with Wordpress and PHP 5.5.9 since it looks like the PHP team incorporated some caching capability. My same setup works on Ubuntu 13.04, Nginx 1.4.6, PHP 5.4.9 and Wordpress 3.9. I haven't made changes to the default php.ini file and I installed php using               sudo apt-get install php5-cli php5-cgi psmisc spawn-fcgi      I'm using MySQL as the database and I connected PHP to MySQL using               sudo apt-get install php5-mysql      My database user has all permissions on the appropriate database. I'm also wondering if there's something in my Nginx Virtual Hosts file for the site that would cause this issue.


title: Create a author subpage

text: I want to create a author subpage, that looks like this `www.example.com/author/user/subpage` I read the Wordpess codex about how to create subpages. You can link a page with another page in the page panel. But my author page isn't listed in the page panel. So do i need to create a code for that in author.php or author-template.php, to get this done?


title: How to create a link to a user's profile page

text:
I've created a user list for all the customers who registered on my website. When a outside user (or guest) browse my website and want to view the profile of a specific user, they should be able to click on the user's name and then should be redirected to the profile page of that user. I've managed to set everything up but the link points me to an author page and should point me to the PROFILE page of the user. Code inside `functions.php`:               function userlist() {         global $wpdb;              $users = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users WHERE display_name <> 'admin' ORDER BY display_name");              foreach ($users as $user ) {                  echo "
";             // GETTING USER AVATAR             echo "ID);             echo "/\">";             echo get_avatar($user->ID);             echo "";             // DISPLAY USER-NAME         echo '
';         echo "ID); // points to wishlist url -> seems like it searches for name          echo "/\">";         the_author_meta('user_lastname', $user->ID); // display name         echo "";      I've changed the `// DISPLAY USERNAME` part a bit. When I hover over the username, the link displayed reads: wordpress/user-list/username but when I click on the username it redirects me to the user's wedding registry page which is: `http://example.com/wishlist/romualdo-and-heidis-wishlist/` The good new is it point somewhere but it needs to go to the user's public profile page. What am I missing in the code to redirect it to profile instead of the wishlist page? The `functions.php` part where I use query var so that WP catches my custom `/user/username` url:               add_filter( 'query_vars', 'wpleet_rewrite_add_var' );     function wpleet_rewrite_add_var( $vars )     {         $vars[] = 'user';         return $vars;     }          add_rewrite_tag( '%user%', '([^&]+)' );     add_rewrite_rule(         '^user/([^/]*)/?',         'index.php?user=$matches[1]',         'top'     );          add_action( 'template_redirect', 'wpleet_rewrite_catch' );     function wpleet_rewrite_catch()     {         global $wp_query;              if ( array_key_exists( 'user', $wp_query->query_vars ) ) {             include (TEMPLATEPATH . '/UserList.php');             exit;         }     }


title: how to test a theme upgrade

text: Is there a way to test run a theme through the automatic updater? We have a theme where a version will introduce new functionality which might break existing themes. I would like to check previous theme version upon upgrade and include some upgrade-specific code if the upgrade is between two certain versions. I first thought I could use `after_theme_switch` hook, but the theme is mainly used as parent theme and will probably be upgraded while not being the active theme. I have looked into using `upgrader_pre_install` and `upgrader_post_install` hooks, but how to I test these? The ultimate would be to have it as a unit test, but any other way to mock- upgrade would be great. Uploading a zip file is treated as an install and not upgrade. Is this even possible from within a theme, our should I look into writing a mock-upgrade plugin?


title: posts_nav_link(); not showing up on static pages

text:
I've got two different loops. The default on the homepage, but a secondary loop on the archive page. It grabs all the content, like so:               <?php // WP_Query arguments     $args = array (         'posts_per_page'         => '3'     );     // The Query     $archiveQuery = new WP_Query( $args );          // The Loop     if ( $archiveQuery->have_posts() ) {         while ( $archiveQuery->have_posts() ) {             $archiveQuery->the_post(); ?>
     <a href="<?php the_permalink() ?>">         <?php  first_item(); ?>       However, when I include `posts_nav_link();`, it does not show up. Is this because it is a static page? I am using this for an infinite scroll.


title: Performance on WPMS

text: my WPMS site is hosted on 8 cores/32mb RAM server but the response time is very high. We have about 1000 blogs (35,000+ tables on single db) and 70,000 pageviews per mounth. I think that i can down the response time moving blogs that have more pageviews into separeted DB and spliting all blogs into 100 blogs per db with hyper-db plugin. What do you think?


title: W3 Total Cache Plugin with WP 3 MultiUser

text: I'm having some strange behavior with my W3 Total Cache solution working on my multi-user Wordpress 3 installation. The multi-user is setup to use sub directories, and I'm using all types of caching in W3. My suspicion is that my problem has something to do with the .htaccess file. Periodically (but not consistently) navigating to certain parts of the site will end up redirecting to the wrong place. For example if I goto /corporate/ which is one of the subsite directories, it will redirect to /directives/corporate-training/ which is a single post of a different sub- site. This only happens occasionally, sometimes it is not a problem (which is why I think it is somehow related to page caching) The behavior suggests that somewhere in the redirect rules, it occasionally forgets to check for other sub-sites, and instead tries to match /corporate/ to the closest post slug in a different site. Looking for any guidance on where to look for the problem.


title: Priority of Meta Box for Custom Post Type

text: I'm having a small issue with the custom post type entry screen. I'd like to bump up my metabox right under the content box, but I'm not sure if that's even possible (as the metaboxes in between are "defaults", i.e.; Excerpt, Discussion & Author). I'm applying the standard code:               function ctp_admin(){     add_meta_box('cpt_meta', 'Meta Box', 'cpt_meta', 'cpt_function', 'normal', 'high');     }      Thank you! Noel


title: Google Analytics event tracking code being stripped out of links in Author box - WordPress site

text: I am using Yoast's Google Analytics plugin on my WordPress site. I have enabled Event Tracking for outbound links and have successfully manually added event tracking for some other internal links. It all works fine EXCEPT for in the 'Author Box'. Under each post I created an author box which pulls "the_author_description" from the user profile. This seems to strip out the GA event tracking code. I have an outbound link in there which should automatically be tracked by the plugin but the code is not there. If I try and manually add the code to any of the links in the user profile, they also get stripped out. Any ideas on how to fix this?


title: How to auto-accept a friend-request in buddypress based on user meta

text: I’m still getting my head around buddypress, so far so good but I’ve hit a snag where I want certain users who are flagged as an ‘expert’ to automatically accept any friend requests people make. I’ve found a couple of functions related to this but I think I’m missing something that would make this simpler such as setting a constant or overriding part of the $bp global… What I have so far is the following:               function bp_auto_accept_friend_request( $friendship_id, $friendship_initiator_id, $friendship_friend_id ) {         if ( is_user_expert( $friendship_friend_id ) ) {             // force add             friends_accept_friendship( $friendship_id );             friends_add_friend( $friendship_initiator_id, $friendship_friend_id, true );         }     }     add_action('friends_friendship_requested', 'bp_auto_accept_friend_request', 200, 3);      Can anyone tell me where I should be looking to make this nice and seamless just as if the main settings were set to bypass the request process please?


title: How can I save an array from a random post sequence for later use?

text:
I'm building a random workout generator on Wordpress to help with my fitness, and am stuck at saving random post arrays for later reference. I'll explain. The generator should work in two main stages:   1. You choose how hard you want the workout to be, and how long it should take.  These values are passed to a new page via the a URL String. This creates a random workout (code at bottom of question) by displaying random posts based on the parameters from the string and code on a dynamic page ('/your- workout/')   2. If you like the workout, I want you to be able to save this random array of posts to use it again later.     1. The ID's of the post displayed in this random sequence are saved to an array.     2. When a user wants to save a workout to use again later, this array of Post IDs is used to create a new Wordpress Page, with content populated by those specific posts in that specific order. This would be a child page of ('/your-workout/') created by 'saving' a workout. Step 2 is specifically where I am stuck. **How can I save the post IDs of a random array and use them to create a new child page which displays this specific sequence?** _Relevant Code for Step 1:_                       <?php global $post;             if (isset($_GET['dm'])) { //Check DM is set             $mode = $_GET['dm'];      //Get DM Value - will define CPT's taxonomy             }             if (isset($_GET['e'])) {  //Check E is set             $posts = $_GET['e'];      //Get E value - will define how many posts are shown             }             $my_query = new WP_Query( "post_type=bw-exercise&orderby=rand&difficulty-mode=$mode&showposts=$posts");?> //Define query using pre-set and URL String values                  <?php   if ( $my_query->have_posts() ) {              while ( $my_query->have_posts() ) {                     $my_query->the_post();?>

<?php echo get_post_meta(get_the_id(), "wpcf-reps", true);?>

<?php the_title('
', '
');?>
<?php the_content();?>

<a href="<?php the_permalink();?>" target="_blank"><img src="<?php bloginfo('template_url');?>/custom/images/i.jpg">

             <?php                    }                }             ?>             <?php   wp_reset_postdata();?>      If I can be any clearer, please let me know. Thanks! R :)


title: Why I can't add a CSS style in this WordPress theme?

text:
I am trying to add a CSS style to a WordPress theme that I am developing as is shown in this tutorial: http://www.wpbeginner.com/wp-tutorials/how-to- properly-add-javascripts-and-styles-in-wordpress/ but seems don't work and I cant' understand why. So this is the **head.php** file of my personal theme:               <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">     <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>          <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />     <title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?></title>     <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" />                <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />                         <?php wp_head(); ?>

<a href="<?php echo get_settings('home'); ?>"><?php bloginfo('name'); ?>

<?php bloginfo('description'); ?>

      And in my **functions.php** file I have put the following code:               <?php     function wpb_adding_styles() {         wp_register_script('my_stylesheet', plugins_url('style.css', __FILE__));         wp_enqueue_script('my_stylesheet');     }          add_action('wp_enqueue_scripts', 'wpb_adding_styles');     ?>      But the file **style.css** is not loaded. Why? What am I missing? In particular the thing that I can't understand in the previous tutorial is how and hwere the **wpb_adding_styles()** is called because in the header.php file it is never called. Someone can help me? Tnx Andrea


title: How to always rewrite author archive page URL even if the author does not have a post

text: My understanding about author archive page URL rewriting is that as long as the author has atleast one post/page the URL for the archive page ofthe author will be re-written to:               http://mysite.com/author/%authorname%      However, if the author does not have any post/page then the URL for the archive page will be of the form               http://mysite.com/?author=id      How can we force wordpress to always rewrite the URL to /author-base/%author% even if the author does not possess any post/page.