Filter get_adjacent_post() for private posts, how to modify JOIN/WHERE?

_Edit 3 - revised per G.M.'s suggestions. Code runs error free, but adjacent post filter still not filtering. Changes noted in code comments, current question noted at bottom of post._ _Edit 2 - reflects G.M.'s code suggestion below. I'm confused about where the modified join/where filter function should go, so I added more of the mu- plugin code structure._ _Edit 1 - reflects Kaiser's comment below, examples provided. Also, I was mistaken about which code was filtering my posts. Question does not relate to the Members plugin._ I have a mu-plugin filtering my WP query so that in the index loop, a visitor only sees posts they can read. It does this by offering post author the ability to assign a multi-level membership taxonomy for each post. At the lowest (public) level, there is no membership taxonomy attached to the post. Here is the query filter in the mu-plugin:               if ( ! class_exists ( 'Site_Members_Taxonomy' ) ) {          class Site_Members_Taxonomy     {         //define( 'LANG', 'some_textdomain' ); deleted LANG, was throwing errors              public $post_types = array( 'post', 'page', 'gallery' );         public $tax = 'membership';         public $tax_label; // CHANGE: made these three vars public              public function __construct()         {         $this->tax_label = __( 'Membership' );              // plugin defines taxonomy and membership meta and then:              add_action( 'pre_get_posts', array( &$this, 'filter_query' ) );              /**          * Modify the query based on membership taxonomy          */         function filter_query( $query ) {                  //quit right now if in admin             if( is_admin() ) return;                  $tax_query = '';             $terms = $this->get_terms_to_exclude(); // see function below                  if( $terms )                  $tax_query = array(                        array(                             'taxonomy' => $this->tax,                             'field' => 'slug',                             'terms' => $terms,                             'operator'=>'NOT IN'                         )                 );                  // if after all that we have a tax query to make, lets do it!             if ( $tax_query )                 set_query_var('tax_query', $tax_query);              }              } //end class              global $Site_Members_Taxonomy;         $Site_Members_Taxonomy = new Site_Members_Taxonomy();          }          // finally, outside the class definition, there is a function `members_can_view` to be used as a conditional to hide/show various template tags etc.      So far, so good. This filter works great. The problem is, in single-post view, `next_post_link()` and `previous_post_link()` don't get the filter, so visitors can navigate to posts they **cannot** read. I want to filter the links to these posts to show the link only to the next post they can actually read. I'd basically like to use the above query filter on get_adjacent_post(). In WP core trac for link-template.php (as well as in the post Kaiser linked to below) I found that `next_post_link()`, `get_next_post()` and `get_adjacent_post()` run the adjacent post query through the following filters:   * `get_{$adjacent}_post_join`   * `get_{$adjacent}_post_where`   * `get_{$adjacent}_post_sort` * * * **REWRITE JOIN/WHERE FILTER** I tried the following rewrite of JOIN/WHERE suggested in G.M.'s answer. As he says, it is very closely based on the wp-core function, with tr and tt given different names and the excluded terms passed directly to the function. This function is currently active on the site and not throwing errors, however it's not filtering the adjacent posts query correctly either. **Current Question:** When converting $excluded_terms from slugs to IDs in the function _filter_adjacent_ below, am I correctly building the array? How can I log the excluded terms and find out what's going on?                   // Filters for get_adjacent_posts() so they don't show up in single-post navigation           // These filters are added within function __construct{} noted above         // CHANGE: &$this to $this              add_filter( 'get_previous_post_where', array( $this, 'filter_adjacent' ) );         add_filter( 'get_next_post_where', array( $this, 'filter_adjacent' ) );         add_filter( 'get_previous_post_join', array( $this, 'filter_adjacent' ) );         add_filter( 'get_next_post_join', array( $this, 'filter_adjacent' ) );                   /**          * These functions added within mu-plugin class:          *          * First, modify excluded terms based on membership taxonomy          *           * NOTE: Excluded terms may be an array          */              function get_terms_to_exclude() {                  // if a real admin or "level1" we won't change tax query at all             if( current_user_can ( 'manage_options' ) || current_user_can ( 'view_level1_posts' ) )                 return false;                  // default/public will exclude all upper level posts             // in other words, all posts with membership taxonomy             $terms = array( 'level1','level2','level3' );                  // if a level3 reader we'll exclude level1 and level2 posts             if( current_user_can ( 'view_level3_posts' ) )                 $terms = array( 'level1', 'level2' );                  // if at level2 level we'll exclude level1 level posts             if( current_user_can ( 'view_level2_posts' ) )                 $terms = array( 'level1' );                  return $terms;              }                   /**          * Next, use these terms to filter the get_adjacent_post JOIN/WHERE          */              function filter_adjacent( $clause ) {                  if ( substr_count( current_filter(), '_post_join' ) ) { // filtering join                      if ( empty($clause) ) $clause = '';                 global $wpdb;                 $clause .=                     " INNER JOIN {$wpdb->term_relationships} AS trmship ON p.ID = trmship.object_id                     INNER JOIN {$wpdb->term_taxonomy} ttmship                     ON trmship.term_taxonomy_id = ttmship.term_taxonomy_id";                 return $clause;                  } elseif ( substr_count( current_filter(), '_post_where' ) ) { // filtering where                      $excluded_term_slugs = get_terms_to_exclude();                 if ( ! $excluded_term_slugs ) return $clause; // nothing to filter if no terms                 $excluded_terms = array(); // we needs term ids, let's convert slug in terms ids                 foreach ( $excluded_term_slugs as $slug ) {                     $t = get_term_by( 'slug',  $slug, 'membership' );                     if ( ! $t || is_wp_error($t) ) continue;                     $excluded_terms[] = $t;                 }                 // something wrong in get_level_term_to_exclude()?                 if ( empty($excluded_terms) ) return $where;                       $posts_in_ex_terms_sql =                      " AND ttmship.taxonomy = 'membership'                     AND ttmship.term_id NOT IN (" . implode( $excluded_terms, ',' ) . ')';                 // return filtered where clause                 return $clause. $posts_in_ex_terms_sql;             }         }


Saving plugin data returns "You do not have sufficient permissions to access this page."

I'm developing a quote plugin which will save a quote to the WPDB using a form to input the quote. I've created half this code and got the other piece from another programmer on here. I'm looking to try and understand these 3 lines better.                if (is_null($quotes)) {             $quotes = array();         }              if (isset($_GET['delete']) && is_numeric($_GET['delete'])) { // ???             unset($quotes[$_GET['delete']]); // remove that quote from the array             $quotes = array_values($quotes); // reorder the keys             update_option('dw_quotes', serialize($quotes)); // store results             echo '
Quote Deleted
';         }              if ($_POST && isset($_POST['random_quote']) && $_POST['random_quote'] !== '') { //???             array_push($quotes, $_POST['random_quote']);             update_option('dw_quotes', serialize($quotes));             echo '
Quote Added
';         }      However this isn't my only problem, I'm getting an error when trying to save the plugin quote. Possible Cause:`<form action="admin.php?page=wse140202.php" method="post">` Reason for possible Cause: Looking at when the error appears its got to be something to do with accessing this page. error:"You do not have sufficient permissions to access this page." Full plugin code:                   <?php          /*idea to develop further would be, add a text box that the user can input the quote in     this then gets added to the DB and passed to the $quotes array. From here the results get     output the same way*/     /*     Plugin Name: Random Quotes     Plugin URI: xxx     Description: This Plugin randomly generates Quotes input by the user.     Version: 0.0.1     Author: xxx     Author URI: xxx     License: GPL2     */          /*          Function Reference      is_numeric() - Finds whether a variable is a number or a numeric string     unserialize() - takes a single serialized variable and converts it back into a PHP value.     isset() - tests to see if a variable isset               */          add_action('admin_menu', 'dw_quotes_create_menu');          function dw_quotes_create_menu() {         //create custom top-level menu         add_menu_page('Quotes Settings', 'Quotes Styling', 'manage_options', __FILE__, 'dw_styling_quotes_settings');     }              //generating the random quote     function dw_get_random_quote() {         $quotes = get_option('dw_quotes', null);          $quotes = unserialize($quotes);         $rand_quotes = array_rand($quotes);         $result_quote = $quotes[$rand_quotes]; // assigns $result_quote the random quote              return $result_quote;                }         //styling the admin menu     function dw_styling_quotes_settings() {              // load quotes         $quotes = get_option('dw_quotes', null);         $quotes = unserialize($quotes); // unserialize the data from the $quotes array              if (is_null($quotes)) {             $quotes = array();         }              if (isset($_GET['delete']) && is_numeric($_GET['delete'])) { // ???             unset($quotes[$_GET['delete']]); // remove that quote from the array             $quotes = array_values($quotes); // reorder the keys             update_option('dw_quotes', serialize($quotes)); // store results             echo '
Quote Deleted
';         }              if ($_POST && isset($_POST['random_quote']) && $_POST['random_quote'] !== '') { //???             array_push($quotes, $_POST['random_quote']);             update_option('dw_quotes', serialize($quotes));             echo '
Quote Added
';         }              ?>
             <?php screen_icon( 'plugins' ); ?>
Quotes Page
                       <form action="admin.php?page=wse140202.php" method="post">                 Add Quote:  <input style="width:600px;" type="textarea" name="random_quote" value="" />
<input type="submit" />             </form>

Current Quotes

             <?php             if ($quotes !== null) { // checks if $quotes is not set to 0                 $index = 0; //counter                 if (is_array($quotes)) { // checks if $quotes is an array to prevent error                 foreach ($quotes as $quote) {                     echo '
[ Delete ]  ' . $quote . '
';                     $index++; //increment counter                     }                 }             }?>

A Random Quote
             <?php echo dw_get_random_quote();     }          ?>


Post of a specific category - not to be seen in paging previous/next post

i have a specific post category, eg. id=x which is not shown in category list. These posts are password protected and should be visible only to those provided with the link. However current version still allows see posts from all categories using prev/next posts. What is the easiest way to ommit some of these category id=x from paging?


List all anchor links on a page

I was trying to make a navigation menu of all the anchor links on a page (similar to wikipedia) but couldn't find out how. I tried to find a plugin that could do it, but they only listed the anchors of a single post. I made a custom page with the following code:               get_header(); ?>          <main id="content" class="site-content" role="main">              <?php query_posts('category_name=Artemis-Header'); ?>              <?php while ( have_posts() ) : the_post(); ?>                  <?php the_content(); ?>              <?php endwhile; // end of the loop. ?>              <?php query_posts('category_name=Artemis'); ?>              <?php while ( have_posts() ) : the_post(); ?>                  <?php get_template_part( 'content', 'page' ); ?>                  <?php comments_template( '', true ); ?>              <?php endwhile; // end of the loop. ?>          </main><!-- #content .site-content -->          <?php get_sidebar(); ?>     <?php get_footer(); ?>      and it displays a header, followed by all the posts that are part of the category "Artemis". When on this page, I'd like there to be a list of anchor links to all of the posts (later I'll move those links to a fixed sidebar, to make navigation easy). Any help would be appreciated


what is correct way to hook when update post

i try to hook when post is updated but all hook i try never executed except `updated_post_meta`               add_action('updated_post_meta', 'my_function');          function my_function($post_id) {             echo 'This is my post ID : '.$post_id;     }      I've tried this `add_action('save_post', 'my_function');` but no id was echo out, or maybe this message already echo but never renders because of redirect header is sent.


Send ALL new posts and edits for moderation before publish

I want to have ALL new posts / edits moderated. I.E. When any user from a specific role (can be WP role such as contributer, or a custom created role) creates a new post, or edits an existing one it needs to go for review by an admin before being published. I can't seem to get this to work in any way I've tried.   1. Revisionary plugin - this would work great but it doesn't seem to work with Custom Fields, which is what most of our content is using.   2. I can use contributor role, which works great for new posts. But after the post has been published the user is free to edit at will, without any moderation.   3. I've tried to force all new posts to "pending" status, which does work, but also causes the post on the live site to return a 404 error until the post is approved and published again. Is there any way to achieve this functionality? Thanks


Using Nonces for AJAX that only retrieves data

Does it make sense to use a nonce on an AJAX action that only returns data and doesn't alter data on the server side? I understand they are important if you are saving data or changing something on the server but if you are just receiving data like a post or metadata, is a nonce really needed?


In theme Twenty Eleven, do the default images rotate randomly?

In theme Twenty Eleven, do the default images rotate randomly, or with some sequence? As far as I can see, I think it's random, but there might be some pattern/sequence that I didn't notice.


Changing CSS in Twenty Eleven to change font size of body text

How do I alter the CSS of Twenty Eleven so that all the body text in posts and on pages is bigger? And is the change I make for this in the files on my server, or through the browser in the Admin login of my WordPress account? (If there's a better way to alter the text size than altering the CSS, then what is that?) Thanks,


How can I have two content titles?

I'm facing a design, that has two titles. I have no clue how can I two titles in wordpress. In a nutshell: Creating a page, there you can set the title. How can I have two titles there? Or similar effect? ![enter image description here](http://i.stack.imgur.com/88INm.png)


Menu Error in Admin Console with Custom Plugin: You do not have sufficient permissions to access this page

_( **Moderator's note:** Original title was "Getting error: You do not have sufficient permissions to access this page. Trying to build custom plugin")_ I'm trying to write my own custom WordPress plugin, but as soon as I click on the menu I get the following error: > _You do not have sufficient permissions to access this page._ My plugin is located under:               /wp-content/plugins/wp-e-commerce-group-pricing/wp-e-commerce-group-pricing.php      The code is below, I'm new to WordPress, so maybe I'm doing something wrong:               if ( is_admin() ) {       // Hooks and admin menu setup       add_action('admin_menu', 'add_options_gp');            function add_options_gp() {         add_submenu_page('wpsc-sales-logs','WPEC - Group Pricing','Group Pricing',7,                          'wp-e-commerce-group-pricing', 'price_options');       }            function price_options(){         // Page content goes here...       }     }


Wordpress Programmatically create subpages when a certain page template is used

I've been fiddling for quite some time now but can't seem to figure this out. What I am looking for is this:   1. One creates a page and set it to use a certain page template, say: "Shop Owner"   2. WP automatically creates a few subpages with the same page template The hierarchy would look like this:               Parent page           Subpage           Subpage           Subpage               subsubpage               subsubpage         Subpage      And those pages will have a predefined content snippet, in my case a shortcode. My thoughts where to do this with:               'post_content' => '[bladiebla]',      I found a similar question but that one is with a custom post type. Hope one of you can point me in the right direction. I feel it's pretty easy with the link above, but can't seem to figure it out. Thanks,   Paul


How to make a bilingual front-end post using the plugin WP User Frontend and Polylang or qTranslate?

I'm implementing a bilingual blog site (English and Japanese). It contains front-end user posting and user registration. So, I used WP User Frontend. For multilingual content, I tried qTranslate and Polylang. **Polylang** is one language per post. **qTranslate** is all languages in a single post. Both are nice and language-selection for posting is implemented in the Admin. I could have created a basic front-end posting form according to the installation guide of WP User Frontend. I have facing two problems:   1. Which one is better for front-end user posting - **Polylang** or **qTranslate**?    2. How can I implement a language selection entry for front-end user posting? **[UPDATE]**   I found the two functions:   * `WPUF_Add_Post->submit_post()` in `wp-user-front-end/wpuf-add-post.php`   * `PLL_Admin_Filters_Post->save_post()` in `polylang/admin/admin-filters-post.php`. I could add a custom field "Language" for the fontend posting form of **WP User Frontend** and then I could make those two functions running in combination. I'm new to wordpress and I don't know how to implement this.


SQL query - get ids - Advanced Custom Fields / WPeC

I need to query the database on add_action( 'init', '...') to find post ids with the field 'product_discount_option' set to true. I know at least one of my product posts have the field 'product_discount_option' set to true. However when i run the SQL query below and var_dump it outputs an empty array , array(0) { } ..               add_action( 'init', 'retrieve_product_ids');          function retrieve_product_ids(){     global $wpsc_cart, $wpdb;              $product_ids = $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM `".WPSC_TABLE_META."` WHERE `meta_key` = 'product_discount_option' AND meta_value = true" ) );              var_dump($product_ids);     }      The field 'product_discount_option' has been setup using the Advanced Custom Fields Plugin. The posts are WPeC custom post types, post_type = 'wpsc- product'. I'm new to SQL queries, sorry if i've missed anything in the question. thanks Cam


Show Biographical Info while creating new user

Is it possible to show the Biographical Info textfield while creating a new user? I know it's possible to add user bio by editing a user AFTER it has been created. But I would like to do this while creating the user.


Rectangle avatars

I'm using `get_avatar()` to output images of my users. Ref: https://codex.wordpress.org/Function_Reference/get_avatar The optional size parameter lets me specify a size. However, this makes a square avatar. How can I output an avatar that is rectangle. Something like width 300px and height 150px?


How to use bootstrap for a gallery with modal popup

I use bootstrap for my theme. I want to create a gallery with title and descriptions. Using lightbox or colorbox will add extra code that is not needed since bootstrap has its own built-in popup modal. This guide works to create a basic gallery that uses the modal for popup. The Js is a bit complex for me. The other option I am testing out is to use content types with views. This looks like it might work. How would you go about to create a gallery?


Responsive Development in WordPress Backend

I've gotten so used to using Twitter Bootstrap. However, I can't seem to use it on the backend. I'm assuming it's conflicting with something in the core. So is there a way to get Twitter Bootstrap to work on the backend, or is there some way of figuring out what WordPress core uses? I would like to build responsive admin pages and forms in my meta boxes. Any guidance appreciated regarding Twitter Bootstrap in the WordPress backend OR more information how what WordPress uses and how I can interact with their responsive framework.


the_post_thumbnail returns full sized image, how to debug?

This is a weird situation. I have defined                add_theme_support('post-thumbnails');      add_image_size('190x280',190 , 280,true);      add_image_size('400x600',400 , 600,true);      Uploaded images to post as featured image, on the server side I see the resized images in the uploads folder. In the template, I use code like this               <?php query_posts( 'post_type=hints&posts_per_page=1'); ?>         <?php  if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
             <a class="colblack" title="<?php the_title_attribute(); ?>" href="<?php the_permalink();?>">             <?php the_post_thumbnail('190x280', array('class' => 'img-responsive')); ?>             <?php echo get_the_title(); ?>
      But, the function the_post_thumbnail returns only full sized image! What the $#ck can it be? Because it is really annoying and I can not debug it? And this code I am using on other sites as well and everything works. Do you know, how to debug it?


How to unset comment_notes_before field in WordPress comment_form

I am trying to remove **Your email address will not be published.** line from comment form in twentythirteen and twentyfourteen default themes. I have tried this:               function alter_comment_form_fields($fields){     unset($fields['comment_notes_before']);     return $fields;     }     add_filter('comment_form_default_fields','alter_comment_form_fields');      and this:               function alter_comment_form_fields($fields){     $fields['comment_notes_before'] = '
Email address not required.
';     return $fields;     }     add_filter('comment_form_default_fields','alter_comment_form_fields');      Nothing seems to work. I have also found this ticket https://core.trac.wordpress.org/ticket/14510 Would appreciate if someone can point me to some direction.


Defer all js except certain ones in functions.php file

I read How to add defer="defer" tag in plugin javascripts? and the code @toscho posted works good to defer certain js files or deferring ALL js files by commenting out the contact-form-7 line, but I need to defer all js except 1 or 2 files. I for sure need to exclude jquery.min because it causes the Revolution Slider plugin to stop working when it's deferred. So how would I write a conditional in the following code to exclude certain js files? For example if I wanted to exclude jquery.min and jquery.ui.core.min               function add_defer_to_cf7( $url )         {             if ( // comment the following line out add 'defer' to all scripts             FALSE === strpos( $url, 'contact-form-7' ) or             FALSE === strpos( $url, '.js' )             )             { // not our file                 return $url;             }             // Must be a ', not "!             return "$url' defer='defer";         }         add_filter( 'clean_url', 'add_defer_to_cf7', 11, 1 );


Add custom metabox in posts

I tried to add a custom meta box following some tutorials like this one but I don't why it doesn't saves any value in the box. There is my code:               add_action('add_meta_boxes','initialisation_metaboxes');     function initialisation_metaboxes(){               // Metabox     add_meta_box('comments_link', 'Lien du sujet sur les forums', 'sujet_comements', 'post', 'normal', 'default');     }          function sujet_comements($post){            // Use nonce for verification     wp_nonce_field( plugin_basename( __FILE__ ), 'sujet_comements_noncename' );          ?>     <label for="champ_comments">Lien du sujet</label>     <input type="text" name="champ_comments" id="champ_comments" value="<?php $_POST['champ_comments']; ?>" />     <?php     }           function sujet_comements_save_postdata( $post_id ) {     // verify if this is an auto save routine.     // If it is autosave then our form has not been submitted yet, so we dont want to do anything          if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )         return;     // verify this came from the our screen and with proper authorization,          if ( !wp_verify_nonce( $_POST['sujet_comements_noncename'], plugin_basename( __FILE__ ) ) )             return;          // Check user permissions          if ( 'page' == $_POST['post_type'] )         {     if ( !current_user_can( 'edit_page', $post_id ) )                 return;         }     else     {     if ( !current_user_can( 'edit_post', $post_id ) )                 return;     }          $mydata = $_POST['champ_comments'];          add_post_meta($post_id, sujet_comements_new_field, $mydata, true);     }


Exclude html from search results (image names, etc.)?

We are heavily marking up our pages/posts so there is a lot of html and pictures being used. The problem is that our search results are hitting image names and class names (maybe I have a few other examples but these are the two worst offenders). Anyway to only search on the text showing on the page?


Call current post parameters inside a plugin

I edited the plugin WP User Frontend (for editing posts from frontend) to have two different edit pages for two different post types. Here's the original function which handles the edit_link.               function wpuf_edit_post_link( $url, $post_id ) {     if ( is_admin() ) {         return $url;     }          $override = wpuf_get_option( 'override_editlink', 'yes' );     if ( $override == 'yes' ) {         $url = '';         if ( wpuf_get_option( 'enable_post_edit' ) == 'yes' ) {             $edit_page = (int) wpuf_get_option( 'edit_page_id' );             $url = get_permalink( $edit_page );                  $url = wp_nonce_url( $url . '?pid=' . $post_id, 'wpuf_edit' );         }     }          return $url;     }          add_filter( 'get_edit_post_link', 'wpuf_edit_post_link', 10, 2 );      How can I call the current post parameters inside the function? I used `get_post` but it doesn't work (I guess because it's not inside the loop...). Here's the piece of function I edited. 201 and 203 are correct edit pages IDs: inside the pages there is some shortcode which turns them into an edit page.               $override = wpuf_get_option( 'override_editlink', 'yes' );     if ( $override == 'yes' ) {         $url = '';         if ( wpuf_get_option( 'enable_post_edit' ) == 'yes' ) {              $post = get_post($post_id);              if ($post->post_type == 'type1') {             $url = get_permalink( 201 );             $url = wp_nonce_url( $url . '?pid=' . $post_id, 'wpuf_edit' );         }              if ($post->post_type == 'type2') {             $url = get_permalink( 203 );             $url = wp_nonce_url( $url . '?pid=' . $post_id, 'wpuf_edit' );         }         }     }      What's wrong with this code?


Loading bbPress CSS file only on forum directory

I added bbpress forum pluggin in my site to handle discussions, forum or comments. The bbPress CSS file is added to every page of my blog. Now, I want to load it only on forum directory to consider page speed. Is there any way to do this?


Custom title, Bones theme

I'm a total wordpress noob and ran into my first problem. I downloaded this theme. My question is how do I change how the `p#logo.h1` is shown. I would like to put a `<br />` in the middle of my title, and half in a custom . So the html of the title should be something like:

This is a
Big title

      How can I change that?


Error: options page not found

This error is really well known and every where I look its either I am not doing:               <form method="post" action="options.php">      or I am not registering my options, which is not the case as seen in the following class:               class CoreTheme_AdminPanel_Admin implements AisisCore_Interfaces_Admin{              public function __construct(){             add_action('admin_menu', array($this, 'menu_setup'));             add_action('admin_init', array($this, 'register_settings'));                  add_option('success_message', false);         }              public function init(){}              public function menu_setup(){             add_menu_page(                 __('Aisis', 'aisis'),                  __('Aisis', 'aisis'),                  'edit_themes',                  'aisis-core-options',                  array(                     $this,                      'build_template'),                       get_template_directory_uri() . '/images/block.png',                      31                 );                  add_submenu_page(                 'aisis-core-options',                  __('Aisis BBPress Options', 'aisis'),                  __('Aisis BBpress Options', 'aisis'),                  'edit_themes',                  'aisis-core-bbpress',                  array(                     $this,                      'build_template'                 )             );                  add_submenu_page(                 'aisis-core-options',                  __('Aisis Packages', 'aisis'),                  __('Aisis Packages', 'aisis'),                  'edit_themes',                  'aisis-core-packages',                  array(                     $this,                      'build_template'                 )             );                  add_submenu_page(                 'aisis-core-options',                  __('Aisis Update', 'aisis'),                  __('Aisis Update', 'aisis'),                  'edit_themes',                  'aisis-core-update',                  array(                     $this,                      'build_template'                 )             );         }              public function register_settings(){             register_setting(                 'aisis_options',                  'aisis_sitedesign',                  array(                     $this,                      'option_validator'                 )             );         }              public function build_template(){             $template = AisisCore_Factory_Pattern::create('CoreTheme_Templates_Builder');             $template->render_template(CORETHEME_ADMIN_TEMPLATES . 'coretheme.phtml');         }              public function option_validator($input){             $option = get_option('aisis_core');             $option = $input;             update_option('success_message', true);             return $option;         }     }      so why am I getting this error?, my settings are registered, the form renders, everything seems to be fine....


How to update avatar in buddypress programmatically? I have a script, which gets the image url and I want to update the url in the database, so that that image will will be avatar of the user.


resizing of thumbnails not working

i have the following in my functions file from the wordpress codex               <?php add_filter('show_admin_bar', '__return_false');     if ( function_exists( 'add_theme_support' ) ) {     add_theme_support( 'post-thumbnails' );         set_post_thumbnail_size( 150, 150 ); // default Post Thumbnail dimensions        }          if ( function_exists( 'add_image_size' ) ) {      add_image_size( 'category-thumb', 300, 9999 ); //300 pixels wide (and unlimited     height)     add_image_size( 'homepage-thumb', 220, 180, true ); //(cropped)     };  ?>      And the below to call the thumbnail in my custom loop               <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'category-thumb' ); } ?>      However it doesnt seem to be resizing the thumbnails. Can anyone advise?


Visual Editor not working when Jetpack plugin is active

After installing the Jetpack plugin, the visual editor stopped working. The Visual tab is still there but the editor area is empty and the toolbar is missing. I have deactivated all other plugins and the problem is still present. (The only other one was Restricted Site Access). Disabling Jetpack (or disconnecting it from Wordpress.com) fixes the problem, but I would like to use some functionality from Jetpack. Has anyone else seen this problem, and is there a fix? Is it a particular Jetpack configuration that causes this? I saw several complaints online, but not fixes.


dynamically filter by category via sub-menu

I'm trying to figure out if it's possible to dynamically filter my custom post types by category via a sub-menu I have set up.      So I've set up a custom post type: `news` and enables categories that I can assign to each post, e.g. events, specials, exhibitions etc.   Then I've set up a WP menu that links to these categories, currently though I have set-up a separate category template for each category archive.   e.g. `category-11.php` (category ID: 11) which queries the news posts like so: `<?php query_posts('post_type=news&cat=11'); ?>`   and   `category-12.php` (category ID: 12) which queries the news posts like so: `<?php query_posts('post_type=news&cat=12'); ?>`   and so on and so on...   BUT as I'll be handing this site over, the client wont be able to set up a new template file for every new category they add. So is it at all possible to dynamically filter the categories via the sub-menu using the `category.php` file instead of setting a new template up each time?   A bit of a long shot, I know. Any suggestions would be greatly appreciated!


2 wordpress loops showing 1 post from same post type - how to avoid showing the same post?

I got to two loops in my template files. Both querying the same thing essentially. This loop in my header:               $testimonial_head = new WP_Query(array(         'posts_per_page' => 1,         'post_type'     => 'testimonial',         'post_status'   => 'published',         'orderby'   => 'rand'          ));          if ($testimonial_head->have_posts()) :      and this loop in my side bar:               $testimonial_sidebar = new WP_Query(array(         'posts_per_page' => 1,         'post_type'     => 'testimonial',         'post_status'   => 'published',         'orderby'   => 'rand'          ));          if ($testimonial_sidebar->have_posts()) :       When these are running that same time, what would be a method of stopping the sidebar query showing the same post as the first header query? I just never ever want a duplicate to be shown.


Removing unnecessary numbers appended to postname in permalinks

I have, with help from Milo managed to tweak the permalinks for my custom post type so that they include the year and month of the event. e.g.   * `mysite.com/events/2013/january/fishing-trip`   * `mysite.com/events/2013/may/picnic`   * `mysite.com/events/2013/may/visit-grandma` One small issue still evades me. If there is more than one event with the same name, WordPress appends a number to the end of the name even when the month is different and so there is no need for the name to be unique. In other words I get   * `mysite.com/events/2013/january/fishing-trip`   * `mysite.com/events/2013/may/picnic`   * `mysite.com/events/2013/june/fishing-trip-2` when I want   * `mysite.com/events/2013/january/fishing-trip`   * `mysite.com/events/2013/may/picnic`   * `mysite.com/events/2013/june/fishing-trip` Is there a solution for this? I've got permalinks set to "postname" in permalink settings if this matters.


Why is our post editor stuck at cols=40?

We recently upgrade Wordpress and it appears that our post editor is a very narrow textarea. Its stuck at 40 characters wide. Its very challenging to work with. More specifically its stuck with these properties:                <textarea class="wp-editor-area" style="height: 360px" cols="40" name="content" id="content">      There doesn't appear to be any ability to drag to widen the textarea. Moreover, there is a giant wasted dead space to the right of the editor control. I can't imagine what we could have done to cause this? I'd like to make posting blog articles easier, and the narrow editor makes it a bit painful to use.


Accessing + retrieving custom database in WordPress

I am looking for something really simple(?). I am using WordPress as a CMS. I created a new page in which I added a form (questionnaire). Inside WordPress' database (the same database in which all WordPress data are), I created a new table called "ExampleTable". Now I have 2 questions: 1) How can I insert data from the form into that custom table? 2) Is is "okay" to add a custom table (which has nothing to do with WP inside WordPress' database, or should I create a new database?) Thanks :)


Hook on Add new category from post editor

How can I "hook" on Add new category metabox from post editor page? I need to add some default values to DB when adding new category


When should add_rewrite_tag() be used?

I've spent a few days trying to learn how to best add rewrite rules. So far my understanding is that a suitable way to add simple rules is to use `add_rewrite_rules()`, with large thanks to Jan Fabry on this exchange who's elaborations have been of great use. Although he mentions `add_rewrite_tags()` I haven't seen a guide on it explaining when it's beneficial to use it, as opposed to other ways to add rewrite rules, or any good examples on its usage. It seems to be a more powerful tool, but that's about all I can fathom. I find the examples in the Codex to be too cryptic or incomplete. Could someone elaborate on it or point to some resource? I found nothing useful on Google. _**edit:_** Its Codex page talks about 'generally' using it in conjunction with `add_rewrite_rules()`, but doesn't elaborate. Similarly the Codex page for `add_rewrite_rules()` refers to `add_rewrite_tags()` but it too is very sparse on information. When and how would such a combination be used? The only example I found is this answer by Rob Vermeer which I don't understand.


Getting subpage of subpage - Custom posts

I have one page with custom posts. They are shown in one page with a list, you can choose one page and when you get to that page I need to show subpages of that page. Here is so far ive made it, its the first page with the custom posts:                 <select name="select_page" id="select_page" class="select_page" data-mini="true" data-theme="c">              <?php             $pageId = 5;             $subpages = get_pages( array(             'child_of' => $pageId,             'sort_order' => 'asc',             'sort_column' => 'menu_order') );         ?>                      <?php if($post->post_parent) {?>         <option value="<?php echo get_page_link($pageId) ?>" >Startpage</option>         <?php } else {?>         <option value="<?php echo get_page_link($pageId) ?>" selected="selected">Startpage</option>         <?php } ?>      That was for the list, I need to show subpages of that subpages and show it in the list also.                  <?php                                            foreach($subpages as $page) { $i++;         $pages[] += $page->ID;               ?>         <?php if($page->post_title == get_the_title()) {?>         <option value="<?php echo get_page_link($page->ID) ?>" selected="selected"><?php echo $i.'. '.$page->post_title ?></option>         <?php } else {?>         <option value="<?php echo get_page_link($page->ID) ?>"><?php echo $i.'. '.$page->post_title ?></option>  <?php } ?>         <?php }?>               </select>      My question is: **How can I show subpages of that subpage ?**


Cannot change Connection Information in admin interface

There are 11 plugin updates available for a WordPress site, so I tried updating it. However, when I do that I get an error:               Public and Private keys incorrect for <username>      I have made keys for my own user on the server, but that is not the problem I am asking about. The problem is that I cannot change any details in the Connection Information page (shown below). There are details already there, but they cannot be changed. I can select them, but I cannot delete or edit them. I have tried in different browsers. What could be causing this? My WordPress account is set as an Administrator. * * * ![Connection Information](http://i.stack.imgur.com/jCye1.png)


Breadcrumbs which show parent category as well as childcategory

there is any plugin to show breadcrumbs included child category also most of plugin support for parent category for example : home >category 1 >subcategory 2 >subcategory 3 >post (most of time we are here) but is it possible that we able to show child category also for example if i m at subcategory 2 then its shows home >category 1 >subcategory 1 (we are here) >subcategory 2 >subcategory 3 >subcategory 4 please suggest me


Error in importing wordpress xml

Iam trying to import my old xml to a newly installed wordpress(3.0.1), the max upload size shows 0, `i tried uploading it, but it ended up with empty screen. How should i proceed?`


Rename a row action label

I would like to simply rename "Delete permanently" to "Delete", without having to mess with the Wordpress core files. It's worth knowing that I'm using a translated version of Wordpress. So the "Delete permanently" action is already translated but the translated string is too long to fit my needs. How can I do that from functions.php? Any help would be appreciated.


Plupload Intergration in a meta-box?

I know that plupload is going to be the new upload engine for WordPress 3.3 but I was wondering if there is any documentation yet on how it integrates with WordPress. My specifically how to collect a response from the plUpload jQuery object once it has uploaded the media that you want and how one would use the same functionality in a meta box to create a gallery? Has anyone played around with it, yet?


Wordpress Mobile Edition not working with WP v3.5

Since upgrading Wordpress from 3.4.2 to 3.5, Wordpress Mobile Edition has not worked. I have left a support request on the plugin's support page, but have received no reply in 2 weeks. I might have to conclude the plugin author is no longer supporting this plugin. I know this question might breach guidelines, but is there a ready alternative to using Wordpress Mobile Edition? Perhaps this doesn't have to be a plugin, but might be a Wordpress hack. I have a customised version of Carrington Mobile I'd like to retain.


Use premade array as categories in wp_query?

I have a theme options panel that the user can set which categories they want to use which is then saved as an array $blog_cat[0] etc. They can select as many categories as they want for the array and it saves the category number not slug. I am having trouble when I go to make a wp_query using these settings. How can I take that array and use it in the wp_query? If I use the following bit of code it will output all of the categories: $catnum = 0; foreach($blog_cat as $blogcats) {echo $blog_cat[$catnum]; $catnum++;} However, I can't use this in the actual wp_query which looks like this: $wp_query = new WP_Query('category_name=' . $blog_cat . '&showposts=3'); I can target them individually but not dynamically regardless of how many are set. I'm guessing this isn't a very hard problem to fix but I don't know enough about the syntax to figure out how.


Problem Uploading PDF Vouchers w/ WooCommerce

Whenever I try to create a PDF voucher for customers using the PDF Product Voucher extension for WooCommerce I get **"FPDF error: Image file has no extension and no type was specified: /home/my_site/public_html/wp- content/uploads/"** when I hit the preview button. What's going wrong? Why can't I upload my PDF voucher? :'(


Add 2 values to post__not_in

How can I add to values to the post__not_in function? For example, I want to exclude $value1 and $value2 from a loop Any ideas? Thanks in advance


Get menu links only

I'm creating a template in HTML5. On navigatiom menu i need to implement something like this                     url1      url2      url3      url4      ...      urln           If i use 'wp_nav_menu', it prints

      when i need just                     There is a way to get that? Thanks!


Check if user is on backend page

i trying to run a script only on packed page... but i cant find the right hook here is my script               function posts_for_current_author($query) {         global $current_user;         if($current_user->data->wp_user_level < 9) {             global $user_ID;             $query->set('author',  $user_ID);         }         return $query;     }     add_filter('pre_get_posts', 'posts_for_current_author');


Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?

I am having a bit of a strange issue with rewrite rules not flushing properly. I have tried using `flush_rewrite_rules();` and `flush_rewrite_rules(true);`. I have also tried globalizing `$wp_rewrite` using `$wp_rewrite->flush_rules();` and `$wp_rewrite->flush_rules(true);` Neither of which appear to be flushing the rewrite rules correctly. Those calls are indeed flushing the rewrite rules when called. How do I know this? Using the solution for debugging rewrite rule flushing. Currently, I have rewrite rules flushed on plugin activation and plugin deactivation. No issues there. I have an plugin administration settings page for users to configure the plugin. Some of the settings adjust the permalink structure, so the rewrite rules are required to be flushed on plugin administration settings page "Save Settings". (Uses the standard `update_option();`) for saving settings. I would like to note that depending on the settings specified, custom post types are created to match user specified settings. So the rewrite rules must be flushed immediately after the settings are saved. This is where things aren't functioning appropriately. The above link solution for debugging rewrite rules provided by `@toscho` is displaying that it's flushing tons of rewrite rules. However, when visiting the custom post type singular item, or even custom post type archive for that matter, each return as 404 errors. The custom post type is registered correctly and appropriately. I know for certain that is not the issue. Immediately following with the plugin administration page settings save. The custom post types are created, permalink structure is adjusted, and all rewrite rules are attempted to be flushed. The custom post types are then loaded always, and loaded on `init` like normal. For some reason, the rewrite rules aren't flushing properly, because like I said before, visiting singular or archive sections of the custom post type return 404 errors. Now the weird part, if all I do is simply visit the administration permalinks settings page, and then go back to the front end to view either singular or archive sections of the custom post type, they magically work as expected. **What does that administration permalinks settings page do that I'm not doing that allows the rewrite rules to flush appropriately and mine do not?** I mean, as a temporary solution, I am redirecting the user to the administration permalinks settings page after saving the plugin administration settings page, but this is not an ideal solution. I'd prefer the rewrite rules just flush properly within my plugin's code. Is there a certain point in WordPress where flushing the rewrite rules just doesn't flush ALL the rules anymore? `admin_menu` \- Plugin settings page is added to WordPress administration. `add_options_page()` \- Plugin settings page is added under Settings menu. Settings page is rendered in the callback for `add_options_page()`. This is also where `$_POST` is processed for updating plugin settings and flushing rewrite rules. Since this is already a long question, I would be willing to provide code blocks (if it helps) in an offsite link that to assist producing a valid answer.


Use $_POST['value'] inside functions.php

Is it possible to use a value stored in POST on a page inside the functions.php file? First on the . after the "20" I want to add the category__in value to the query_vars. And thats where I want to return the values stored in a POST which I submit trough a form on the page               // set number of projects displayed for pagination     function project_posts_per_page( $query ) {              if ( $query->query_vars['post_type'] == 'watches' )             $query->query_vars['posts_per_page'] = 20 .             $query->query_vars['category__in'] = 53;                  // This should be something like this:             // $query->query_vars['category__in'] = $_POST['category'];                  // So when I select one, or more categories in my checkbox based form it updates the pagination                               return $query;     }     if ( !is_admin() ) add_filter( 'pre_get_posts', 'project_posts_per_page' );


How do I properly register bootstrap JavaScript into WordPress functions.php?

I am new to bootstrap and WordPress and trying to put together a simple page. So, it doesn't surprise me that I'm running into dependency problems adding and registering scripts from both the header and footer. Is there anything obvious here that I'm missing?               <?php      function wpbootstrap_scripts_with_jquery() { // Register the script like this for a theme: wp_register_script( 'custom-script', get_template_directory_uri() . 'js/bootstrap.js', array( 'jquery' ) );          // Register the script like this for a theme:     wp_register_script( 'custom-script', get_template_directory_uri() . 'js/jquery.tweet.js', array( 'jquery' ) );               // Register the script like this for a theme:     wp_register_script( 'custom-script', get_template_directory_uri() . 'js/clock.js', array( 'jquery' ) );               // Register the script like this for a theme:     wp_register_script( 'custom-script', get_template_directory_uri() . 'js/soon.js', array( 'jquery' ) );     //footer scripts          // Register the script like this for a theme:     wp_register_script( 'custom-script', get_template_directory_uri() . 'js/dat.gui.min.js', array( 'jquery' ) );               // Register the script like this for a theme:     wp_register_script( 'custom-script', get_template_directory_uri() . 'js/fss.js', array( 'jquery' ) );               // Register the script like this for a theme:     wp_register_script( 'custom-script', get_template_directory_uri() . 'js/bgCustom.js', array( 'jquery' ) );               // For either a plugin or a theme, you can then enqueue the script:     wp_enqueue_script( 'custom-script' );     } add_action( 'wp_enqueue_scripts', 'wpbootstrap_scripts_with_jquery' );          ?>


Upload files into buddypress profiles

Someone knows any plugin or method to allow users to upload files into their profiles? I mean i can link those files later to their profiles is the files are linked to users some way. I want to allow my users to upload papers, pdf , etc and then show those files on their profiles. Thanks in advance!!


Installing themes from an external website

**What I am doing** I am looking for WP theme for an android app. As I couldn't find any searching on WP I looked up on Google and I found that every Theme I found are not available on WP theme search. An example of this is this webiste **So, worring on the quality/security of these themes:** Why are they not available? Regards,


Number of post for a WordPress archive page

I want to be able to change the amount of post shown on each archive page on a per category basis. Is there something I can change in the loop code or a plugin that gives me that ability? Thank you SE community.


Wordpress Menu options in the Admin: Posts for the dropdowns

Under Appearance > Menus I seem to be able to add Categories, Pages, or Custom Links as my menu/sub- menu dropdown items...but I can't add posts. I would like to have posts in my dropdown (posts of a given category), but I can't seem to do this without writing custom links, which is going to be time- consuming. Is there any way around this?


How can I gracefully escape an error condition?

My plugin is freezing the execution of the page at the point where it calls the functions below. I have two problems... 1) How can I recode the function so that if there is an error, the plugin does not stop the page from loading, but rather, returns an error message? 2) How can I feedback what the error might be? Its just freezing but not outputting the error.               function rseo_get_seo($check, $post){      //return false;         switch ($check)         {         case "h1": return rseo_doTheParse('h1', $post);         case "h2": return rseo_doTheParse('h2', $post);         case "h3": return rseo_doTheParse('h3', $post);         case "img-alt": return rseo_doTheParse('img-alt', $post);         }     }          function rseo_doTheParse($heading, $post)     {         $content = $post->post_content;         if($content=="") return false;         $keyword = trim(strtolower(rseo_getKeyword($post)));         @$dom = new DOMDocument;         @$dom->loadHTML(strtolower($post->post_content));         $xPath = new DOMXPath(@$dom);         switch ($heading)             {             case "img-alt": return $xPath->evaluate('boolean(//img[contains(@alt, "'.$keyword.'")])');             default: return $xPath->evaluate('boolean(/html/body//'.$heading.'[contains(.,"'.$keyword.'")])');             }     }      Here's my attempt to change the 2nd function with try catch but I get a fatal error on plugin activation...               function rseo_doTheParse($heading, $post){     try { //I get a FATAL error here. unexpected '{'         $content = $post->post_content;         if($content=="") return false;         $keyword = trim(strtolower(rseo_getKeyword($post)));         @$dom = new DOMDocument;         @$dom->loadHTML(strtolower($post->post_content));         $xPath = new DOMXPath(@$dom);         switch ($heading)             {             case "img-alt": return $xPath->evaluate('boolean(//img[contains(@alt, "'.$keyword.'")])');             default: return $xPath->evaluate('boolean(/html/body//'.$heading.'[contains(.,"'.$keyword.'")])');             }         }         catch (Exception $e)         {             echo 'Exception caught: ',  $e->getMessage(), "\n";         }     }


Does WordPress have a built in reference to the PHP version its running under?

I have a plugin that has a single method that requires PHP5. How can I code around the fact that the server may have PHP4? Code is below... (I'm thinking its the DOMDocument object that's freezing the plugin when running on a PHP4 server.               function rseo_doTheParse($heading, $post){         $content = $post->post_content;         if($content=="" || is_php4()) return false;         $keyword = trim(strtolower(rseo_getKeyword($post)));         @$dom = new DOMDocument;         @$dom->loadHTML(strtolower($post->post_content));         $xPath = new DOMXPath(@$dom);         switch ($heading)             {             case "img-alt": return $xPath->evaluate('boolean(//img[contains(@alt, "'.$keyword.'")])');             default: return $xPath->evaluate('boolean(/html/body//'.$heading.'[contains(.,"'.$keyword.'")])');             }     }               function is_php4(){//code here}


%tag% in permalink not working

I use custom permalink structure: /%tag%/%postname%/ and it is not working. I get url - http://mydomain.com/%tag%/post/. So there is no tag name, just %tag%. If i place %category% instead ot %tag%, everithing is ok. Can somebody solve this problem?


Add category slug as class attribute in a link array

This incredible website and the genius developers here have helped me significantly in the course of my WP Dev over the years, firstly THANK YOU. I am now faced with a problem that I have been trying to find a solution to for the past 3 days and is driving me insane, but might be easy for one of you genius's! The problem... I am using the excellent Microkids Related Posts plugin and I am trying to make a seemingly simple change to the code and the link that is outputted to show the Parent Category Slug of a post as a class, so that I can use it as a global stable unique identifier. The foreach loop is as follows...               foreach( $related_posts as $post_type => $post_type_related_posts ) {         # This filters %posttype% from the title         $title = MRP_get_title( __($options['title'], 'microkids-related-posts'), $post_type );         if( count( $post_type_related_posts ) ) {             $output .= "
\n";             # Create the title with the selected HTML header             $output .= "<".$options['header_element'].">".$title."</".$options['header_element'].">\n";             $output .= "
\n";             # Add related posts             foreach( $post_type_related_posts as $related_post ) {                 $output .= "
";                 $output .= "ID )."\">".$related_post->post_title."";                 $output .= "
\n";             }             $output .= "

\n";         }         # If there are no related posts for this post type         else {             if( !$options['hide_if_empty'] ) {                 $output .= "
\n";                 $output .= "<".$options['header_element'].">".$title."</".$options['header_element'].">\n";                 $output .= "
".$options['text_if_empty']."
\n";                 $output .= "
";             }             else {                 # Show nothing                 return "";             }         }     }     $output .= "
";     return $output;      In the inner foreach loop is the line...               $output .= "ID ."\">".$related_post->post_title."";      I would like to add a class in the "a" containing the Category Slug so that I can reference that later.   1. my-domain/photo-shoot-location/knights-3/   2. my-domain/press/knights-3/   3. my-domain/photo-meta-data/knights-3/   4. my-domain/about/knights-3/ etc. I would like for it to look as follows...               $output .= "ID )."\">".$related_post->post_title."";      With `THE-CATEGORY-SLUG` to be "`photo-shoot-location`" or "`press`" etc. Any help would be greatly appreciated. Thank you so much in advance!!!!!


Blog posts permalinks correct but recent post widgets goes to my website and not staying on my blog site

I am a novice, but I have my website, online store and blog looking the way I want them. I had to change my blog theme because the widgets were in the wrong place so I chose another theme (raindrops). The only problem is that my blog widgets such as categories, recent posts, etc., when clicked on go to my website instead of my blog site. The blog and store are subdomains under digitaldesignzonline.com and all have separate folders and wordpress installs. My website digitaldesignzonline.com (so far) is working great, and my store: digitaldesignzonline.com/store seems to be also. The only problem is my blog: digitaldesignzonline.com/blog. When I click on the recent posts widget in the sidebar, the address show the correct post link and name, but actually goes to my website (digitaldesignzonline.com) My blog pages direct back to the website, but that doesn't bother me. I think it is where the problem may be? It is a child theme. I have tried different themes, deleted a ton of plugins that were not activated, checked the permalinks settings, and tried everything I can think of. I have googled for 12 hours and can't find the problem. Please help me before I have a stroke trying to figure this out!   PS I am a novice at php, etc., but can follow instructions if clear and precise. You will be my hero if you can help me!


Changing siteurl and homeurl - internal links redirect to home page?

My new site was initially set up with an IP address (say http://123.123.12.12/). I later changed the siteurl and homeurl to my domain (say xyz.com). I also pointed the domain to the IP address so I don't lose out on the indexing in search engines. But now whenever I click on any of the links in the home page, it redirects back to http://123.123.12.12/ instead of going to http://123.123.12.12/newpage/ The anchor tag shows the URL as http://xyz.com/newpage/ Any relative URLs on any other pages work fine. But otherwise all links (from the menu) redirect to the home page. To summarize, any urls saying http://xyz.com/somepage redirect to home page Any ideas what I might be missing? Thanks. P.S. I changed the siteurl and homeurl in the database directly. Do I need to change it on the Wordpress Settings page as well?


Can't see themes for Multi-site wildcard subdomain

I have successfully enabled wildcard subdomains and everything is working except for enabling themes besides the default. All of the plugins in the root plugin directory are available but none of the other themes I have in the theme folder are showing up. Any ideas?


What are non-printable characters doing in my theme?

> * REQUIRED: Non-printable characters were found in the 'functions.php' file. > You may want to check this file for errors. What are non-printable characters and how can I correct it?


Custom post type hierarchical permalinks not behaving as expected for parent/child pages

When you have Pages with children, the permalink structure works something like this: > example.com/parent-page/child-page/ All well and good. Trying to go to this URL: > example.com/child-page/ doesn't work, which is good, and as expected - I only want the one URL for my child page. However, I've set up a custom post type, and set it to be hierarchical, so as to behave like pages. It doesn't quite work the same way: > example.com/custom-post-type/parent-page/child-page/ works as expected, but removing the parent page from the URL: > example.com/custom-post-type/child-page/ also displays the child page. It should 404, I would have thought. I've used the following args to register_post_type:               $args = array(         'labels' => $labels,         'public' => true,         'publicly_queryable' => true,         'show_ui' => true,          'show_in_menu' => true,          'query_var' => true,         'rewrite' => array('slug'=>'custom-post-type','with_front'=>false),         'capability_type' => 'post',         'has_archive' => false,          'hierarchical' => true,         'menu_position' => null,         'supports' => array('title','editor','thumbnail','excerpt','revisions','page-attributes')     );       It's entirely possible I've misunderstood some of the options though. Can someone tell me if I'm doing something wrong, or if this is a bug or a feature? I'm using 3.2.1, with no plugins, just my custom theme. Thanks,


Rewrite custom taxonomy slug - but only parent items

I've set up a custom hierarchical taxonomy called 'region'. So now I have e.g. `url.com/region/leeds/` etc. However, I'm now expanding to other countries, so I'm making the region sub- categories of the parent. I want to rewrite the parent category URL to lose the `/region` and instead become `url.com/region/uk` -> `url.com/uk`. Can I use WP_Rewrite and hook into `category_rewrite_rules` and check if the taxonomy is a parent and then supply the edited URL?


Create not-activated user in code, wordpress

I'm doing a site in wordpress and I need some help.   I have a custom registration form where users can sign up and get special roles, but I want to save the users to the database as not activated so that the admin activates them through a plugin. Problem is that the code I'm using, just saves the user in the db immediately and the account is usable. Any ideas on how to create a new user as not activated?               $newUser = wp_create_user($un, $pw, $em);                 if (!$newUser || is_wp_error($newUser)) {                        $error = "[:en]Please fill in all fields.[:it]Please fill in all fields.";             } else {                 $userinfo = array('ID'=>$newUser, 'first_name' => $fn, 'last_name' => $ln);                    wp_update_user($userinfo);                 update_usermeta($newUser, 'company', $co);                 $user = new WP_User($newUser);                 $user->remove_role('subscriber');                 $user->add_role($tp);                 $success = "[:en]Your registration has been submitted for approval.[:it]Your registration has been submitted for approval.";                 wp_new_user_notification($newUser, $pw);             }


Allow an editor to change the author

I am using wordpress multi user and have a set of users set up as Editors who wish to ghost write for another user who is an author. How can they change who the author of the posts is without the author having to review each post? I can only seem to edit it under quick edit if I am logged in as the author.


Any way to "combine" galleries or show multiple galleries as one?

So let's say I run a TV show blog. One day, the show releases to the public a set of 10 screencaps from an upcoming episode. I post that on my blog, either as a post with multiple images, or specifically as a "gallery" post -- either way, readers can view all the image attached to that post as a gallery. Then, several days and several posts later, they release 10 more screencaps from that same upcoming episode. I want to make a separate post rather than bump the old one, but I also somehow want to be able to display all screencaps (20) from that particular episode in a single gallery. Or at least what would look like a single gallery. Possible? (Preferably without NextGEN or other plugins... trying to accomplish as much as I can using WordPress' native capabilities before stacking plugins.)


Where to insert the other site image url for our wordpress post

I am scrapping contents from my others sites into my wordpress site, i did all and below is my insert query               $my_post = array(        'post_title'    => $my_title,        'post_status'   => 'publish',        'post_author'   => 1,        'post_category' => array(5),        'post_content'  => $res_final,        'post_date'     => date('Y-m-d H:i:s'),        'post_date_gmt' => date('Y-m-d H:i:s'),        'post_type'     => 'post'      );           $post_id = wp_insert_post( $my_post );      I can able to insert my titles and contents and yes it is displaying :), even i can see images inserting into the post as image comes along with the content, but i have planned to take the image alone from the content and stored separately as a post image so that it will come in the front page. Any help on how to add the image into the post, and what is the best way to insert my image URL, an insert query to do this. Please help me


Remove default quicktags

I only want to display a subset of the buttons on the html editor button bar. What is the proper way to remove some of the quicktags? For intance I don't want it to offer "proofread".


Showing latest post without 301 redirect

My WordPress website is now redirected to latest post by adding below function to `function.php`               add_action( 'template_redirect', 'redirect' );     function redirect() {         $args = array(         'numberposts' => 1,         'post_type' => 'seller',         'post_status' => 'publish');         $last = wp_get_recent_posts($args);     $last_id = $last['0']['ID'];             if ( is_home() && ! is_paged() && ! is_archive() && ! is_tag() && !isset($_GET['ptype'])  ) :                  wp_redirect( get_permalink($last_id) , 301 );                           exit;             endif;     }      now, I want this feature but without changing URL to latest post! I mean when you go to http://www.example.com latest post shows **without a 301 redirect** to http://www.example.com/article/some-other-texts


functional quicktag

I want to add quicktags that do more than just add markup. For instance, I would like to add a quicktag to run a function do apply a js regex on the page content. How can I add a quicktag that executes a function? To give a specific example, I would like to add a button that removes all markup tags in the entire post text. This is analogous to the predefined quicktags for finding unmatched tags, or "proofread", etc.


Remove “sites/{blog-id}” from wodpress mu images url

I have a problem with wordpress mu pictures and files urls. Wordpress picture urls in 3.7 version has changed to http://blog.yoursite.com/sites/blog-id(2)/file.img type. ("sites/blog-id" added) I have one site that must move to the multisie. I moved all pictures to the subdomain (for example sub.yoursite.com). and Now I have to in the wpmu set the image url to befor pattern. but "sites/1" in the images file urls, conflict with old image url. I want remove "sites/1" form those new url in wordpress multisie. Help Please...


How to include custom field in shortcode (do_shortcode) in theme file

To cut out a few steps and make it easier for authors, I have included a custom field for authors to enter details (may include HTML). I want to add the custom field to a shortcode in the theme. From multiple sources, I have a few sets of code, but the custom field is not displaying:               <?php if ( get_field('test_field') ):      $testfield = get_field("test_field");     ?>       <?php echo do_shortcode('[shortcode]'. $testfield . '[/shortcode]'); ?>        <?php endif; ?>      I have also tried:               <?php if ( get_post_meta($post->ID, 'test_field', true) ) {         echo do_shortcode('[shortcode]'. printf(get_post_meta($post->ID, "test_field", true)) . '[/shortcode]');     } ?>      I'm sure it is a simple solution, but I can't figure it out.


How to make a custom menu based on a category or tag?

I'd like to have a sidebar widget that has my latests featured posts, which would be marked as a category or tag. Is there a way to do this with the new custom menus, and if not, is there a plug-in that can accomplish this?


Filtering Children of the “uncategorized” Category out of the Loop?

I have some utility categories that are only used by my theme. To help separate these categories I place them all as children of uncategorized. How can I make sure that any call to wp_list_categories() excludes the child categories under "uncategorized" cat_id = 1? I want this to work even if the call wp_list_categories() comes from a third party plugin that I don't control. Perhaps a filter I can place in functions.php that intercepts any call for the wp_list_categories() function to attach the exlude_tree = '1' to the arguments. For example, in my own categories plugin widget, I use this...                   <ul>     <?php         $cat_args['title_li'] = '';         $cat_args['exclude_tree'] = 1;         wp_list_categories(apply_filters('widget_categories_args', $cat_args));     ?>         </ul>


Re-order posts inside tax query

I have some posts having some custom fields and their value. I have custom fields like `featured` and `expiry_date`, whose values are `yes/no` and `some date` respectively. All these posts are coming under custom taxonomy called `stores`. My requirement is to list posts like, featured posts first and then other posts and order by `expiry_date` , `ASC`. Below is my code but it's not working properly.               add_filter( 'pre_get_posts' , 'orange_alter_posts' );          function orange_alter_posts( $query ) {              if(is_tax('store')) {             $query->set('meta_query', array(                                                 array(                                                     'key'       => 'featured',                                                     'value'     => 'yes',                                                 )                                             )                         );         }     }     add_filter('posts_orderby', 'alter_posts_orderby');     function alter_posts_orderby($orderby_statement) {         global $wpdb;         $orderby_statement = "('listing_expiry_date')";         return $orderby_statement;     }      Sorry for the question title, it's may not matching to the description. Could anyone help me in this regard?


How to Make your Category Titles have H1 tags?

I´m using the atahualpa theme and have the category titles displayed on the category pages. I want the title to have H1 Tags and the site name and info H3 tags. Right now, the category titles have H2 tags and the site name and info H1. (actually, the only place I want them to have H1 tags is on the homepage) If you are an expert, please help me out.


Difference between bloginfo('home') and home_url() and site_url()

I have been reading through Codex and other SO and SE posts regarding this. But I am confused. I used home_url() and site_url() to linking the site's home and it gave same results. As I was using qTranslate for bilingual implementation. And had its language switcher. Found later, when clicked on the home logo (used `home_url()` and `site_url()`) the current language didn't persist. Because, I am using one language as default and which would just produce http://example.com And for other language it would be http://example.com/ar Later I found that, using `bloginfo('home')` solves it. The url now carries the language suffix with the home URL. As these posts say the bloginfo() functions are being deprecated. I am really confused.


Wordpress search issue with searching html tags

I am working on a wordpress site and I am using wordpress native search. When we search for a string like "example" it searches inside html tags. ie if there is any html tag like `<a href="http://example.com">` in the page or post then the search result will show that particular page or post. I dont want to search inside html tags. I already tried using the plugin Search Exclude HTML Tags But it uses MySql stored function which is not working for me. I think it may be issue with the permission of my mysql user. Is there any alternate way to fix this. Thanks Pramod


Plugin - Make sure jquery is loaded in my settings page plus my JS file

I'm creating my first wordpress plugin and I'm struggling to find the correct and best way to make sure jquery and my own JS file is included on my settings page of my plugin. I do not need them to load anywhere else unless on my settings page. What code and where do I put it in my plugin? This is what I have so far as for creating the settings page:               add_action("admin_menu", "create_admin_pages");          function create_admin_pages() {         add_submenu_page('options-general.php', "MYPLUGIN", "MYPLUGIN", 10, "my-plugin", 'settings_page');     }     functions settings_page() {         // Settings form is here and I need Jquery and my script loaded for this     }      EDIT: The code above is somewhat been dumbed down so not to reveal the plugins function until its ready to be released. The Plugin I'm coding is wrapped in a class so its ok that the function names are generic.


My custom title gets duplicated at every save or post update

I have a problem, my custom title keeps getting added at every time I save the post.. First I created a Custom Post Type called 'imac' plus a front-end form for posting in this Post Type, only before saving I would like to change the ['post_title'] based on the Custom Fields people fill out on the front-end form aswel. Every post people create front-end will get a 'pending' post_status but as soon as I press Publish or edit the post later and press update the title gets added too. for example: example.com/imac-lala-blabla/ becomes after a second save: example.com/imac-lala-blabla-lala-blabla/ Can somebody help me please.               function modify_imac_title( $post_id ) {          // ['post_title'] create $vars for custom title setup              $ghz = get_post_meta( $post_id, 'imac_processor', true );         $strip_ghz = preg_replace( '/z.*$/', 'z', $ghz );         $ram = get_post_meta( $post_id, 'imac_ram', true );         $hd = get_post_meta( $post_id, 'imac_harddrive', true );         $model = get_post_meta( $post_id, 'imac_model', true );              global $wpdb;              $wpdb->update( $wpdb->posts,                         array(                             'post_title' => get_the_title( $post_id ).' '.$strip_ghz.' '.$ram.'GB '.$hd.' '.$model                         ),                         array( 'ID' => $post_id )                     );           }     add_action( 'save_post_imac', 'modify_imac_title' );


Error showing in current page id in wordpress admin

I am trying to remove a metabox ID from a page ID in the admin screen. So I have coded the following:               function ag_remove_cmb_metaboxes() {         global $post;         $id = $post->ID;         if ($id == 21) { ?>             <script type="text/javascript">             jQuery(document).ready(function($){                     jQuery('#test_metabox_img') .hide();             });             </script>         <?php }     }     add_action( 'admin_head', 'ag_remove_cmb_metaboxes' );      It is working fine but an error is showing in the widget.php page. Error code is: > Notice: Trying to get property of non-object in > E:\xampp\htdocs\speechcare\wp-content\themes\cutedoctor\core\helpers.php on > line 56 Can anyone please explain why this error is showing and what I am doing wrong? Thanks in advance.


DIR vs URI when defining a path to a file

When including files in a plugin, I've seen people do `WP_PLUGIN_DIR.'/'.dirname(plugin_basename( **__ _FILE_ __**)).'/somefile.css'` and yet WordPress `wp_enqueue_script/style` uses URI for the file path (such as `plugins_url`). What difference is there? I'm confused...


Different number of posts in each category

I have categories driven site. I have different template for each category. I would like to set different number of posts – **different for each category**. Plus I would like to add proper previous and next links in each category. for example in this `category-1.php` I want 4 posts per page:               <?php query_posts('showposts=4'); ?>     <a href="<?=next_posts()?>"> PREVIOUS      <a href="<?=previous_posts()?>"> NEXT      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>     ...     <?php endwhile; endif; ?>      but in this example `next_posts()` and `previous_posts()` doesn't work.


Cart66 localization hardcode strings

I've read the documentation http://cart66.com/cart66lite-documentation.pdf and searched on google but i can't seem to find a location(s) to localize strings (hardcode) for Cart66. If someone can point me to the right direction. EDIT1: I've changed CART66_CURRENCY_SYMBOL field in the wp_cart66_cart_settings table to have my own currency. But i still need to localize the string. I changed the cart66.po and it's not working. Please help. EDIT2: Modified php scripts in views folder to localize strings and format the currency with price accordingly. SOLVED.


Easiest way to have closed comments on a custom post type

My site has several different kinds of post types. One of these is Discussions. The site is completely open and public, but my client has asked that I provide a space where only certain members can have discussions/post comments. Basically, I want only members/authors/editors/whoevers of my site to see/post new Discussions. I've explored using bbpress and other forum options, but they're all too complicated. Is it even possible in WordPress to have only registered users see/post to a Discussions post type? Thanks Terry


Appending anchor tag to next post

I am making a one page wordpress site. There is a section of the website displaying content via category posts. There is only one post displaying at a time and I am using the following default code to have Next/Prev links appear:
<?php next_posts_link('« Next Recipe') ?>

<?php previous_posts_link('Previous Recipe »') ?>
      When the previous post is clicked, it loads the previous post properly, however since this is a one page site, it goes to the top of the page upon refresh. Is there a way when that link is clicked, to make it refresh the page in the same location, or to target that I would like? Even better, a way to make this do a page refresh using AJAX? I've crawled google and haven't found anything. I suppose this is similar: http://www.problogdesign.com/wordpress/load-next- wordpress-posts-with-ajax/, however I haven't been able to execute that with my custom theme.


Search in non-English language returns only one result

When I try to search in my (Greek) website it always returns a single result despite searching for article titles I know should return multiple results. More specifically if i search for Μουσείo (Museum) it only returns a single result, despite the fact that I have at least a dozen articles about museums whose titles are Museum of Something Contents of `searchform.php`:                        <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">             <?php __('Search for:') ?>             <input type="text" value="Search" onfocus="if (this.value == 'Search') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search';}" results=5 autosave="un1qu3_aut0s@v3_v@l" value="<?php esc_attr(apply_filters('the_search_query', get_search_query())) ?>" name="s" id="s">             <input type="submit" id="searchsubmit" value="<?php esc_attr__('Search') ?>" />         </form>           Contents of `search.php` (can also be found on Pastebin):               <?php     /**      * The template for displaying Search Results pages.      *      * @package Toolbox      * @since Toolbox 0.1      */          get_header(); ?>

                      <?php if ( have_posts() ) : ?>
<?php printf( __( 'Search Results for: %s', 'toolbox' ), '' . get_search_query() . '' ); ?>
                                               <?php //toolbox_content_nav( 'nav-above' ); ?>                          <?php /* Start the Loop */ ?>
                     <?php while ( have_posts() ) : the_post(); ?>

                         <?php get_template_part( 'content', 'search' ); ?>

                     <?php endwhile; ?>
                     <?php toolbox_content_nav( 'nav-below' ); ?>                      <?php else : ?>

<?php _e( 'Nothing Found', 'toolbox' ); ?>

<?php _e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'toolbox' ); ?>
                             <?php get_search_form(); ?>

                      <?php endif; ?>

          <?php get_sidebar(); ?>     <?php get_footer(); ?>      What is going wrong? I can search through the posts fine through the backend


list all authors outside of loop with photo from /uploads

I was successfully using this excellent contributors function to generate a list of the users on my site with gravatar photo.. UNTIL the client decided they don't want to use gravatar and would rather use images hosted on their own site. It also came out that they will have many other roles on the site besides author, and "WHERE NOT" in the query isn't going to suffice anymore. Can someone help me with 2 parts.. Adapt this function to limit to "Author" role AND use the user's first name & last name to customize the image link so I can pull in their image from /uploads? This would be used outside of the loop. I'm currently using $curauth in the loop to append the author's first and last name to an image link, which works well, and the image is named JohnSmith.jpg in the uploads folder. My SQL and PHP is weak but I am thinking:               select id, firstName, lastName from users WHERE Role=Author;      Then, replace                echo get_avatar($author->ID);      with                echo 'firstName,lastName; . '.jpg />;      I assume there will be a join to get the user role and I'm not quite sure what the field is called.. Below is the contributors function. Any help with this would really be appreciated!               function contributors() {     global $wpdb;          $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users WHERE NOT ID = '1' ORDER BY display_name");          foreach($authors as $author) {         echo "
";         echo "ID;         echo "\">";         echo get_avatar($author->ID);         echo "";         echo '
';         echo "ID;         echo "\">";         the_author_meta('display_name', $author->ID);         echo "";         echo "
";         echo "
";     }      }


Change post format using custom field

I'm creating a theme using the CF Post Formats plugin. But I've run into some trouble I don't know how to solve. Here's what I want to be able to do:   * Create a new standard-format post   * Enter a url into the _format_link_url custom field   * If the custom field is not empty, on save/update, change the post format to 'link'; else, remain 'standard'. For whatever reason, I can't get set_post_format to work in this context (perhaps there's a conflicting update?). I would like things to work this way is because I want to be able to continue using Marsedit (which doesn't support post formats) to submit content to my blog. Since Marsedit does support custom fields, I figure I can use them to auto-update the post format. Any help would be appreciated. **Update:** Okay, I've gotten this to mostly work. It works perfectly within the admin web interface. Via the web interface, I can create a link post with a url and it saves fine. I can try changing the post to a quote post, but on updating, it reverts to a link post (as intended, for now). I can delete the url from the custom field and on update the post becomes a standard post. However, when creating or updating a link post from Marsedit, the custom field gets as it should but the post format is set as standard. Frustrating. The function I've created is below. What am I missing?               function gateway_set_post_format( $post_id ) {         $the_post_format = get_post_format( $post_id );         if ( $the_post_format == 'link' && empty($_POST['_format_link_url'])) {             set_post_format( $post_id, '' );         }         elseif ( !empty($_POST['_format_link_url']) ) {                 set_post_format( $post_id, 'link' );         }     }     add_action('save_post', 'gateway_set_post_format',11, 1);


Wordpress usermeta scaling for thousands of users

I have developed a CRM plugin for a client integrated with Wordpress user management and I stored additional information for each user under the `wp_usermeta` table. However, the client's customer database is growing exponentially, and we are now in the _thousands_ , which gives us several _tens of thousands_ rows in `wp_usermeta`: at this point I am starting to be worried about **scalability** of this **architecture**. Does anybody have any experience on managing such an amount of users the Wordpress way? Should I add columns to the `wp_users` table instead of relying on the `wp_usermeta` one? How can I diagnose/profile Wordpress and my own code performance at this stage? I have never worked on such an amount of data and at this increasing rate, and any pointer would be valuable.


possible to combine sites that have lots of content, into multisite?

i run 3 wordpress sites. they are each on different installations. i don't really want to combine them right now because i'm not very proficient technically, with wordpress, but i might want to combine them at a later date, to make it easier to administer. but i want to check in case it's better to set it up now, because i'm just setting one wordpress site up -- maybe it's better to do this now. so my question is: at a later date, when i have 3 sites running, each with lots of content on, can i combine them at that time? or does setting up multisite involve starting things from scratch?


Calling Custom Field within Function wrapped with Divs.

Hi all I've created a function that basically allows the user to input the embed code for youtube into a custom field called youtube and this will then be styled on a wordpress post. Now I can get it to work perfectly until I want to wrap some CSS around it. Could you have a look where I'm going wrong. I think it's because I'm closing and opening PHP code? Thanks                <?php         function youtube(){             $ytvalue = get_post_custom_values("youtube");             $youtube = $ytvalue[0];              return '

';                  return $youtube;                  return '

';                              }             add_shortcode('youtube', 'youtube');              ?>


Is there a way I can put my post templates in a separate folder?

I have some custom post/page template files I would like to keep better organized by placing them into a folder inside my themes directory. Is this possible, or would I need a line of code in my functions.php file? If so, what is the line for functions.php?


Private messaging plugins + custom admin

I have build a simplified version of wordpress admin without all the features and stuff, only posting some specific custom post types and pages. This simplified version addresses a specific role on my normal wordpress operation (since admin is such a fuss to customize), but it lacks some things, such as using the plugin administration from the normal wordpress wp-admin. The wp- admin, still works for administrators only, but they are out of the loop for what I want to implement. Given the fact that my clients now want to use an internal private messaging system, what are my options here? Basically I am talking about (backend) pages in the same domain such as wp- admin that have wp-load.php, checks for roles and specific users, custom designed and inside them I want to use, for example, the wp private message plugin or the messaging plugin from wpmu. Is there any other customizable php class that I could use?


Adding Custom Capabilites

So, I'm not sure if this is possible, but is it possible to add custom Capabilities? So, I've written a group message application, that ties in with Wordpress. I only want certain members (set via options that I just asked about) to be able to send out such messages. I'd like to add a capability for, say "group_message", and add it to specific users (since it isn't strictly editors / administrators who have access to send out). I know about:               wp_current_user()->add_cap()      But is the only thing I need to do, say: wp_current_user()->add_cap('group_message')?


custom post types containing a collection of items

i have a custom post type products.How can i add a collection of items to that custom post type like this: **Product A**   title   description   price   option1   option2   option3   option n   Option items can be 0-n   In a relational database it would be like this:   table_products (product_id, title,...)   table_options ( **product_id** , option_id,...)   Thank you.


What is the difference between WP: template_directory vs TEMPLATEPATH

I am trying to code in more consistent manner and would like to know what is the difference between WP: template_directory vs TEMPLATEPATH.


Why aren't sub-categories nested after creating post in the WP Admin?

I have several sub-categories set up. Everything displays properly as far as nesting (see below) when creating a new post. > Category 1 > > \--Sub Category 1 > > \--Sub Category 2 > > \--Sub Category 3 > > Category 2 > > etc After I select a sub-category, then go back and edit a post, the sub category that I check shows up like this (note how it's not nested under Category 1): > (checkmark) Sub Category 2 > > Category 1 > > \--Sub Category 1 > > \--Sub Category 3 > > Category 2 > > etc Is this a bug in WordPress 3.1.2? Can someone tell me how to fix it? I don't remember it doing this when I was running 3.0.5 (but there's a chance it could have).


Avoid Wordpress categorizing a permalink request as Not found 404 Page

I've been looking all over the web for something like what I need and I haven't find anything resemble not even similar, the thing is this: I got a Page Template to a simple page post type, let's say 'Fruits' and then in this template I am calling a Web Services that will bring back all fruits with a certain description, the url of this is www.mydomain.com/fruits/ I am not populating Wordpress database with this information but taking it from an external service and I want to navigate the content with it details in Wordpress templates design, so what I need is be able to click on 'orange' so I would be creating a link like this: www.mydomain.com/fruits/orange/ ---> This would be my permalink that is not registered This non-existing permalink will redirect me immediately to the 404 Template page and it will be categorized in the wp_query object as '404' = true, I want to avoid wordpress from processing it as a 404 and tweak it inners to send this request to a custom-template that will display the details of orange. Please If you got any idea which hook can I use that doesn't involve WP_Rewrite (which I tried all kind of combinations with no success) I will be forever grateful. Thanks in advance.


Displaying posts from last 24 hours in current category with pagination

I am trying to find a solution for this problem but unfortunately without any success. I've checked WordPress Codex (WP_Query & wpdb) and few other solutions from Internet and still I wasn't even close to reach my goal. Even when I'm trying this simple solution:               $args = array(                   'post_type' => 'post',                   'post_status' => 'publish'                 );          $query = new WP_Query( $args );      while ($query->have_posts())         {             $query->the_post();              foreach($query as $post) {             echo get_the_title() . '<br>'; }                 }      WordPress is displaying articles multiple times, including drafts and auto backups. This code should work from category.php file so it should display posts only from current category, that were written in last 24 hours.


Metabox with checkbox is not updating

I trying to set a meta_box with a single checkbox, everything goes fine, however if I uncheck it and save the post, it marks again as checked, I've been taking a look but I cannot find my mistake. Take a look a my code.                function am_checkbox_option() {             global $post;             $custom = get_post_custom($post->ID);             $front_event = $custom["front_event"][0];             wp_nonce_field(__FILE__, 'am_front_event');               if( $front_event ){ $checked = "checked=\"checked\""; }else{ $checked = "";}               ?>               <label>Display Content? (type yes):</label>               <input type="checkbox" name="front_event" value="true" <?php echo $checked; ?> />               <?php             }     });           add_action('save_post', function() {     if ( defined( 'DOING_AUTOSAVE') && DOING_AUTOSAVE ) return;          global $post;           if ( $_POST && !wp_verify_nonce($_POST['am_front_event'], __FILE__) ) {         return;     }           if ( isset($_POST['front_event']) ) {         update_post_meta($post->ID, 'front_event', $_POST['front_event']);     }           });      Thanks in advance


Display count of new members registered today

I would like to display the registered members count for today in BuddyPress. Something like: **20** new members registered today I have no clue where to start, so I cannot provide any code yet :(


Prevent special characters in titles being turned into code

I'm having a problem with Wordpress converting any special characters in my title to the HTML code for that character. For example, if my title is:               "Post Title"      Wordpress saves this as:               "Post Title"      Then if I save the post again I end up with:               &quot;Post Title&quot;      And this goes on and on until it gets really messy! Any ideas as to what might be causing this? I've never seen it on a Wordpress install before. I'm wondering if there might be a problem with the database field.


wp_enqueue_script and wp_register_script in theme not working

I am trying to use a self written script for the jQuery library in my self- made theme, but it's not working. When I simply use script-tags, everything is alright. So it has to be something with wp_enqueue_script and wp_register_script. In the beginning of my code in the index.php I have               <?php         wp_enqueue_script('jquery');         wp_register_script( 'my_name', 'path/to/my/script/script.js'));         wp_enqueue_script('my_name');     ?>      I know that normally that has to be written BEFORE wp_head(); but because I am still developing everything, I haven't split my code into various files, I am working straight in the index.php. Do I have to do any other steps before enqueueing the scripts?


Bootstrapping Wordpress MultiSite Outsite of Wordpress - No $wpdb

I'm working on a plugin for a system to use Wordpress as the authentication backend, so that I can use my existing Wordpress users in another application. The plugin works great when running in single website mode:               include /path/to/wordpress/wp-config.php     global $wpdb;     // SQL and code to select user and compare entered passwords      I need this to work against a Wordpress Multisite install as well. When I pull in the wp-config.php for the MS site, I end up with this error:               Fatal error: Call to a member function set_prefix() on a non-object in /path/to/wordpress/wp-includes/ms-settings.php on line 126      On line 126, WP is trying to set the table prefix against $wpdb, but for some reason $wpdb doesn't exist here. I ran xdebug and $wpdb does get created, but ms-settings.php doesn't see it. I can fix this by adding:               global $wpdb;      right before line 126 and it works, but I don't want to modify the core Wordpress code. Is there a better way to bootstrap Wordpress ?