title: Adding wp_ajax to a theme outside functions.php (on specific template page)

text: I'm doing a function which requires the use of the `wp_ajax` action. I've followed this guide to set it up with the differences of adding the requesting the object AJAX file in functions.php and also added               if(isset($_REQUEST['action'])) {         do_action('wp_ajax_'.$_REQUEST['action']);         do_action('wp_ajax_nopriv_'.$_REQUEST['action']);     }      to make it work. Issue is that obviously having the file in functions.php causes every page to initialise workflow, but I only want it on one particular template file. I could add it as a plugin I'm aware, but certain functions used are global to the theme and will never be used on any other theme so doesn't make sense in my mind to do that. Ideally, I would just like to do `require('ajax_file.php');` in the template file, but that's the main issue here is I don't think I can (unless somebody can correct me). So if there is an easy way to call it from the functions.php file without every other page also calling it then that would be a massive help. Thanks!


title: Help to condense/optimize some working code

text: WordPress by default shows ALL posts to users who are Authors. I wanted Authors to only be able to see their own posts so I came up with the following code which works well. Any suggestions to condense/optimize it?               // Only show posts related to current author     add_action('pre_get_posts', 'query_set_only_author' );     function query_set_only_author( $wp_query ) {         global $current_user;         if ( is_admin() && !current_user_can('edit_others_posts') ) {             $wp_query->set( 'author', $current_user->ID );         }     }          // Check that user is not an Administrator     if (!current_user_can('promote_users')) {         add_filter('views_edit-post', 'remove_mine');         add_filter('views_edit-post', 'posts_all');         add_filter('views_edit-post', 'posts_published');         add_filter('views_edit-post', 'posts_draft');         add_filter('views_edit-post', 'posts_pending');         add_filter('views_edit-post', 'posts_trash');     }          // Remove "Mine" from filter bar     function remove_mine( $views ) {         unset($views['mine']);         return $views;     }          // Fix "All" post count to only include posts related to current author     function posts_all($views) {         global $current_user;            $query = array(             'author'       => $current_user->ID,             'post_type'    => 'post'         );         $result = new WP_Query($query);         if ( get_query_var('post_status') == NULL ) $class = ' class="current"';         $link = sprintf(__('All (%d)', 'all'),                 admin_url('edit.php?post_type=post'),                 $result->found_posts);         $views['all'] = $link;         return $views;     }          // Fix "Published" post count to only include posts related to current author     function posts_published($views) {         global $current_user;            $query = array(             'author'       => $current_user->ID,             'post_status'  => 'publish',             'post_type'    => 'post'         );         $result = new WP_Query($query);         if ( get_query_var('post_status') == 'publish' ) $class = ' class="current"';         $link = sprintf(__('Published (%d)', 'publish'),                 admin_url('edit.php?post_status=publish&post_type=post'),                 $result->found_posts);         $views['publish'] = $link;         return $views;     }          // Fix "Drafts" post count to only include posts related to current author     function posts_draft($views) {         global $current_user;            $query = array(             'author'       => $current_user->ID,             'post_status'  => 'draft',             'post_type'    => 'post'         );         $result = new WP_Query($query);         if ( get_query_var('post_status') == 'draft' ) $class = ' class="current"';             $link = sprintf(__('Draft'.((sizeof($result->posts)>1)?"s":"").' (%d)', 'draft'),                 admin_url('edit.php?post_status=draft&post_type=post'),                 $result->found_posts);         $views['draft'] = $link;         return $views;     }          // Fix "Pending" post count to only include posts related to current author     function posts_pending($views) {         global $current_user;            $query = array(             'author'       => $current_user->ID,             'post_status'  => 'pending',             'post_type'    => 'post'         );         $result = new WP_Query($query);         if ( get_query_var('post_status') == 'pending' ) $class = ' class="current"';             $link = sprintf(__('Pending (%d)', 'pending'),                 admin_url('edit.php?post_status=pending&post_type=post'),                 $result->found_posts);         $views['pending'] = $link;         return $views;     }          // Fix "Trash" post count to only include posts related to current author     function posts_trash($views) {         global $current_user;            $query = array(             'author'       => $current_user->ID,             'post_status'  => 'trash',             'post_type'    => 'post'         );         $result = new WP_Query($query);         if ( get_query_var('post_status') == 'trash' ) $class = ' class="current"';         $link = sprintf(__('Trash (%d)', 'trash'),                 admin_url('edit.php?post_status=trash&post_type=post'),                 $result->found_posts);         $views['trash'] = $link;         return $views;     }


title: How to make user accept license agreement before download

