Show the child categories of current category on category page including other parent category

I want to show list like:   * category 1      * sub cat 1.1     * sub cat 1.2      * sub cat 1.3   * category 2   * category 3 My code is:

Links
<?php                     if (is_category()) {                         $cat = get_query_var('cat');                         $this_category = get_category($cat);                         $this_category = wp_list_categories('hide_empty=0&hierarchical=true&orderby=id&show_count=0&title_li=&use_desc_for_title=1&child_of='.$this_category->cat_ID."&echo=0");                         if($this_category !='
No categories
')                         {                          echo '
'.$this_category.'
';                          }                     }                     ?>


How to change URL of Pagination?

I have used PageNavi Plugin for pagination ,Generally when we click on page- two we get url like this : http://www.example.com/acb/page/2 but how Can I change Url like this http://www.example.com/acb/page-2


Creating archive pages for children categories

**Example:** video cat id = 4 video cat child category id's = 7,8,9 news cat id = 5 news cat child category id's = 11,12,13 I wanna display choosen categories ( like video and news ) in the different archive.php? Is it possible thanks. ( sorry about my bad Eng ) Thanks for Chris S but its not what i want to do.                 <?php     $catPosts = new WP_Query();     $catPosts->query( array( 'category__and' => array(5,11,12,13), 'posts_per_page' => 5, 'orderby' => 'date', 'order' => 'DESC' ) );       while ($catPosts->have_posts()) : $catPosts->the_post(); ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?>

        By <?php the_author() ?>

       <?php the_excerpt(); ?>
      When I wrote the parent category id, i dont wanna write its child category id's. When i choose the parent category id the system should its child category ids in the same archive page.


Using 'add_attachment' to add taxonomy term on upload completion?

function amend_gametitle_upload( $game_title ) {     global $post;              if ( isset( $_REQUEST['post_id'] ) ) {                  $post_id  = absint( $_REQUEST['post_id'] );             $post_obj  = get_post( $post_id );             $post_slug = sanitize_title($post_obj->post_title);              $states = get_the_terms($_REQUEST['post_id'], 'games_titles');                       if ( $states )                  $game_title = wp_set_object_terms( $post_obj, $states, 'games_titles', TRUE );         }         else {                 $game_title = wp_set_object_terms( $post_obj, $post_slug, 'games_titles', TRUE );         }              if ( is_wp_error( $game_title ) )         exit( $game_title->get_error_message() );              return $game_title;     }     add_filter( 'add_attachment', 'amend_gametitle_upload', 20 );      Been trying for some time to get the above code to work without success. I have already managed to assign the taxonomy, hack into the Media Modal and extend the filter system. Now all I require is to have the taxonomy term applied (if one exists on the main post) to the attachment itself after each upload. Thanks. *Most I can do is crash the media uploader :(


What are the advantages to the Settings API?

Let me preface this by saying that I hardly ever work with WordPress - in fact, the last time I did a site in WordPress was back during 2.2. Yesterday I made quite a mess of everything and asked several questions here trying to get a basic menu plugin working. I now have the plugin fully functional and behaving exactly as I expect, so I decided to make minor changes here and there to add functionality and compatibility - including using the Settings API. However a very short moment into reading tutorials on this API and I became quite confused, then this confusion only deepened as I read on and tried to implement the examples - which was made even more difficult by the fact that my plugin is implemented as a class. Unless I'm doing something wrong, from what I understand to use the Settings API requires the creation of a new function PER SETTING. This means 3-5 functions for the average plugin, and up to hundreds for more advanced plugins. It just seems ludicrous to write this many functions (and develop a naming system to keep from confusing them) when you could just as easily import all applicable `$_POST` variables into an array and forego the entire mess. Perhaps I'm old-fashioned, but unless there's something to gain from it I don't see the reason to triple or quadruple how much code I'm writing. Here's how I managed options before attempting to add the Settings API:                   function __construct() {             /* constructor stuff */             $this->options = $this->db_options = get_option( 'de-menu-options' );             if( $this->options === false ){                 $this->options = $this->defaults;             }             if (is_admin()) {                 add_action('admin_menu', array(&$this, 'admin_menu'));             }                /* more stuff */                  // When WordPress shuts down we store changes to options             add_action('shutdown', array(&$this, 'update'));         }              public function admin_menu() {             add_options_page('DE Menu Options', 'DE Menu', 'manage_options', 'de-menu-options', array(&$this, 'options'));             add_option('de-menu-options', $this->options);         }              public function options() {             if (!current_user_can('manage_options')) {                 wp_die( __('You do not have sufficient permissions to access this page.') );             }             if ( !empty($_POST) && check_admin_referer('de-menu-options') ) {                 // These options are saved to the database at shutdown                 $this->options = array(                     "columns" => $_POST["de-menu-columns"],                     "maintenance" => $_POST["de-menu-maintenance"]                 );                 echo 'DE Menu options saved';             }     ?>

DE Menu Plugin
         <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">             <?php settings_fields('de-menu-options'); ?>             <input type="checkbox" name="de-menu-maintenance" />             Columns:             <input type="text" name="de-menu-columns" value="<?php echo $this->options['columns']; ?>" />
             <input type="submit" name="de-menu-submit" value="Update Options »" />
         </form>
     <?php         }              function update() {             // By storing all changes at the end we avoid multiple database calls             $diff = array_diff( $this->options, $this->db_options );             if( !empty( $diff )  ){                 update_option('de-menu-options', $this->options);             }         }      Now with the settings API I have something more like the following:                   function __construct() {             /* constructor stuff */             // Do I load options? Will they be loaded for me? Who knows?             if (is_admin()) {                 add_action('admin_menu', array(&$this, 'admin_menu'));                 add_action('admin_init', array(&$this, 'admin_init'));             }                /* more stuff */             // Settings API should update options for me... I think         }              public function admin_menu() {             add_options_page('DE Menu Options', 'DE Menu', 'manage_options', 'de-menu-options', array(&$this, 'options'));             add_option('de-menu-options', $this->options);         }              public function admin_init() {             register_setting('de-menu-options','de-menu-options',array(&$this,'validate'));             add_settings_section('de-menu-main-options', 'Main Settings', 'options_section', 'de-menu-options');             add_settings_field('de-menu-maintenance', 'Maintenance Mode', array(&$this,'options_maintenance'), 'de-menu-options', 'de-menu-main-options');             add_settings_field('de-menu-columns', 'Columns', array(&$this,'options_columns'), 'de-menu-options', 'de-menu-main-options');         }              public function options() {             if (!current_user_can('manage_options')) {                 wp_die( __('You do not have sufficient permissions to access this page.') );             }             if ( !empty($_POST) && check_admin_referer('de-menu-options') ) {                 // These options are saved to the database at shutdown                 $this->options = array(                     "columns" => $_POST["de-menu-columns"],                     "maintenance" => $_POST["de-menu-maintenance"]                 );                 echo 'DE Menu options saved';             }     ?>

DE Menu Plugin
         <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">             <?php settings_fields('de-menu-options'); ?>             <?php do_settings_sections('de-menu-options'); ?>
             <input type="submit" name="de-menu-submit" value="Update Options »" />
         </form>
     <?php         }              public function options_section() {             echo '
' . __('Main description of this section here.','de-menu-lang') . '
';         }              public function options_maintenance() {             echo "<input id='de-menu-maintenance' name='options[maintenance]' type='checkbox' />";         }              public function options_columns() {             echo "<input id='de-menu-columns' name='options[columns]' type='checkbox' value=".$this->options['columns']."/>";         }              function validate($options) {             return $options; // I guess?         }      It's probably painfully obvious from the scrollbars that the code is already longer with just two options. It's like-wise obvious from the comments that I don't entirely understand what I'm doing. Then there's the matter of having 5 new functions (and removing only 1) in order to accomplish all of this. So just what advantage am I gaining from all of this extra work?


How to show full post on home page

I am using the Yoko theme and would like to show the most recent full post in category 1 on the home page. I am a Wordpress newbie, but my approach was going to be to provide my own index.php in a child theme. The parent theme has relevant code that looks like this:               <?php /* Start the Loop */ ?>       <?php while ( have_posts() ) : the_post(); ?>         <?php get_template_part( 'content', get_post_format() ); ?>       <?php endwhile; ?>     <?php /* Display navigation to next/previous pages when applicable */ ?>      I had thought I needed to place a line like this prior to the while loop:               <?php query_posts('cat=1&posts_per_page=1'); ?>      However, I see the partial post only. I have also tried to do the same sort of thing with single.php. I am sure I am missing something simple. Can someone school me on the loop?


Overriding wp_nav_menu default arguments

I'm trying to override WordPress' default arguments for the `wp_nav_menu` function, while still allowing programmers the ability to pass their own arguments. The `wp_nav_menu_args` filter seems like the perfect solution, but their is a catch. The function would look like this:               function my_nav_menu_args( $args = '' ) {         // my code here         return $args;     }     add_filter( 'wp_nav_menu_args', 'my_nav_menu_args' );      The catch is that `$args` contains the function call's arguments **or WordPress' default arguments**. Therefore, if `wp_nav_menu` is call without any arguments `$args` looks like this:               array(         'menu' => '',         'container' => 'div',         'container_class' => '',         'container_id' => '',         'menu_class' => 'menu',         'menu_id' => '',         'echo' => true,         'fallback_cb' => 'wp_page_menu',         'before' => '',         'after' => '',         'link_before' => '',         'link_after' => '',         'items_wrap' => '
%3$s
',         'depth' => 0,         'walker' => '',         'theme_location' => ''     )      This means I can't simply check if a particular argument is empty in order to know where or not to apply my own defaults. There is also the `wp_parse_args` function which is used to merge arguments with your own defaults. However, this doesn't work in this case:               $defaults = array(         'container' => false     );          $args = wp_parse_args( $args, $defaults );      `$args['container']` will still be WordPress' default `'div'` and not `false`. I know that `$args['container'] = false` will set the argument properly, but then any function calls that set the `container` argument will be ignored. The only solution I can think over is to check each argument against WordPress' defaults arguments hard coded in. Checking the `container` argument would look like this:               function my_nav_menu_args( $args = '' ) {         if ( $args['container'] == 'div' ) {             $args['container'] = false;         }         return $args;     }     add_filter( 'wp_nav_menu_args', 'my_nav_menu_args' );      It would work, but I'm thinking there has to be a simpler solution that won't require the defaults hard coded in.


Getting author page slug from get_users() or get_userdata() functions

`wp_list_authors()` gives a list of author pages permalinks (site.com/author/john, site.com/author/jenny, etc). I want the same links using `get_users()` or `get_userdata()` functions instead. I need these functions because I display authors in a very customized way. However I don't know how to get proper author page slugs with those functions. (for example, one author has an email address as her Username, and the `wp_list_authors()`-generated link for her author page has dashes in place of the "@" and the ".". This is to say that the author page slug is not necessarily the same thing as the username)


Hiding wp-config.php via .htaccess on an install installed in another directory?

Say my wordpress install is here, example.com/wp/ but my .htaccess is in example.com, am I ok with               <Files wp-config.php>       Order Allow,Deny       Deny from all     </Files>      or do I need to specify a directory?               <Files /wp/wp-config.php>       Order Allow,Deny       Deny from all     </Files>


What does the output of this plugin mean?

I just tried to compress a file and am not sure if it worked or not. The plugin I am using gave me the following results:               adding: wp-includes/js/tinymce/plugins/wpeditimage/editimage.html (deflated 76%)     adding: wp-includes/js/tinymce/plugins/wpeditimage/php.ini (deflated 64%)     adding: wp-includes/js/tinymce/plugins/wpdialogs/ (stored 0%)      The line I am concerned about is the third one:               wp-includes/js/tinymce/plugins/wpdialogs/  (stored 0%)      Can anyone explain what this means? I think this could mean:   1. The file was not able to compress OR   2. The file was not able to get stored in part of the zip file OR   3. The original file was empty so there was nothing to compress I am open to other suggestions as well.


Plugin options will not save in database

I'm not sure what's happening here, since this has worked in another plugin I've created. I'm simply trying to store data in the options table. Here is the code I'm using:               function on_myplugin_start () {              register_setting('first_tab_options', 'first_tab_items');     }          add_action('admin_init','on_myplugin_start');      Here is the form that gets submitted:               <form action="options.php" method="post" >     <?php      settings_fields( 'first_tab_options' );      ?>     <input type="text" name="some_name" value="">     <input type="submit" value="Save Settings" name="submit" class="button-primary">     </form>      That's it..when I look at the source code, everything looks fine...there is all the hidden fields put in by the settings API..but when I put in a value and hit submit (and it says successfully saved, nothing is in the database field that was successfully created (first_tab_items). I would appreciate any help on this....thanks


Add Role inherits?

On the WordPress codex Add Role page it says how to add a role, but I can not figure out how to do it, or that is inherits. Specially the comment `//Use false to explicitly deny`. What does that mean? Does that mean if i do not say false to all the capability they can still do is if they guess the rigth URL? Can somebody tell me the difference between true and false in wp role perspective, and how I should use it? I am trying to make a user which can only edit pages. Nothing else. http://codex.wordpress.org/Function_Reference/add_role               $result = add_role('basic_contributor', 'Basic Contributor', array(         'read' => true, // True allows that capability         'edit_posts' => true,         'delete_posts' => false, // Use false to explicitly deny     ));     if (null !== $result) {         echo 'Yay!  New role created!';     } else {         echo 'Oh... the basic_contributor role already exists.';     }


How to get comments with mixed status using get_comments?

Is there a way to get comments with more than one `status` using `get_comments` function? Let's say I would like to get both `trash` and `hold` comments. It is possible to do the same with posts:               get_posts(array('post_status' => 'draft,private,trash'));     get_posts(array('post_status' => array('draft', 'private', 'trash')));      What I want to do is:               get_comments(array('status' => 'hold,trash'));     get_comments(array('status' => array('hold', 'trash')));


Share Tags Between Custom Posts in Admin

Let's say I have several custom post types that all have support for post tags. Since these custom post types will all be tagged with mostly the same keywords, I'd like to know if there is a way to share the commonly used tags between the custom post types. So if I were to browse a post edit screen for Custom Post Type 1, it would also show Custom Post Type 2 tags inside the metabox. This would be a time- saver.


Custom post query error

i have a ~46k rows in my wp_posts. All i want to do is to query the database that meet my queryes and display the resulted posts but my problem is that any query that i`m doing to the database it display only the last 5 entryes that were added. Thats the code:               if(isset($_GET["submit"])){          $nume_searchq=$_GET["nume_doc"];     $spec_searchq=$_GET["specializare_doc"];     $instit_searchq=$_GET["spital_doc"];     ?>
     Rezultatele cautarii:
          <?php          $query= $wpdb->get_results("SELECT * FROM `wp_posts` WHERE post_content like '%Alba%' OR LOWER(post_title) LIKE '%$nume_searchq%' OR LOWER(post_content) LIKE '%$spec_searchq%' OR LOWER(post_content) LIKE '%$instit_searchq%' ".$limit, OBJECT);      $pageposts =get_posts($query);     if($pageposts){         foreach($pageposts as $post){                         global $post;                         setup_postdata($post);                         echo '
 ' . get_the_title() . '
';     wp_reset_postdata();     }//end_Foreach     }//end_if     ?>      I have tried different methods and queryes and still the most recent 5 entryies it display...how can i fix this? PS: dont bother about the $limit variable because i have a pagination code under this query. Thanks! LE: i changed the code a bit and i have results but in my query **i only need posts** and it display absolutely everything that it found in the db, including small pictures, contact form, different pages, different codes, posts etc. Code looks like this for the moment:                   <?php         switch($_GET['filter1']){                  case "ALL":             $querystr = "SELECT * FROM `wp_posts` WHERE post_type='post' OR LOWER(post_title) LIKE '%$nume_searchq%' OR LOWER(post_content) LIKE '%$spec_searchq%' OR LOWER(post_content) LIKE '%$instit_searchq%' ";               break;            case "AB":               $querystr = "SELECT * FROM `wp_posts` WHERE post_content LIKE '%Alba%' AND post_type='post' OR LOWER(post_title) LIKE '%$nume_searchq%' OR LOWER(post_content) LIKE '%$spec_searchq%' OR LOWER(post_content) LIKE '%$instit_searchq%' ";              break;         ..... //more case`es }             $pageposts = $wpdb->get_results($querystr, OBJECT); ?>      <?php if ($pageposts): ?>      <?php foreach ($pageposts as $post): ?>      <?php setup_postdata($post); ?>           <div class="post" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">         <?php the_title(); ?>
         <?php //display_rating_result(); ?>
           <?php the_content('Read the rest of this entry »'); ?>
         <?php edit_post_link('Edit', '', ' | '); ?>           <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>

       <?php endforeach; ?>      <?php else : ?>
Not Found
      <?php endif;                 }//end_submit       ?>


Add Custom Values to Permalinks Through Custom Fields and Posts

I have two custom post types 1 called melon-parties and another called party- categories. for posts in melon-parties i create a metabox which gets populated from all posts from parties-categories. I then have been able to rewrite the url of melon-parites to www.domain.com/parties/christmas-party/thames-river- party where christmas-party is a custom post from party-categories. I can access that page (www.domain.com/parties/christmas-party/thames-river- party) but when i try and go to www.domain.com/parties/christmas-parties it redirects to the homepage and not the custom post which is where my problem lies. I have had to do a custom rewrite for that as well because when i use the rewrite option when i register the post type i get a 404 on the party post. here is my code that creates all the custom post types and rewrite rules:               function register_custom_post_types() {         $args = array(             'labels' => array(                 'name' => __( 'Parties' ),                 'singular_name' => __( 'Party' )             ),             'menu_position' => 50,             'public' => true,             'has_archive' => 'true',             'hierarchical' => true,             'taxonomies' => array('post_tag'),             'capability_type' => 'post',             'rewrite' => false,             'supports' => array('title', 'editor', 'thumbnail', 'revisions', 'page-attributes')         );              register_post_type('melon-parties', $args);              $args = array(             'labels' => array(                 'name' => __( 'Type of Parties' ),                 'singular_name' => __( 'Type of Party' )             ),             'menu_position' => 50,             'public' => true,             'has_archive' => 'true',             'hierarchical' => true,             'show_ui' => true,             'publicly_queryable' => true,             'capability_type' => 'page',             'supports' => array('title', 'thumbnail', 'revisions', 'page-attributes'),             'rewrite' => false         );              register_post_type('party-categories', $args);              $args = array(             'labels' => array(                 'name' => __( 'Home Slider' ),                 'singular_name' => __( 'Home Slide' )             ),             'menu_position' => 50,             'public' => false,             'show_ui' => true,             'hierarchical' => false,             'publicly_queryable' => true,             'capability_type' => 'post',             'supports' => array('title', 'editor', 'thumbnail', 'revisions', 'page-attributes')         );              register_post_type('melon-home-slider', $args);              $args = array(             'labels' => array(                 'name' => __( 'Case Studies' ),                 'singular_name' => __( 'Case Study' )             ),             'menu_position' => 50,             'public' => true,             'hierarchical' => false,             'publicly_queryable' => true,             'capability_type' => 'post',             'rewrite' => array('with_front' => false, 'slug' => 'case-studies'),             'supports' => array('title', 'editor', 'thumbnail', 'revisions', 'page-attributes')         );              register_post_type('melon-case-studies', $args);     }     add_action( 'init', 'register_custom_post_types' );          add_action('init', 'tdd_add_rewrite_rules');          function tdd_add_rewrite_rules() {          // Register custom rewrite rules              global $wp_rewrite;         $wp_rewrite->add_rewrite_tag('%melon-parties%', '([^/]+)', 'melon-parties=');         $wp_rewrite->add_rewrite_tag('%parties_categories%', '([^/]+)', 'cmb-event_category=');              $wp_rewrite->add_permastruct('melon-parties', '/parties/%parties_categories%/%melon-parties%', false);     }          add_filter('post_type_link', 'tdd_permalinks', 10, 3);              function tdd_permalinks($permalink, $post, $leavename) {              $no_data = 'no-category';              $post_id = $post->ID;              if($post->post_type != 'melon-parties' || empty($permalink) || in_array($post->post_status, array('draft', 'pending', 'auto-draft')))              return $permalink;              $var1 = get_post_meta($post_id, 'cmb-event_category', true);              $var1 = sanitize_title($var1);              if(!$var1) { $var1 = $no_data; }              $permalink = str_replace('%parties_categories%', $var1, $permalink);              return $permalink;          }          add_action('init', 'partyCategoryRewriteRules');          function partyCategoryRewriteRules() {          // Register custom rewrite rules              global $wp_rewrite;         $wp_rewrite->add_rewrite_tag('%party-categories%', '([^/]+)', 'party-categories=');              $wp_rewrite->add_permastruct('party-categories', '/parties/%category%', false);     }          add_filter('post_type_link', 'partyCategoryPermalinks', 10, 3);              function partyCategoryPermalinks($permalink, $post, $leavename) {              $no_data = 'no-category';              $post_id = $post->ID;              if($post->post_type != 'party-categories' || empty($permalink) || in_array($post->post_status, array('draft', 'pending', 'auto-draft')))              return $permalink;              $var1 = $post->post_name;              $var1 = sanitize_title($var1);              if(!$var1) { $var1 = $no_data; }              $permalink = str_replace('%category%', $var1, $permalink);              return $permalink;          }      Please can someone advise where i am going wrong. would really appreciate it.


IIS7.5 URL rewrite pboblem on index page

H, I've installed wp on IIS7.5 machine. But I'm having error when my permalink setting is line: /%year%/%monthnum%/%day%/%postname%/ Problem is the index page (root page /) gives 404 error ( **EDIT: error is in a wordpress page, not server default page** ). But I'm not getting 404 when permalink is default or /index.php/%year%/%monthnum%/%day%/%postname%/ Site can be seen here: http://marmarabote.innovacube.com/ I've also rewrited urls in web.config like:               <?xml version="1.0"?>         <configuration>             <system.webServer>                 <rewrite>                     <rules>                         <rule name="Main Rule" stopProcessing="true">                             <match url=".*" />                             <conditions logicalGrouping="MatchAll">                                 <add input="{REQUEST_FILENAME}" matchType="IsFile"                                 negate="true" />                                 <add input="{REQUEST_FILENAME}"                                 matchType="IsDirectory" negate="true" />                             </conditions>                             <action type="Rewrite" url="index.php" />                         </rule>                     </rules>                 </rewrite>             </system.webServer>         </configuration>


Why do I get this "plugin does not have a valid header" error?

I recently committed version 2 of my new plugin to the Plugin Directory, but now when you install the plugin for the first time, you get this error on activation: "The plugin does not have a valid header." ![alt text](http://i.stack.imgur.com/65Kbi.png) You can workaround it by browsing to the plugin section of wp-admin and activating from there with no errors, but this is still not ideal. As far as I can tell, the header looks fine, and is pretty much the same as version 1.0. Which leave me to wonder why I get this error? Here is the plugin: http://wordpress.org/extend/plugins/export-to-text/


Image archive without date

I don't care about having images catalogued by date, I actually hate the subdirectories it creates by year and by month when you upload an image. Is there a way to store them all in the same folder?


Disable some features in Admin

I'd like to open my WP based blog to the general public so they can contribute, so I'm trying to lock-down my WP install. In particular I would like them to be **unable** to:   * edit the slug or assign tags   * send trackbacks   * add custom fields   * enable/disable comments   * add an excerpt   * see the Tools section   * see the Comments section What's the best way to go about these customizations? Should I roll my own theme or is there some plugin out there that can suit me?


Overwrite custom post type (WP SEO Local)

Site I'm working on right now is using WP SEO Local plugin (Yoast), it makes a custom post type for the locations, and they all get a custom slug. Let's say my slug is /locations/ So all the locations posts have the permalink /locations/post-name/ I would like to rewrite it to using /state/city/post-name/ if possible, or /city/post-name/ Right now I have made /city/post-name/ work by adding a rewrite rule, like so:               function asbra_rewrite_rules( $rules )     {       $new_rules = array();            // taxonomy=categories&post_type=wpseo_locations            $taxonomies = get_object_taxonomies( 'wpseo_locations', 'objects' );            foreach( $taxonomies as $taxonomy )       {         $terms = get_terms( $taxonomy->name );              foreach( $terms as $term )         {           $new_rules["({$term->slug})/?$"]    = 'index.php?categories=$matches[1]';           $new_rules["{$term->slug}/(.*)/?$"] = 'index.php?post_type=wpseo_locations&wpseo_locations=$matches[1]&taxanomy_name=categories';         }       }            $rules = array_merge( $new_rules, $rules );            return $rules;     }     add_filter( 'rewrite_rules_array', 'asbra_rewrite_rules', 9999 );      With this rule /city/post-name/ works, which is very fine, and I am happy, just would like to have /state/ if possible too. Now to the next problem, I would like the /locations/post-name/ not work, or to redirect to /city/post-name/ How can I do this? I have attempted hooks to init, query_vars & request. Using the register_post_type I have managed to make the /locations/post-name/ 404, but not /locations/               function asbra_init()     {       register_post_type( 'locations', array( 'rewrite' => array( 'slug' => '', 'with_front' => false ) ) );     }     add_action( 'init', 'asbra_init' );      However, when anything want to get the permalink for the post, it gives the /locations/post-name/ and I would like it to get the /city/post-name/ if possible. I have read alot of posts on this subject, tried many different methods but sofar I'm unsuccessful. Was hoping I could get some help here :) Thanks you for reading!


Large WP 3.0 menu times out and won't save

I have a large menu containing 10 parent items with roughly 7 child items each that I am trying to build using the WP-admin > Appearance > Menus. I have nearly all the menu items added but now my wp-admin backend won't save the menu, it keeps timing out and just ending on a blank screen. I have about 4 more items left to enter but I can't save the menu anymore. I have tried increasing the php memory in wp-config.php by adding define('WP_MEMORY_LIMIT', '64M');   but it made no change. Any tweaks or tips to help me get this menu saved, this is the only thing holding the site up and the client is waiting. Thanks very much! maikunari


How to add exception to Wordpress's web.conf

I have a WordPress install on a Windows/IIS server. But, WordPress's URL rewrite rule is preventing the redirect in a sub- directory from being executed. I tried adding a condition to WP's rule, but to no avail. How can I except a single directory from WP's rewrite rules? Here's the current relevant code from the web.conf in webroot with my attempt at an exception rule: http://d.pr/n/xCI4


"Right Way" to make custom Loop respect reading settings inside admin panel?

I have created custom Wordpress loop using WP_Query, loop is working fine and I can customize it nicely, however i have a problem using "Blog pages show at most" settings, for example inside my loop if i have added following argument `'post_per_page' =>-1` my loop is showing all posts but now i **can't insert my custom number of posts** inside admin panel if I enter **"Blog pages show at most" 3** (three representing number of posts) they are ignored and loop is showing all posts.      So to overcome this problem _(because i want to control number of posts showing inside admin reading settings)_   I have done following : Created a blank value variable and passed it as an argument like this:               $show_my_posts = '';     $args = array(               'paged' => $paged,          'post_not_in' => $show_my_posts          //added blank value variable in order to respect "Blog pages show at most" in backend     );     $temp = $wp_query;     $wp_query = null;     $wp_query = new WP_Query($args);      So now **I can insert custom number of posts** inside admin backend and my loop is behaving as i want (I enter "Blog pages show at most" and value as 3 ) and now my loop is displaying three posts as I want.      My question is: **Am I doing this the "right way" or is there a better way for achieving that behavior?** THX!! My full loop looks like this:               <?php //enable pagination on static pages and blog pages         $show_my_posts = '';         $col = 1; //Let's create first column         /*Let's add pagination to post page and static page*/         if ( get_query_var('paged') ) {         $paged = get_query_var('paged');         } elseif ( get_query_var('page') ) {         $paged = get_query_var('page');         } else {         $paged = 1;         }          $args = array(         /* Add whatever you need here - see http://codex.wordpress.org/Class_Reference/WP_Query */              'paged' => $paged,          'post_not_in' => $show_my_posts                  //added blank value variable in order to respect                  //"Blog pages show at most" in backend     );     $temp = $wp_query;     $wp_query = null;     $wp_query = new WP_Query($args);          if($wp_query->have_posts()):?><?php while ( $wp_query->have_posts() ) : $wp_query->the_post();?>                  <?php if ($col == 1) echo '
';//If column 1 create first row ?>     <?php if ($col == 2) echo '
';//If column 2 create second row ?>         <div <?php post_class('col'.$col); ?> id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

                     <?php the_post_thumbnail();           echo '
' . get_post(get_post_thumbnail_id())->post_excerpt . '
';?>
             <?php  // let's enable more link on pages...             global $more;             $more = 0;             ?>                 <?php the_content(); ?>

<?php the_meta(); ?>

                      <?php _e('Filed under:','domain'); ?> <?php the_category(', ') ?> <?php _e('by','domain'); ?> <?php  the_author(); ?>
<?php the_tags('Tags:', ', ', '
'); ?>                 <?php _e('Posted on: ','domain'); ?><?php the_time('l, F jS, Y'); ?>
                      <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> <?php edit_post_link('Edit', ' | ', ''); ?>

              <?php /*Enable Two Column Layout*/             if($col==1) {             $col=2;             echo "
";             }             else if($col==2)  {             $col=1;              echo "
";             }              endwhile; ?>

              <?php         global $wp_query;         $big = 999999999; // need an unlikely integer              echo paginate_links( array(         'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),         'format' => '?paged=%#%',         'current' => max( 1, $paged ),         'total' => $wp_query->max_num_pages         ) );         ?>
     <?php endif; ?>      <?php     $wp_query = null;     $wp_query = $temp;     wp_reset_query();     ?>


wp query problem

I am using wp-postviews plugin to to track views of my post The author provided a query to order post by views in index.php                <?php query_posts('v_sortby=views&v_orderby=desc') ?>      But when I am using the same key with diff query it isn't working This is my code to get post with less than 22 views                <?php query = new WP_Query( array( 'meta_key' => 'views', 'orderby' => 'desc', 'meta_value'  => '22', 'meta_compare' => '<=', 'post_type' => 'post' ) );


wordpress plugin that show my reputation (points) in any stackexchange project in my wordpress blogs

I'm seeking for a plugin show my points (reputation) of Stackexchange (not Stackoverflow) in my Wordpress blogs. or other projects in stackexchange like :   1. Superuser   2. Security   3. Serverfault   4. SharePoint or author plugin that show points like Google plus beside the picture of every authors. or help me about "how can i develop a plugin do this for me? or show my profiles in stackexchange's projects?


Can admin_bar_menu or another action be used to modify the admin bar on the admin side?

I have used `add_action('admin_bar_menu', 'modify_admin_bar')` to change the admin bar on the "front end" of WordPress (the site the user sees). However, it seems that `modify_admin_bar()` is not called before the admin bar is rendered on the "back end" (the Dashboard or admin side of WordPress). How can I modify the admin bar as it is presented on the admin side of WordPress? Here's an example...               add_action( 'admin_bar_menu', 'modify_admin_bar', 95 );     function modify_admin_bar() {         error_log('admin barring');     }      In this example, my error log shows "admin barring" every time I refresh a page on the user side of WordPress, but never shows "admin barring" when I refresh the admin side (the Dashboard) of WordPress. It does not seem that the function gets called from the admin side. I am running WP 3.5.


AJAX pagination offset returns same post on adjacent pages

I have a simple AJAX pagination that seemed to work just fine, calling one Wordpress page (not ideal, I know) with a pagenum and a sort order arguments and it returned 4 custom posts per call. The problem I found while testing it is that if the items are ordered like this in the db:               item1: 4 votes     item2: 3 votes     item3: 3 votes     item4: 3 votes     ----page2----     item5: 3 votes     item6: 2 votes     ...      ...there's a chance that any one of items with 3 votes in custom field will display as the first item on page2 of the pagination. This effectively erases one of the items from listing, and I can't seem to find a way to query get_posts properly. This is how it looks now:               elseif($savjet_order == 'votes') :     $offset = (($savjet_per_page * $savjet_page) /* - $savjet_per_page*/ );     //$offset = $offset < 0 ? 0 :  $offset;     $args = array(     'numberposts'     => $savjet_per_page ,          'offset' => $offset ,     'meta_key' => 'wpcf-glasova',     'orderby'         => 'meta_value_num post_date',     'order'           => 'DESC',        //'paged' => $savjet_page ,      'post_type'       => 'savjet',         'post_status'     => 'publish'     /*'suppress_filters' => true*/ );           $savjeti = get_posts($args);      ...adding post_date (or even date) to orderby clause doesn't seem to change anything ('date' seems to make it worse by making the list ascend even though the order is DESC).


Wordpress: robots.txt gives 500 Internal Server Error

This is a fairly new installation. Almost no plugins. Everyting works fine except the dinamically-generated `robots.txt` gives Error 500. Google doesn't like it much. (won't read my sitemap). All other pages work fine. Permalinks are "default". htaccess on public_html is:               # BEGIN WordPress          # END WordPress      Server logs are useless: `66.249.73.225 - - [11/Dec/2012:15:06:11 -0500] "GET /robots.txt HTTP/1.1" 500 671 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"` I'm definitely no WP expert. Found `function do_robots()` in `functions.php` but don't know who calls it. I'd appreciate any pointers on how to troubleshoot this further. Otherwise... maybe generating a static robots.txt file? Not sure how would that interact wit the one WP tries to build. **EDIT** : As requested, this is the function in my `functions.php` file:               /**      * Display the robots.txt file content.      *      * The echo content should be with usage of the permalinks or for creating the      * robots.txt file.      *      * @since 2.1.0      * @uses do_action() Calls 'do_robotstxt' hook for displaying robots.txt rules.      */          function do_robots() {          header( 'Content-Type: text/plain; charset=utf-8' );              do_action( 'do_robotstxt' );              $output = "User-agent: *\n";         $public = get_option( 'blog_public' );         if ( '0' == $public ) {             $output .= "Disallow: /\n";         } else {             $site_url = parse_url( site_url() );             $path = ( !empty( $site_url['path'] ) ) ? $site_url['path'] : '';             $output .= "Disallow: $path/wp-admin/\n";             $output .= "Disallow: $path/wp-includes/\n";         }              echo apply_filters('robots_txt', $output, $public);     }


How can I put a custom meta box above the editor but below the title section on the edit post page?

I have a custom meta box for a custom post type that my client wants placed between the title/permalink section and the post editor in the admin panel. Is this possible and if so is there a hook/filter/etc that I would need to use?


Wordpress single.php different layouts projects / posts

i'm new in Wordpress and I'm currently building my personal website where my works will be published and have a blog too. For the portfolio layout I've looked up this tutorial: http://net.tutsplus.com/tutorials/wordpress/create-a-multi-layout-portfolio- with-wordpress/ It gives me what I want, more or less. The point is that when I enter on a specific project, the look of it changes a little bit. The file single.php is working right? But doesn't this means that the blog posts will have the exactly the same layout than the project details? I mean, if I edit that file I'm doing it for both blog posts and project details right? How can I make it to look different? Best Regards, Tiago Castro


Remove HTML from search.php of my parent theme

I have a child theme of the theme alterna, and in the search.php (among other code) there is this:

<?php echo get_the_date('d'); ?>

<?php echo get_the_date('M'); ?>

<?php echo get_the_date('Y'); ?>

      I want to be able to get rid of just that part, so I am thinking on copying the exact search.php to the child theme and get rid of that part. Is that the correct way to do so? Thanks


Add mime types with plugin

I've tried a few plugins to add mime types including the PJW Mime Config plugin. And adding this to a themes `functions.php` file would work fine, too, for a non-WPMS site. But I need these to be allowable throughout the network. So I've written my own plugin to do the trick. After looking at info from the codex as well several blog posts and this WPSE question. This is what I've come up with:               function new_mime_types($mimes) {         $mimes = array_merge($mimes, array(              'pdf' => 'application/pdf',             'zip' => 'multipart/x-zip'             //add your ext => mime to the array             //there are a LOT more, but to save space I've left the rest out :)             ));         return $mimes;     }          // Hook     add_filter('upload_mimes', 'new_mime_types');      Now when I go to upload one of these file types, I receive a warning: **Warning:** Cannot modify header information - headers already sent by (output started at [server]\wp-content\plugins\tps-mime-types.php:1) in **[server]\wp-includes\pluggable.php** on **line 934**. I'm still new to WP, so any suggestions on what to do next? _**Note:** Also, I was going to tag this as **upload-mimes** and **mime- types** , but don't have the rep. :)_ * * * ### *// Update* I've updated my plugin to the code below:               function new_mimes($mimes) {              // add your mime to the txt file below         // same formating and no spaces              // mime-types.txt file set up like this...         // pdf|application/pdf         // zip|multipart/x-zip         $file = "/tps-mime-types/mime-types.txt";         $contents = file_get_contents( plugins_url( $file ) );         $contents = str_replace( "\r", "|", $contents );         $contents = str_replace( "\n", "|", $contents );         $mime_types = explode( "|", $contents );              $counter=0;         foreach ( $mime_types as $ext_app ) {             if( !isset( $ext_app[0] ) ) $ext_app[0] = $ext_app[1];             $counter++;         }              // return the new full result         return $mimes;     }          add_filter('upload_mimes', 'new_mimes');      But after activating the plugin on a WPMS install I've had for a while as well as a single install, I'm still experiencing problems. Upon activation: > The plugin generated 3 characters of **unexpected output** during > activation. If you notice “headers already sent” messages, problems with > syndication feeds or other issues, try deactivating or removing this plugin. Then when I attempt uploading a file matching one of the new mime-types I receive my original error message: > **Warning:** Cannot modify header information - headers already sent by > (output started at [server]\wp-content\plugins\tps-mime-types\tps-mime- > types.php:1) in **[server]\wp-includes\pluggable.php** on **line 934** Any ideas?


How to count nav menu items?

I'm creating a custom walker for my nav menu. The goal is to split the menu in to columns like so: ![enter image description here](http://i.stack.imgur.com/Cr9xo.png) I can easily determine where I am in the list by looking at `$item->menu_order`. What I don't know is how many items are in the menu total. How can I figure that out from inside the walker? **Updated:** I realize there are several other ways to create columns. All have their drawbacks, however:   1. **CSS Floats.** As suggested below by @sagive, this could be accomplished by floating all of the list elements. The problem is that the list changes order. Instead of going down the first column, then wrapping over to the second, the list would go across all four columns on the first row, then across all four columns in the second row. This messes up the order.   2. **CSS Columns.** This is _almost_ the perfect solution. It will give me exactly what I want -- except that IE doesn't it at all. Even on IE 9. That makes it unusable for a mainstream web site.   3. **jQuery.** With some client-side javascript I could hack up the list and make it layout the way I want. That's messy though, and it breaks for people who have js disabled.   4. **PHP.** This is the method I'm asking about in this question. I break the list in to four separate unordered lists, dump each out in html, then use CSS to float the lists to make four distinct columns. It may be tricky to produce in PHP, but the result looks the same for all browsers. That makes it the best option I believe. **Solution:** For those who may follow, here's the code I finally used to get the answer:               // The menu handle from the register_nav_menu statement in functions.php     $theme_location = 'my-menu-handle';          $theme_locations = get_nav_menu_locations();          $menu_obj = get_term( $theme_locations[$theme_location], 'nav_menu' );          // Echo count of items in menu     echo $menu_obj->count;


Exclude top-level pages from search results

With the following code I can exclude all posts and pages that are top-level, but I would like to apply this only to pages, not to posts (but I still want all posts in the results):               function search_filter( $query )     {         if(             $query->is_search              AND $query->is_main_query()             )         {             $query->set( 'post_parent__not_in', array( 0 ) );             $query->set( 'post_type', array( 'post', 'page' ) );         }         return $query;     }      At the moment all my posts have 0 as post_parent, so they all get excluded from the results.


Importing old Disqus comments into WordPress

Anyone got a working way to import old Disqus comments into WordPress? Presumably by converting the Disqus XML export format to the WordPress XML import format. Note that this plugin is for some ancient version of Disqus and doesn't work.


pad_count with custom taxonomies and attachment post type

I use hierarchical custom taxonomies with attachment post types, and am trying to display a hierarchical terms list with the `pad_counts` argument set to `1` but children counts are not added to parent's. I've tried several combinations of `hierarchical`, `hide_empty`, `pad_counts` and `show_count` arguments, but none of them seem to work; the counts returned by the `wp_list_categories()` function are always wrong. Any idea how I can solve this issue? Thanks for helping.


Wordpress language switcher

Is there an easy way I can switch between languages (perhaps with some flag icons) on a single Wordpress site? Can this be done with 2 content editors on the same page, or will I have to resort to a multi-site set up and point each flag to a different version of the site? I only require 2 languages, English and Mandarin, I also need to edit it all manually, I'm unable to rely on auto translators Thank you for any suggestions


Make the css of the widget overwrite theme css

I have created a widget that creates forms. I am using the Twitter Bootstrap framework in order to style those forms. I have two instances of WP:   * One is using the Alterna theme, which uses Bootstrap too. The forms look great on that theme.   * The other one uses OptimizerPress, which does not use Bootstrap. The problem comes here. That theme doesn't use Bootstrap, and their CSS overwrites the definitions in Bootstrap. So my question is:   * How can I make my widget CSS to take high priority than the Theme CSS? Here is how I am adding the CSS into my Widget:               class LeadCapture_Form_Widget extends WP_Widget {         /**          * Register widget with WordPress.          */         function __construct() {             parent::__construct(                 'lc-form-widget', // Base ID                 'LeadCapture_Form_Widget', // Name                 array( 'description' => __( 'Widget that outputs a basic form with that will capture the user\'s information and submits it to the CRM.', 'text_domain' ), ) // Args             );             add_action( 'wp_enqueue_scripts', array( $this, 'register_plugin_styles' ) );         }              /**          * Register and enqueue style sheet.          */         public function register_plugin_styles() {             wp_register_style( 'lc-form-widget', plugins_url( 'LeadCapture_Form_Widget/css/form.css' ) );             wp_enqueue_style( 'lc-form-widget' );         }


Hide content editor for posts after approriate date

I am tuning my new site and i what to disable Content Editor for post created after date X, but for posts that created before that date Content Editor must be on its place.


Display 3 recent posts from one taxonomy

I have created a Custom Post Type - "magazine_entry" and have registered the taxonomy "division". I have then created several divisions such as, "international", "tokyo", "kansai", etc... I am trying to display the 3 most recent posts from a single taxonomy of the custom post type. For example, have (i will handle the css and html later)               International:     post 1      post 2     post 3              Tokyo:     post 1      post 2     post 3      etc... I can get all posts from the custom post type to show up, but I don't know how to get the posts from just one of the taxonomies.


OpenGraph descriptions not showing when using Wordpress SEO (Yoast)

I installed WordPress SEO a couple of days ago and have the Open Graph tags ticked, and they are all displaying fine apart from the page description. Should this be appearing, and am I correct in saying it will be automatically taken from the first couple of paragraphs? Now I understand the reason for not having automatically generated Meta Descriptions, but right now when we post our articles on Google+, only the page title is being pulled through, so the post looks a little blank. Is there anyway to get the opengraph description tags to work?


Visual Editor gone

My visual editor is missing in a project I've tried this guide which includes deactivating ALL plugins, changing the theme, empting the cache and still at that point there was no Visual Editor, only the plain HTML editor. Turning on `define('SCRIPT_DEBUG', true);` in the wp-config.php didn't returned any error / warning in the browser console. The editor's tabs shows empty:

      With the browser's element inspector, I manually added the missing HTML tab code:               Text     Visual      Obvioulsly te tabs apeard but clicking on them returned the following JS error: > Uncaught ReferenceError: switchEditors is not defined onlick I've also reinstalled WP (3.9.1) at: /wp-admin/update-core.php Still missing the Visual Editor... I'm getting desperate and my client isn't happy. What I didn't do was manually delete wp-admin, wp-include and re-upload from fresh WP installation but it's a live site with heavy traffic and I'm not sure if this is safe. One error that I've noticed when I turned debug on for a quick check was: > Notice: wp_enqueue_script and wp_enqueue_style was called incorrectly. > Scripts and styles should not be registered or enquened until the > wp_enquene_scripts, admin_enquene_scripts, or login_enquene_scripts hooks. But how can I know which script caused that?


Is W3 Total Cache supposed to delete the local files after they are uploaded to CDN?

My site hosts/sells hundreds of photos. To optimize the loading of each image in the front-end I decided to use CDN. The plugin I'm using for that is W3 Total Cache. My question is; is it supposed to delete the images after they are uploaded? I was hoping CDN would act like an image hosting too so that my hosting wouldn't have to store the images. Does CDN allow that or it requires retaining a copy of each image in the local server?


switching test to production > main menu forgotten, background forgotten

the bigger question is: How to have a beta (test) site and production, and switch between them so easily that a user can do it. I **wrote a script** that does the move. Here's what the script does:               1. saves the target wp-config DB settings     2. dumps source_DB, with --add-drop-table --add-drop-database      3. replaces all http://source/ with http://target in dump_DB.sql     4. loads source_DB.sql in Target_DB     5. (there is no cache plugin in either sites)     6. rsync --delete /source/path/ to /target/path     7. chown -R /target/path  with the correct ownership      The script works perfectly. the source-site is practically identical to the target-site. The files are md5-identical between the srouce and target (except wp-config.php). BUT! (here's are questions)   * The main menu is "forgotten". I have to manually go to "menus" and select the main-menu from the drop-down box. it happens each time i switch these websites. **How can that be, if the database is copied 1:1 ?** Could it be that the menu is related to domain URL somehow?   * the background **preference** (controlled by "simplify" theme") is forgotten. I have to manually select the background images from existing images.    * Is there a better way to switch test-site <> production site without all this hassle? I Just want to have a test site and to switch DNS entries. My posts dont travel over the internet, so I dont need absolute URLS. changing "hosts" file solution is not acceptable for admin end-user.


Menu page with list of users

I need a way to create a menu page with a list of all users for administrative purposes. The list will be used by users that don't have permission or acceses to the "Users" menu page. The page need to have the User ID, Name, Registration Date, Nickname, User Level and User Role for each user Any idea how to achieve this ? Any reference docs or tutorial is welcome also.


Display the content of a custom field in the LCP template

Excellent plugin, my only problem is that I can't get the value of a custom field displayed where I want to. I have a custom field: imgx It's value is an HTML code, specifically for an image, like:                     I want to place this left of the post title in the template. How do this? Please post a code sample for the template file. I tried with 'echo', but nothing happens. Thanks in advance for your help! Sorry about this, I thought that people would know that if I'm using this tag, it woulf be obvious, that I'm referring to the Wordpress plugin List Category Posts. It's my First time here guys :) Anyway, here's the template that I want to get working. My comments start like this:                //zzz             /**              * The format for templates changed since version 0.17.              * Since this code is included inside CatListDisplayer, $this refers to              * the instance of CatListDisplayer that called this file.              */                  /* This is the string which will gather all the information.*/             $lcp_display_output = '';                  // Show category link:             $lcp_display_output .= $this->get_category_link('strong');                  //Add 'starting' tag. Here, I'm using an unordered list (ul) as an example:             $lcp_display_output .= '
';                  /**              * Posts loop.              * The code here will be executed for every post in the category.              * As you can see, the different options are being called from functions on the              * $this variable which is a CatListDisplayer.              *              * The CatListDisplayer has a function for each field we want to show.              * So you'll see get_excerpt, get_thumbnail, etc.              * You can now pass an html tag as a parameter. This tag will sorround the info              * you want to display. You can also assign a specific CSS class to each field.              */             foreach ($this->catlist->get_categories_posts() as $single):                 //Start a List Item for each post:                 $lcp_display_output .= "
";                      //zzz This is where I look for the custom field (displays nothing):                 $lcp_display_output .= get_post_meta($post->ID, 'imgx', true);                      //zzz This is where I try to display stuff:                 //zzz this works: $lcp_display_output .= 'hello world';                 //zzz this doesn't: echo "hello world"                      //Show the title and link to the post:                 $lcp_display_output .= $this->get_post_title($single);                      //Show comments:                 $lcp_display_output .= $this->get_comments($single);                      //Show date:                 $lcp_display_output .= ' ' . $this->get_date($single);                      //Show author                 $lcp_display_output .= $this->get_author($single);                      //Custom fields:                 $lcp_display_output .= $this->get_custom_fields($this- >params['customfield_display'], $single->ID);                      //Post Thumbnail                 $lcp_display_output .= $this->get_thumbnail($single);                      /**                  * Post content - Example of how to use tag and class parameters:                  * This will produce:
The content
                  */                 $lcp_display_output .= $this->get_content($single, 'p', 'lcp_content');                      /**                  * Post content - Example of how to use tag and class parameters:                  * This will produce:
The content
                  */                 $lcp_display_output .= $this->get_excerpt($single, 'div', 'lcp_excerpt');                      //Close li tag                 $lcp_display_output .= '
';             endforeach;                  $lcp_display_output .= '
';             $this->lcp_output = $lcp_display_output;


How can I get the Event Calendar for PHP 5.3 plugin to display a category specific calendar on each category archive page?

I am using the Event Calendar for PHP 5.3 plugin. I have a set of regional categories, ex. Coastal. I want to put a calendar on each region page, and I want that calendar to only show events from that region. How can I limit the calendar to only show posts associated with that region? Or better yet, to only show posts from the category archive the calendar is displayed on? This is the code you can add to a template file to call the calendar in, but there is no documentation on the plugin site to explain how to add to or alter this code to different purposes:               <?php ec3_get_calendar();?>      This problem has also been posted on the Wordpress.org forum for a couple months with no solution. Any hint at a possible solution would be greatly appreciated. UPDATE Someone has been trying to help me on the Wordpress.org Forums, but I don't understand them. Please take a look at the support forum and help me out. Maybe you can understand what they are trying to tell me and explain it to me in a way that I can understand.


How can save user linkedin link to my database

I need to get Profile link of user when click in LinkedIn icon in my site. So, When user click in this button, i need only get the profile link of him and save it in my site. Are there way to get it.


Upgrade to WP 3.5 hangs in "database upgrade" step

Just tried to upgrade my wordpress blog using the automatic upgrade function. It asks me to upgrade my database, and after I click the button all I get is a page with the wordpress logo, nothing else. When I reload the page, it doesn't change anything. The URL is `http://www.rhein-neckar-tango.de/wordpress/wp- admin/upgrade.php?step=1&backto=%2Fwordpress%2Fwp-admin%2F` If I try to access /wp-admin it redirects me to the "upgradee database" page, as if I never started the upgrade in the first place. I can access the blog pages, but not the backend. Steps taken so far:   1. Upgrade started (no plugins deactivated) = Fail = Backend no longer accessible   2. plugin directory renamed = started database upgrade = fail   3. Manual upgrade via FTP upload according to instrctions on wp codex   4. got up to database upgrade throwing an error (fields that it wants to add already exist, but there are no such fields in the database) Which steps should I take to debug and solve this problem? [Dirty fix] change wp_options/db_version to the one 3.5 uses. system seems to run.


After a manual update, themes and plugins that were installed (and still in the directory) are not being seen

The title pretty much says it all. The files and folders for my various themes and plugins are all intact in their proper path location under wp-content, but the WordPress install is not seeing them. Additionally, all of the pages within the site are loading a blank white pages (my assumption is that this is a result of the install not seeing any themes). I'm stumped...


Persist fields with Setting API

In my admin panel, if I use a sanitizing callback `register_setting()` and the field does not pass through my custom validation, I've been preventing the database from updating by using `return FALSE;` and adding an error with `add_settings_error()`. How do I return the invalid values back to the form fields that the user submitted, so that they don't have to start all over again?


Uploading/Deploying a Multi Site Install

So I was looking to create a multi site for a clients since the goal is to have the same branded theme on several sub domains to deal with different countries (e.g. mysite.com, usa.mysite.com, canada.mysite.com) where the root site was basically a map to pick our countries site. After reading all about wordpress multi site it seems this would be perfect. **My questions though is how development is different**. Basically how to transfer a multi site from DEV server to client. Will all the subdomains and structure/content transfer just like a regular WP install when I dump databases and transfer


Advanced Query Logic With Multiple Taxonomies

I have a page on my site that acts as a search tool/search results page for users to find rental spaces. On the left side is a column of checkboxes that let the user filter the results by three separate custom taxonomies (`space- types`, `space-features`, `space-areas`) the right side of the page lists the results after the checkbox form is submitted. I am trying to properly query the spaces (custom post type `space-listings`) based on the selected terms in each taxonomy but the logic doesn't seem to be possible and I'm not sure how else to do it. This is the needed logic: If the space listing has ANY of the `space-types` and ALL of the `space-features` that the user has selected AND has ANY of the `space-areas` that they have selected. Here is the closest I've gotten with my query array:               $searchspace = array (     'post_type'=>'space_listing',     'posts_per_page'=> 3,     'paged' => $paged,     'tax_query'=> array (         'relation' => 'AND',         array (             'taxonomy' => 'space-types',             'field' => 'slug',             'terms' => $searchedtypes, //Array of selected types                         'operator' => 'IN'//default             ),         array (             'taxonomy' => 'space-features',             'field' => 'slug',             'terms' => $searchedfeatures, //Array of selected features                         'operator' => 'AND'             ),                 array (                         'taxonomy' => 'space-areas',             'field' => 'slug',             'terms' => $searchedareas, //Array of selected areas                         'operator' => 'IN'//default             ),         )          );


Permalink change made author archive vanished

I changed my WordPress blog URL from:               http://example.com/%year%/%monthnum%/%day%/%postname%/      into first,               http://example.com/%postname%/      and then after many days,               http://example.com/%post_id%/%postname%/      But now seen that, they are taking the author archive link to a dead end (404). Where the default author archive link is: `/?author=1`, with any of these permalinks, the author archive's link becomes `/author/1`. But the URL is taking me to a 404. I've tested in my local dev environment too, can't get what's the exact URL which can give me the author archive. The author archive link, that's in my theme is:               <a href="<?php echo get_author_posts_url( false, $authordata->ID, $authordata->user_nicename ); ?>">        <?php the_author(); ?>     </a>      Is that a bug of WordPress or I'm doing something wrong?


Debugging WordPress themes with Xdebug, real time html output

Hi I'm using XDEBUG to debug my WordPress code, is it possible to view the page building up in the browser while debugging? At the moment the page just hangs until the debugging process is finished then displays the fully rendered page. Ideally I'd like to see the page building up bit by bit as I debug through the theme's code.


Automatically assign a custom post to a custom taxonomy based on custom field value

We have a custom post type called `listings`, and each `listing` has a custom field `zipcode` (which is a 5 digit number). We then have a custom taxonomy `area`, which can be "New York", "Los Angeles" etc. If the `zipcode` is "10001", "10002" or "10003" then it should be assigned to "New York", and if it's "90001" or "90101" then it should be assigned to "Los Angeles" and so on. How can we automatically assign each `listing` to an `area` based on the `zipcode` value? Thanks for any help!


Using tax_query creates a 1 = 0 or 1 = 1 in $wp_query->request

This is my first attempt at modifying the main query using the `pre_get_posts` action/filter This is the function currently hooked to it:               function advanced_product_search_filter($query)     {       if(!is_admin() &&          is_main_query() &&           is_search() && $query->query_vars['post_type'] == 'product')       {         $keyword = $_GET['s'];              if($_GET['exactly'])           $keyword = $_GET['s'] . ' "'. $_GET['exactly'] . '"';              if($_GET['without'])         {           $excluded = exclude_product_keyword_search($_GET['without'],                          $_GET['pname'],                         $_GET['pcode']                       );           $query->set('post__not_in', $excluded);         }              if($_GET['pname'])           $query->set('s', $keyword);         else           $query->set('s', '');              if($_GET['pcode'])         {           $tax_queries = $query->get('tax_query');           $tax_queries[] = array(             array(               'taxonomy' => 'pa_ordering-code',               'field' => 'name',               'terms' => array($keyword),               'operator' => 'LIKE'             )           );           $query->set('tax_query', $tax_queries);         }       }     }      This is a plugin built on top of a `WooCommerce` installation. So basically this function _tries_ to support searching a `WooCommerce` product either through the standard search (title and content) or an attribute search on a custom attribute called `Ordering Code` which is `pa_ordering-code` in the `term_taxonomy` table Other parts of the code works fine, I can modify the `s` and `post__not_in` vars without any problems, but if I try to use the `tax_query` it, the query seems to break down. To give you an idea, when I try this:               ?s=foo&post_type=product&pname=1&pcode=1&without=non&exactly=foo+bar      dumping the `WHERE` clause, I see this:               AND wp_posts.ID NOT IN (219)      AND 0 = 1      AND      (       (         (wp_posts.post_title LIKE '%foo%') OR          (wp_posts.post_content LIKE '%foo%')       ) AND (         (wp_posts.post_title LIKE '%foo bar%') OR          (wp_posts.post_content LIKE '%foo bar%')       )     )      AND wp_posts.post_type = 'product'      AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')      AND     (        (         wp_postmeta.meta_key = '_visibility' AND         CAST(wp_postmeta.meta_value AS CHAR) IN ('visible','search')       )      )      Notice the `AND 0 = 1`? When I dump the `JOIN` clause, I become sure that the `tax_query` parameter isn't being interpreted properly since I only see the `postmeta` table in there. No `terms`, `term_relationships`, or `term_taxonomy` table. And I also tried simply overwriting the existing `tax_query` (if there is one) by doing this:               $args = array(       array(         'taxonomy' => 'pa_ordering-code',         'field' => 'name',         'terms' => array($keyword),         'operator' => 'LIKE'       )     );     $query->set('tax_query', $args);      But I still could not get it to work. Any ideas as to what I may be doing wrong?


Get post by term from custom taxonomy in another blog on the network?

I'm having trouble getting post by term in a custom taxonomy I have set up. The catch is this is multisite and I'm getting this data from another blog on the network where the taxonomy is registered. The code I have works fine on the blog with which the taxonomy is registered. However when I try the same code on the other blog using switch_to_blog I get bool(false). Meaning, I guess, that there is an error in the sql. However if I just do is_term I can confirm it's there. Here's a link to the code that is working on the naitive blog but not the other,               <?php get_header(); ?>          <?php global $switched; switch_to_blog(2); ?>
          <?php         $type = 'portal_warrants';         $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         $terms = is_term( 'most-wanted' , 'warrant_status' );         $args=array(                 'post_type' => $type,                 'posts_per_page' => 6,                 'paged' => $paged,                 'tax_query' =>                         array(                                 array(                                         'taxonomy' => 'warrant_status',                                         'field' => 'id',                                         'terms' => 'most-wanted',                                 )                         )                      );                                                     $my_query = null;         $my_query = new WP_Query($args);         $i = 0;         if( $my_query->have_posts() ) {                 while ($my_query->have_posts()) : $my_query->the_post();                      if( $i % 3 == 0) :?>

                 <?php endif; ?>                 <?php print_r(var_dump($wp_query->request)); ?>

Wanted

                                                                  Arrested

<?php the_title(); ?>

Last Known Address:

Hair:

Eyes:

Height:

Weight:

               <?php $i++ ?>            <?php endwhile; } wp_reset_query(); ?>
           <?php restore_current_blog(); ?>          <?php get_footer(); ?>      *Edit (updated pastebin with switch_to_blog included) http://pastebin.com/uBbaXnSt Also, this doesn't output anything at all not even with `print_r(var_dump($my_query->request));` * * * Solution (or at least in part) * * * The problem is `switch_to_blog` doesn't give you access to everything in another blog on the network including taxonomies, tags, things in your functions.php, although don't quote me 100% on that. Therefore the taxonomy wasn't registered in the "switched to" blog. My solution (at least for now) register the taxonomy in that blog. After doing that, `tax_query` worked as expected. This is what I'm going with until I find a better solution (if one exists at all).


How to use different short description in shop page and in product page in woocommerce

What I would like to have is the sentence "Entre em contacto connosco para saber preços Aqui" just in product page, not in shop page. Please take a look in this page: http://www.kepaweleurope.com/shop/soutien-mamoplastia-85/ Does anybody can help me? Thanks in advance Miguel


Editor can create any new user except administrator

I have set up a WordPress site for a client. The client has the Editor role, however I have installed the Members plugin and given the client the capability to add new users to the WP admin. This is working just fine. The question I have is that I would like for the client to have the ability to create new user as with the roles of a Contributor, Subscriber, Editor and Author, but NOT Administrator. The new users the client creates should not have the Administrator role. Is it possible to hide this option somehow? Thanks Vayu


What type of Google tracking should I use?

I have WP Multisite and now I want to track the different sites.   I'm using Multisite Domain Mapping to map `www.mysite.com` to `http://subsite.mysite.com` My questions is: **a)** Do I need to add the same google analytics script to all themes?   **b)** when creating the script at GA, I have the following choices:   * A single domain (default)   * One domain with multiple subdomains   * Multiple top-level domains Do I use nr 2 or 3? I know there are plugins I can use. But I still have to create the scripts at GA, right?


Internal 500 error: Activating rootio theme and deploying with capistrano

When I deploy my wordpress site using Mark Jaquith's capistrano recipes, I get a 500 internal error when trying to activate my roots.io theme. All other default themes work. Here are my server logs: require_once(/www/ ** _*_ ****. _ **_** _**._ ** _*_ ***/releases/20140116200222/wordpress): failed to open stream: No such file or directory in /www/ ** _*_ ****. _ **_** _**._ ** _*_ ***/releases/20140116200222/wordpress/wp-content/themes/roots/functions.php on line 5, referer: http:// ** _*_ ****. _ **_** _**._ ** _*_ ***/wordpress/wp- admin/themes.php [Thu Jan 16 20:05:34 2014] [error] [client **_*_ ****] PHP Fatal error: require_once(): Failed opening required '' (include_path='.:/usr/share/pear:/usr/share/php') in /www/ ** _*_ ****. _ **_** _**._ ** _*_ ***/releases/20140116200222/wordpress/wp- content/themes/roots/functions.php on line 5, referer: http:// ** _*_ ****. _ **_** _**._ ** _*_ ***/wordpress/wp-admin/themes.php Here's my folder structure: ![enter image description here](http://i.stack.imgur.com/RRetj.png) So far I've tried:   * Downgrading to 3.8 stable from 3.9 alpha   * Replacing my custom roots theme with a fresh unedited one   * Changing my httpd config to point to the actual path of the file, not just the symbolically linked folder 'current'   * Moving my roots theme from `content/themes/` to `wordpress/wp-content/themes/` Any thoughts?


Maintain SEO of a website while migrating it to Wordpress?

i have a site url http://www.dualfocusphotography.co.uk i want to convert it to wordpress in such a way its SEO or site ranking should not be disturbed. any one guide me is it possible if yes then how? any help or relevant-materiel would be appreciated.


Dynamic height in custom header image panel

I've enabled the custom header image panel for my theme.. That all works fine, but it has a predetermined height. How can i make it dynamic? The width can be permanent. I used this code. http://www.wpbeginner.com/wp-themes/how-to-enable-custom- header-images-panel-in-wordpress-3-0/               define( 'HEADER_IMAGE_WIDTH', apply_filters( 'yourtheme_header_image_width', 940 ) );     define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'yourtheme_header_image_height',  198 ) );          set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );


How can I correctly redirect user to the submitted post and define a template for each new post in Wordpress?

What I want to do is to create a simple front-end post submit form, for every different type of post I will include in my Wordpress app. For example there will be articles, events, quick messages and those types will have a different design/structure for a user to see. Author will use those forms to post their content. As far as I know, I can have a different template for those types with the `if in category` function but I am interested in alternative solutions (maybe better). I know that there is `page_template` to add in the array http://wpengineer.com/1229/puplishing-extend-of-wordpress/ but is there anything else? Also I am having some difficulties to redirect or even echo the posted link (as below). For your concern, I can not echo the `$link` . Thank you for your help.               if(isset($_POST['submit'])){              global $user_ID;              $new_post = array(             'post_title' => $_POST['post_title'],             'post_content' => $_POST['post'],             'post_status' => 'publish',             'post_date' => date('Y-m-d H:i:s'),             'post_author' => $user_ID,             'post_type' => 'post',             'post_category' => array(0)         );              wp_insert_post($new_post);     }      I tried this for redirect without luck               $pid = wp_insert_post($new_post);     $link = get_permalink( $pid );     echo $link;     wp_redirect( $link );


if is within sidebar

I have several sidebars (more then 1 on a page) and I would like to set different image sizes to widgets, depending in which sidebar they are located. I tried               if( ! dynamic_sidebar('my-sidebar') ) :      and               if ( is_active_sidebar( 'left-sidebar' ) ) :      but this only seems to check if the sidebar's exist (and they do). How do I get: " **if widget is located in sidebar A, give me this size, elseif widget is located in sidebar B, give me that size** "?


WP Admin Login keeps redirecting to login

Everytime I try to login it keeps redirecting me to the login page, or pretty much just loops. No error messages, just redirects. If I reset the password it works, but the next time it starts all over again. Any ideas?


How to redirect to a page after the form is submitted

I am New to Wordpress.I am creating a Plugin Where I have to import a csv File to database.Uploaded and Entered data Successfully.But my Problem is once the file gets uploaded it shows a blank page with the success Message.How can I redirect to the same Page with success or error Message please help..Thanks in Advance.. Here is my code               $admin_services =   add_menu_page('Fee Schedule','Fee Schedule','administrator','pd-services','pd_services');     <?php     function pd_services(){     if ( $_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['admin_service_csv_upload']))          {             if(get_file_extension($_FILES["service_upload_csv"]["name"])!= 'csv')             {                 $error[] = 'Only CSV files accepted!';             }         if (!$error){             $tot = 0;             $handle = fopen($_FILES["service_upload_csv"]["tmp_name"], "r");                 //echo $file   =  $_FILES["service_upload_csv"]["tmp_name"];                 while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {                     for ($c=0; $c < 1; $c++) {                         //only run if the first column if not equal to firstname                         if($data[0] !='Department Name'){                             $insert_csv_query = "INSERT INTO wp_services(                                         dept_name,                                         inc_10_codes,                                         description,                                         uc_fee                                                     )VALUES(                                         '".mysql_real_escape_string($data[0])."',                                         '".mysql_real_escape_string($data[1])."',                                         '".mysql_real_escape_string($data[2])."',                                         '".mysql_real_escape_string($data[3])."'                                         )";                                 $insert_csv_query;                             $inserted = $wpdb->query($insert_csv_query);                             }                              echo $tot++;                 }         }     fclose($handle);     $content.= "
 CSV File Imported, $tot records added
";     }     } else {     ?>
         <form name="csvupload" action="" method="POST" enctype="multipart/form-data">

                     Upload Services from CSV	                     <input type = "file" name="service_upload_csv" id="upload_csv_id" aria-required="true">

                     <input type="submit" class="button-primary" name="admin_service_csv_upload" value="<?php _e('Save Changes')?>" />

         </form>         <?php echo $content ?>
     <?php     }     }      ?>


error:-Cannot modify header information - headers already sent by

whewn ever i try to login http://affiliatesurge.com.au/wp-admin/ i got "" Warning: Cannot modify header information - headers already sent by (output started at /home/affiliat/public_html/wp-config.php:1) in /home/affiliat/public_html/wp-includes/pluggable.php on line 881 "" Error ... i already try removing spacing in wp-config and functions.php


Get Admin Email Address From External PHP page

I am setting up a "built in" contact form that I need to pull the administrators email address from an external php page. For instance, my form `action="path/to/process_form.php"` Within that `proces_form.php` I have a few options set up.               $msg = "Form Contents: \n\n";     foreach ($this->fields as $key => $field)         $msg .= "$key :  $field \n";          $to = 'static@email.com';     $subject = 'New Form Submission';     $from = $this->fields['email'];      My goal is to dynamicly grab the admin email address from this page and populate the `$to = ''` area. Any help would be much much appreciated!


Frontend image uploading from frontend cant handle hebrew names

i'm using the insert_attachment code in my functions.php :               function insert_attachment($file_handler,$post_id,$setthumb='false') {            // check to make sure its a successful upload       if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();            require_once(ABSPATH . "wp-admin" . '/includes/image.php');       require_once(ABSPATH . "wp-admin" . '/includes/file.php');       require_once(ABSPATH . "wp-admin" . '/includes/media.php');            $attach_id = media_handle_upload( $file_handler, $post_id );            if ($setthumb) update_post_meta($post_id,'_thumbnail_id',$attach_id);       return $attach_id;     }      and build a nice form in a static page :                <form id="new_post" name="new_post" method="post" action="" enctype="multipart/form-data">
שם                   <input type="text" id="first_name" value="" tabindex="1" size="20" name="first_name" />

משפחה                 <input type="text" id="last_name" value="" tabindex="1" size="20" name="last_name" />

מקעקע                 <input type="text" id="tatto_artist" value="" tabindex="1" size="20" name="tatto_artist" />

גיל הקעקוע                 <input type="text" id="tatto_age" value="" tabindex="1" size="20" name="tatto_age" />

מחיר                 <input type="text" id="tatto_price" value="" tabindex="1" size="20" name="tatto_price" />

שם הקעקוע                 <input type="text" id="tatto_name" value="" tabindex="1" size="20" name="tatto_name" />

ספר על הקעקוע                 <textarea id="post_tags" tabindex="3" name="post_tags" cols="30" rows="2" name="post_tags"></textarea>

העלה תמונה :                  <input type="file" name="thumbnail" id="thumbnail"/>

<input type="submit" value="שלח" tabindex="6" id="submit" name="submit" />
               <input type="hidden" name="action" value="new_post" />               <?php wp_nonce_field( 'new-post' ); ?>             </form>      as you can see, the form is in hebrew. when i'm trying to upload attachment :               if ($_FILES) {       foreach ($_FILES as $file => $array) {         $newupload = insert_attachment($file,$pid);         echo ($attach_id);       }     }      my problems begin... the photos are loaded but if their names is in hebrew - it saves them in other names and cant find them. for example: name of file from my pc: סקיצה (1).jpg the name after i uploaded it, in the wp uploads folder : ׳¡׳§׳™׳¦׳”-1.jpg does anyone have any ideas how to handle this situation?


Auto Accept Friend Requests BuddyPress

I'm attempting to create a function that auto accepts friend request in Buddy Press, the function is as follows;               function bp_auto_accept_friend_request( $friendship_id, $friendship_initiator_id, $friendship_friend_id ) {              friends_add_friend(              $friendship_initiator_id,              $friendship_friend_id,              $force_accept = true          );              friends_accept_friendship( $friendship_id );     }          add_action('friends_friendship_requested', 'bp_auto_accept_friend_request', 200, 3);      The above function works by creating an entry in the `wp_bp_friends` table with a value of `1` for the `is_confirmed` column, however the default friendship request action is still being executed which adds an additional entry to the table saying unconfirmed.               id  initiator_user_id   friend_user_id  is_confirmed    is_limited       2          1                   3             1              0        3          1                   3             0              0         So we have both a confirmed and unconfirmed entry for the same friendship. This means that on the user profile page it will appear as if you have both **a confirmed friend** and have **a friend request** from the same person. The above function was adapted for simplicity from; http://premium.wpmudev.org/forums/topic/auto-accept-friend-requests There's also this accepted answer from WPSE here; How to auto-accept a friend-request in buddypress based on user meta ...which when adapted to my use case produced the same results described. Any thoughts on how to prevent the default action? So far I can't unhook the request...


How to make changes on Wordpress site locally on live site?

I would like to set up a System where I can clone a live website and work on it locally and then when I'm satisfied and the changes are approved, I can send or sync those changes with the live site. I'm currently watching gitHub tutorials, but I'm not sure if I'm on the right track.


List sidebars on a page

I need to generate a list of sidebars on a given page. I know how to list all sidebars that have been registered, and all sidebars that have been registered that have active widgets, but I do not know **how to filter** them down to **the sidebars that were displayed on an individual page** using PHP. To try to get around this I took `$wp_registered_sidebars` and swapped it out for a class that implemented `ArrayAccess`, which gets 90% of the way there in that it intercepts the calls and stores the requested sidebars, only the sidebars then never show because somewhere is an `is_array` or other check fails. I can also intercept `dynamic_sidebar_params` and check the id field in the first array item, but this only tells me which dynamic sidebars are called with active widgets, it doesn't tell me when an empty sidebar is tried. Here is my interception class:               class sidebar_counter implements \ArrayAccess {              private $container;         private $offsets = array();              function __construct( $container ) {             $this->container = $container;         }              public function addOffset( $offset ) {             if ( !in_array( $offset, $this->offsets ) ) {                 $this->offsets[] = $offset;             }         }              public function getOffsets() {             return $this->offsets;         }              public function offsetExists( $offset ) {             $this->addOffset( $offset );             return isset($this->container[$offset]);         }              public function offsetGet( $offset ) {             $this->addOffset( $offset );             return isset($this->container[$offset]) ? $this->container[$offset] : null;         }              public function offsetSet( $offset, $value ) {             if ( is_null( $offset ) ) {                 $this->container[] = $value;             } else {                 $this->container[$offset] = $value;                 $this->addOffset( $offset );             }         }              public function offsetUnset( $offset ) {             if ( ( $key = array_search( $offset, $this->offsets ) ) !== false ) {                 unset( $this->offsets[$key] );             }             return isset($this->container[$offset]) ? $this->container[$offset] : null;         }     }      It's intended usage:               // early on:     global $wp_registered_sidebars;     $this->counter = new sidebar_counter( $wp_registered_sidebars );     $wp_registered_sidebars = $this->counter;      then after the footer:               $sidebar_ids = $counter->getOffsets();


Calculate average crossing post categories

In my WP database I have some posts i the category `hotels` and some other posts in the category `visits`. In the posts (placed in the category `visits`) there is two meta_fields ( `rating` and `placeid` ) `rating` is the rating for the visit and `placeid` is the id (`post_ID`) for the hotel ( a post in the category `hotels`). Now I will want to make an average of the ratings for the hotel. I will do it in one MySQL-question. How can I join and calculate the average on the right way? Here is my code where I get the hotels:               $result = query("SELECT p.*             , x.adresse             , x.lat             , x.lon             , x.location                 , y.rating                 , y.placeid             FROM wp_posts p             LEFT             JOIN                  ( SELECT post_id                         , MAX(CASE WHEN meta_key = 'adresse' THEN meta_value END) adresse                         , MAX(CASE WHEN meta_key = 'lat'  THEN meta_value END) lat                         , MAX(CASE WHEN meta_key = 'lon'  THEN meta_value END) lon                         , MAX(CASE WHEN meta_key = 'location'  THEN meta_value END) location                      FROM wp_postmeta                     GROUP                        BY post_id                  ) x              ON x.placeid = p.ID                 LEFT             JOIN                  ( SELECT post_id                         , MAX(CASE WHEN meta_key = 'rating' THEN meta_value END) rating                         , MAX(CASE WHEN meta_key = 'placeid'  THEN meta_value END) placeid                      FROM wp_postmeta                     GROUP                        BY post_id                  ) y              ON y.post_id = p.ID             LEFT              JOIN                  ( SELECT * FROM wp_term_relationships ) r             ON (p.ID = r.object_id)             LEFT              JOIN                  ( SELECT * FROM wp_term_taxonomy ) q             ON (r.term_taxonomy_id = q.term_taxonomy_id)             LEFT              JOIN                  ( SELECT * FROM wp_terms ) t             ON (q.term_id = t.term_id)          WHERE p.post_status = 'publish' AND t.name = 'Hotels' AND q.taxonomy = 'category'       ORDER BY ID DESC ");      I also got these average-code - but can't implement it on my code. I'm stuck!               SELECT AVG(rating) as gennemsnit FROM anmeldelser WHERE placeid=$postid


Make parent category an optgroup

How to transform the parent category into an `optgroup`? Demo of what I want: http://fiddle.jshell.net/Pp7Ey/show/ Currently I have this code:                   $cat = $_POST['cat'];                  $data = array(             ..             'post_category' =>array($cat)             );          wp_insert_post($data);          <?php wp_dropdown_categories('orderby=name&hide_empty=0&show_count=1&show_option_none=Select one&class=cat&hierarchical=1&name=cat'); ?>


How to make "my posts" page

1. How to make a section, or better is something like a shortcode, to filter only posts added by me (or other user, depends on who is logged in)?   2. And how to hide this page (section) if is nobody logged in?


Separating search results collectively by type

My search results are limited to post types `book` and `author`. The following code in `search.php` displays all `author` posts first, then all `book` posts (I asked why post types are separated like that, but got no answer so far):               while(have_posts()) : the_post();                if ( 'book-author' == get_post_type() ) {                ?>
AUTHOR
             <?php the_title();          }         elseif ( 'book' == get_post_type() ) {               ?>
BOOK
             <?php the_title();          }     endwhile;       However I want to display these search results in two columns entitled "BOOKS" and "AUTHORS", each in its own `div` element. This code doesn't allow that, so how can I achieve such division?


How to SELECT number from table and use in calculation . Unsupported operand types

This is the PHP part of an ajax request. The user enters two numbers, via two fields. I can add these two numbers together & display the total in a field, this works OK. However, I would also like to add a number that has been retrieved from a custom table to this. So it's two user entered numbers + number from custom table. I get the following error: `br /><b>Fatal error</b>: Unsupported operand types in <b>/home/greentes/public_html/wp- content/plugins/jquery_validate_min1/activate2.php</b> on line <b>118</b><br />` Line 118 is   `$total = $numwelds + $numconwelds + $mpcountrys ;` My code:                function myajax_inputtitleSubmit_func() {           global $wpdb;     $mp_country_table_info = $wpdb->prefix . 'countries '; //Good practice     $mpcountrys = $wpdb->get_results( "SELECT labour_cost FROM $mp_country_table_info WHERE id='2' ");                       $nonce = $_POST['nextNonce'];            if ( ! wp_verify_nonce( $nonce, 'myajax-next-nonce' ) )             die ( 'Busted!');              $numwelds = isset($_POST['numberofwelds']) ? $_POST['numberofwelds'] : '';     $numconwelds = isset($_POST['numberofconwelds']) ? $_POST['numberofconwelds'] : '';          if (is_numeric($numwelds) && is_numeric($numconwelds))     {         $total = $numwelds + $numconwelds + $mpcountrys ;         $response = json_encode($total);         header("Content-Type: application/json");           echo $response;         exit;     }      }      What is wrong with this please?


Make the text field in search form optional

I've added some custom fields to my search form, which will be used more frequently than the original text field (`<input name="s" />`). However, the text field seems to be required to perform a search, and an empty value isn't enough. Valid: `http://www.example.com/?s=foobar&max_price=500` Invalid: `http://www.example.com/?s=&max_price=500` Is there any way to get round this? The HTML form is pretty simple:               <form action="/">        <input type="search" name="s" />        <input type="number" name="max_price" value="0" min="0" />        <input class="button" type="submit" value="Search" />     </form>


Apply styles to blockquote element with the WYSIWYG editor

I have a blockquote and I can float it left or right if I want by going into the html editor and adding class="alignleft" etc. Is there any way I can make that available to a non tech individual with a button or plugin / function or something. I think i'm looking at a tinymce plugin but i've never done anything with that area; so hoping to avoid that at this time if at all possible. If that is what I need would anyone have a code snippit or a link to a good tutorial. I imagine it's a fairly common thing to have.