text: I use my Wordpress site to host downloads, among other things. According to German law I need to make a user accept the license agreement prior to being able to download a program. I am thinking of displaying the license agreement in a pop-up window similar to the way Codeplex does it (see this page and click on download). **How can I accomplish this easily in Wordpress?**


title: Using custom post types within a section of a template

text:
I'm trying to get the hang of custom post types and I am trying to get them to loop through the post types within a page template. I'm already using the MultiEdit plugin to display certain content regions within my template. Overall, here is what my template page looks like:               <?php     /*     Template Name: Home Template     MultiEdit:Icons,NameTitle,CategoriesTitle     */     ?>     <?php get_header(); ?>     <?php query_posts( 'post_type=homecategories'); ?>     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

     <?php multieditDisplay('Icons'); ?>

              <?php the_content(); ?>

         <?php multieditDisplay('NameTitle'); ?>

              <?php multieditDisplay('CategoriesTitle'); ?>

                       <?php edit_post_link('Edit this entry.', '
',      '
');          ?>

                <?php //comments_template(); ?>         <?php endwhile; endif; ?>     <?php //get_sidebar(); ?>     <?php get_footer(); ?>      If I keep it like this the only thing that shows is the entries from the custome post type and nothing else. And what I am trying to accomplish is get it to only display the custom post types within this section in the template:

           Like I mentioned, I'm still getting the hang of using and implementing custom post types and I'm not really sure if this is the right way to go or not. Thanks!


title: Conditional styling of wp_list_pages bullet points

text: I'm looking for some type of script that allows me to select custom image bullets for my wp_list_pages for 3 scenarios:   1. If a page does not have a child   2. If there are children   3. If a page was recently updated, provided that the page has children I'm not sure how to do this. Since the depth of the children can vary, I would not edit style.css for for my last child. Since the wp_list_pages is what outputs the ul, I'm not sure how to write an argument (perhaps in my Walker class) that says if this page has zero children, . Can anyone advice on this?


title: Check if post has gallery images/media

text: Is there a Wordpress conditional that I can use to check for gallery images/media in a post? I do not want to check if the [gallery] shortcode exist in a post. Attached is a screenshot of what I want to check for and if is images I want to output them to the page. ![Gallery has 4 image](http://i.stack.imgur.com/DJe2z.jpg)


title: Subdomain and subdirectories together in one installation

text: I'm currently want to develop my design company website and choosing wordpress as my CMS. How do I should install the wordpress when I want the domain structure like this:   * Blog = blog.example.com   * Portfolio = example.com/portfolio/...   * Shop = shop.example.com = using WooCommerce I'll be glad if someone would help, because I really have no idea to config.


title: WP_enqueue_script inside shortcode?

text: I've got shortcode that needs to include JS library only once and only there where it's used.               function shortcode_function($atts, $content = null) {         $class = shortcode_atts( array('something' => '0'), $atts );              return "<script src=\"http://maps.googleapis.com/maps/api/js?sensor=false\"></script>                  And here goes HTML code for the map.";     }     add_shortcode("sh", "shortcode_function");      The problem is that above example is going to include library several times if maps shortcode is used several times. How can I prevent that? Or more precisely: how can I do it "the correct way"? Can I use `wp_enqueue_script()` in that place? Just one requirement: I really need this to include that library **only-when- shortcode-is-used**.


title: What should I use? index.php, front-page.php and home.php

text: I'm building a WordPress theme but I'm bit confused. I don't know what to use. There is `home.php`, `front-page.php` or `index.php`. When I started building the WordPress theme I started with `index.php` and gave it this code:               <?php get_header(); ?>      after that I found that there is that 3 pages `index.php`, `front-page.php` and `home.php`. So I realised that I need front-page.php, from what I heard it loads first so I will use it for front page which will have news slideshow and etc. Well now here is the question, what for is `index.php` or `home.php`? Do I really need these two files? And can I use `index.php` as front-page? Do I really need `front-page.php`? Can't I just use `index.php`? Thank you.


title: Using subdomain as primary domain

text: I have a dev site at sub.example.com. Instead of migrating the dev site to the root folder, is it possible to do something similar to this but using a subdomain instead of a subdirectory?


title: Wordpress SEO plugin by Yoast Breadcumbs

text: Currently i am using the WordPress SEO plugin by Yoast. if i activate the breadcrumbs in the plugin and set the code in my custom post type single page it is not properly displayed. (Home > Features) instead of (Home > Features > current single feature) i am using archive => true already and i have no idea why its acting this way. no custom hacks done just a custom post type and a clean install of wordpress and the plugin. Also how do i tried adding a page called Features and created a template of my archive page, still the same result. What is the best way to get this to work?


title: Fallback for empty custom fields

text: I'm using, for example: `<?php echo get_post_meta($post->ID, "Pricing_Land_Only", true); ?>` but need to know how to implement the 'else' function to display 'Nothing found' if I didn't type anything in that field. The reason being is for different pricing fields that I have and while not all pages use the same fields, most would. Thanks!


title: Setting a page link in the footer?

text: What is the proper process for setting a page up with a link to it in the footer? Currently, all my pages are in Appearance -> Menu...and of course displayed in the main menu. However I want a batch of them to be in the footer. I have decent HTML,CSS, PHP skills but new to WP.


title: Unable to login to new custom domain on multisite?

text: **Background** I setup WordPress Multisite a while ago. I added one on a custom domain, and more on subdomains of the main site. Since then I've added more on subdomains, and so far everything has worked fine. **Problem** I added another on a custom domain, and for some reason I cannot log into it. Each login attempt redirects to the login page again. All the other existing domains still work just fine. **What I Tried** I'm pretty sure it is cookie related. I was able to login once by resetting the password, but then it didn't login again. I've tried multiple browsers to see if that was the issue. I checked the .htaccess to see if there were special directives for either of the custom domains, and didn't find anything. I compared the settings for both sites (from the Network Admin dashboard) and didn't see anything out of the ordinary.


title: How to link a word comprised of a custom field with another?

text:
I want to link content comprised of a custom field(field1_details) using another custom field(field2_link) which is a URL type. `the_field('field1_details')` is text_area field and `get_field('field2_link')` is a website field (using a ACF addon). (These custom fields are created using Advanced custom fields plugin) **Here is the code I am trying in loop.php:**               <a href="<?php get_field('field2_link'); ?>"><?php if( function_exists('the_field') ) the_field('field1_details'); ?>      Output-                The text content ( Doesn't out put the link)      **And tried this without the`if`**               <a href="<?php get_field('field2_link'); ?>"><?php the_field('field1_details'); ?>      **Trying with`the_field` instead of `get_field`**               <a href="<?php the_field('field2_link'); ?>"><?php the_field('field1_details'); ?>      Output- `<span><a href="<a href=" http:="" google.com"="" target="_blank">google.com</a>">This is the test content</span>` ===================================================== The two custom fields works fine if I use them separately like this: **Field 1- field1_details** Output HTML-
This is the Text     content
      **Field 2- field2_link** or without the `if`               <?php the_field('field2_link'); ?>      Out put-                google.com      I think I am not using it in a right way. Could any one tell me how to link the field with a URL entered in the another field in loop.php? Also tell me how would you do it in the functions.php instead of the templates like loop.php


title: pre_set_site_transient_update_plugins wont call on hosted webspace

text: Iam trying to use "pre_set_site_transient_update_plugins" to update my plugin from a GitHub repository. For that Iam using this example https://github.com/bfintal/Plugin-Update. On my Dev-System (MAMP for Mac Version 2.2) everything is fine. It gets the latest Version and shows me the update notification. When I publish it to my Live System wich is a hosted webspace package. I don’t get the Update Notification. Even after waiting 12 hours or using ?force- check=1 What I already did was to create a simple Plugin that logs a string to the wordpress log when "pre_set_site_transient_update_plugins" is called. Again on my Dev-system it works, but not Live. So I think it has something to do with the PHP configuration. Does anyone has an idea which setting could prevent this filter from beeing executed? Thanks


title: LogOut button only if logged in in front end menu widget

text: I would like to add a "LogOut" button at the end of my sidemenu - but of course only, if someone is logged in. I also want to have it in two languages using qtranslate. At the moment I have created a new Menu Item "Log Out" with a link to `/wp- login.php?action=logout` which works, but always shows up of course. Is there a way to put something like this in the function? Any help - or just a hint would be very nice! :)


title: How to correctly add a table to the Wordpress MySQL database

text: I want to add a new table to the Wordpress database. I need this one for a specific section of my Wordpress website, that requires something a bit different than what I can achieve through custom posts. What would be the correct approach to do that? Is it enough to just add a table of my own or is there something I need to do in PHP code as well to make Wordpress aware of it? Will this affect in any way Wordpress upgrade procedures?


title: Recent Posts widget missing current_menu_item class

text: Unlike the (WP standard) Custom Menu widget, the Recent Posts widget does not add the current_menu_item class when a post is selected (being displayed). This seems like a major oversight, am I missing something? If not, does anyone know of a third party widget that lists the most recent posts and includes the current_menu_item class (or equivalent)? ...or perhaps some magical hack to achieve the result of adding a class to the active menu item?


title: Change website URL without breaking links or images? WP 3.3

text: I am using Wordpress 3.3.2. Currently I am working on a website in a dev folder on my domain, dev.domain.com. Upon creating pages and blog posts, it just occurred to me that when I move the WP website from dev.domain.com to domain.com that all the images I have used in all my pages and posts will break. Also some images are linked to specific pages or blog posts. Those will break as well. I don't know why I was under the impression that when I linked to images in the WP media manager or when I linked to specific posts, the information updated if the website URL or permalink structure changed. Can anyone advise me on either how I should go about adding pages/blog posts/images while in my dev folder so the links won't break when I move over OR what would be the best way to fix all the broken links once I have moved the website over to domain.com? Thank you in advance for all your advice!


title: FTPS Uploads - wp-content cannot be found

text: i've arranged my new Server and i use proFTPD with TLS Support. Now, WordPress can't upgrade or install plugins anymore. I get the following message: The directory "wp-content" cannot be found This is my FTP(S) Setup at wp-config.php:               /** FTP */     define( 'FS_METHOD', 'ftpext' );     define( 'FTP_USER', 'username' );     define( 'FTP_PASS', 'password' );     define( 'FTP_HOST', 'example.com' );     define( 'FTP_SSL', true );      EDIT: previously i have defined the following constants to prevent this bug:               define('CONCATENATE_SCRIPTS', false);     putenv('TMPDIR='. $_SERVER['DOCUMENT_ROOT'] .'/wp-content/tmp');     define('WP_TEMP_DIR', ABSPATH . 'wp-content/tmp');      .. but that doesn't work anymore.


title: How to limit the number of posts on the home page?

text: I am working on my first WP site and am having some difficulty. In my theme's index.php page, I see the following code:               <?php      query_posts(array(       'category__not_in' => array($headline),       'post__not_in' => $postnotin,       'paged' => $paged,       'numberposts' => 5     ));     if ( have_posts() ): $postCount = 0; ?>     <?php while ( have_posts() ) : the_post(); $postCount++;?>     [more code....]      So - you see I'm trying to limit the number of posts on the home page to 5, which I thought was the default. Anyways, it is showing more than 5 and I can't seem to get it to work. I've tried "posts_per_page" without luck. If my theme is overwriting it, any ideas where that may be? FWIW, I'm using the initiator theme by colorlabs Thanks!!!


title: wp_list_categories() not listing categories

text: I've many categories in my database but when i'm calling `wp_list_categories()` it is not listing any categories, its only outputting               Categories       No categories      Also, I'm trying to populate it using `get_categories()` but still same problem, it outputting as if there were no category


title: How to implement two separate featured images for each post/page

text: So I would like to set two separate feature images for each post/page. One would be a rectangle for use in a slider and another would be a square for use on archive pages, search pages, category pages. WordPress can do this, but it either resizes the initial image to the nearest resolution or crops it. I would rather create it myself and upload it.


title: Auto Refresh Post List after X seconds

text:
i'm new in wordpress, and i really need a help here. My main site, list the resume (excrept) of all posts, with pagination. But when a user publish a new post, the only way to see it on the main page is to reload it... I want to know if there's a way to automatic show new posts , like facebook.... I didn't found a way to do it untill now. I've removed the following line from my index.php (inside the /wp- content/themes/wp_blogger/):               <?php if (have_posts()) : while (have_posts()) : the_post(); ?>          <?php include(TEMPLATEPATH."/excrept.php"); ?>          <?php endwhile; else: ?>

<?php _e('Nenhum post encontrado com estes critérios.'); ?>

          <?php endif; ?>      I've put the code above inside a load.php (at the same directory), and replace it inside the index.php with:

      But no luck with that... i'm getting this error: Fatal error: Call to undefined function have_posts() in /var/www/RMON/blog/wp- content/themes/wp_blogger/load.php on line 1


title: Limit ads appearing more than three times

text: I am using the following code in content.php to repeat an ad insertion. Ads are inserted in the middle of every 2nd row in a grid of thumbnails. There are 3 thumbnails per row.               <?php else : ?>       <?php global $wp_query; ?>      <?php if (($wp_query->current_post + 1) % 5 == 0 ): ?>       <div class="box">        <adsense code>       </div>     <?php endif; ?>      However Google's AdSense policy limits 3 content ads per page and I don't want to violate these terms. How can I limit this to only three instances? Thanks for your help.


title: Using wordpress and codeigniter in one website

text: Is it possible to use WordPress as the CMS but all of contents will be displayed using CodeIgniter? What I want to know also if I can use the WordPress functions by simply including this `wp-blog-header.php` in the CodeIgniter. Do you guys think this idea will work? Probably one of the function I really need is `apply_filters()`


title: Retrieve post thumbnails

text:
I am trying to build a wordpress blog from scratch. I am looking to retrieve all the articles from a specific category. I then want to also include the SQUARE thumbnail(not a stretched version, a cropped square). I am slightly confused on how to do this. I tried searching the web.
Latest free recipe
     <?php $temp_query = $wp_query; ?>     <?php query_posts('category_name=recipes&showposts=1'); ?>     <?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?>

     By <?php the_author() ?>

     <?php                if ( has_post_thumbnail() ) {        the_post_thumbnail();     }else{          }          ?>     <?php the_content(); ?>
     <?php endwhile; ?>


title: What is the Wordpress Pinecone sitting on top of?

text: Does anybody know where wordpress gets their banner images? Perhaps we could find the original photo? I'm curious just what exactly this pine cone is sitting on top of. ![image](http://img828.imageshack.us/img828/9583/pinecone.jpg)


title: Possible to change meta data single quotes to dobule quotes in yoast wordpress seo?

text: The yoast wordpress seo plugin puts meta description and meta keywords in single quotes. The issue here is that many old spiders and directory submission sites do not read meta data in single quotes. Also i dont really know if there is any benefit in using single quotes over dobule quotes for meta data. So i am wondering if it is possible to change those single quotes to dobule quotes? Thanks


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

text:
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.'
';                          }                     }                     ?>


title: How to change URL of Pagination?

text: 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


title: Creating archive pages for children categories

text:
**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.


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

text: 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 :(


title: What are the advantages to the Settings API?

text:
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?


title: How to show full post on home page

text: 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?


title: Overriding wp_nav_menu default arguments

text:
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.


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

text: `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)


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

text: 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>


title: What does the output of this plugin mean?

text: 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.


title: Plugin options will not save in database

text: 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


title: Add Role inherits?

text: 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.';     }


title: How to get comments with mixed status using get_comments?

text: 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')));


title: Share Tags Between Custom Posts in Admin

text: 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.


title: Custom post query error

text:
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       ?>


title: Add Custom Values to Permalinks Through Custom Fields and Posts

text: 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.


title: IIS7.5 URL rewrite pboblem on index page

text: 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>


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

text: 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/


title: Image archive without date

text: 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?


title: Disable some features in Admin

text: 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?


title: Overwrite custom post type (WP SEO Local)

text: 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!


title: Large WP 3.0 menu times out and won't save

text: 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


title: How to add exception to Wordpress's web.conf

text: 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


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

text:
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();     ?>


title: wp query problem

text: 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' ) );


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

text: 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?


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

text: 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.


title: AJAX pagination offset returns same post on adjacent pages

text: 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).


title: Wordpress: robots.txt gives 500 Internal Server Error

text: 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);     }


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

text: 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?


title: Wordpress single.php different layouts projects / posts

text: 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


title: Remove HTML from search.php of my parent theme

text:
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


title: Add mime types with plugin

text: 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?


title: How to count nav menu items?

text: 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;


title: Exclude top-level pages from search results

text: 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.


title: Importing old Disqus comments into WordPress

text: 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.


title: pad_count with custom taxonomies and attachment post type

text: 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.


title: Wordpress language switcher

text: 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


title: Make the css of the widget overwrite theme css

text: 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' );         }


title: Hide content editor for posts after approriate date

text: 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.


title: Display 3 recent posts from one taxonomy

text: 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.


title: OpenGraph descriptions not showing when using Wordpress SEO (Yoast)

text: 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?


title: Visual Editor gone

text:
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?


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

text: 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?


title: switching test to production > main menu forgotten, background forgotten

text: 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.


title: Menu page with list of users

text: 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.


title: Display the content of a custom field in the LCP template

text:
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;


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

text: 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.


title: How can save user linkedin link to my database

text: 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.


title: Upgrade to WP 3.5 hangs in "database upgrade" step

text: 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.


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

text: 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...


title: Persist fields with Setting API

text: 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?


title: Uploading/Deploying a Multi Site Install

text: 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


title: Advanced Query Logic With Multiple Taxonomies

text: 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             ),         )          );


title: Permalink change made author archive vanished

text: 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?


title: Debugging WordPress themes with Xdebug, real time html output

text: 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.


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

text: 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!


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

text: 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?