WP Query with custom taxonomy

I'm just getting used to the WP Query and was hoping I could get some assistance on this. I've created a custom taxonomy (theme) and now want to display the latest post with one of these taxonomies on my front page as a top featured post. Now I can't really seem to work out how to get it to filter the query properly, maybe someone can correct me:               <?php                $args = array(                     'tax_query' => array(                         array(                             'posts_per_page' => 1,                             'taxonomy' => 'theme',                             'field' => 'slug',                             'terms' => array ('text-image', 'just-text', 'just-image')                         )                     )                 );                 $query = new WP_Query( $args );                ?>                <?php if (have_posts()) : while (have_posts()) : the_post(); ?>      Any help would be highly appreciated, thanks! EDIT: Here's the finished code in case anyone else needs it;               <?php                $args = array(                 'post_type' => 'post', // it's default, you can skip it                 'posts_per_page' => '1',                 'order_by' => 'date', // it's also default                 'order' => 'DESC', // it's also default                     'tax_query' => array(                         array(                             'taxonomy' => 'nameoftaxonomy',                             'field' => 'slug',                             'terms' => array ('whatever1', 'whatever2', 'whatever3')                         )                     )                 );                 $query = new WP_Query( $args );                ?>                <?php if (have_posts()) : while( $query->have_posts() ) : $query->the_post(); ?>      Thanks for the help!


Memory needed to host 200 wordpress sites?

I'm planning to use Multisite to host 200 different wordpress blog with each having their own unique subdomain. I notice each time I create a virtual host for each subdomain it'll use roughly 50mb ram. So if 50mb * 200 sites = 10GB RAM correct me if wrong is 10GB of RAM needed to host 200 sites? if possible is there solutions to decrease ram usage?


How to export comments in WordPress?

I want to export my comments to Excel, PDF or Word. The format really doesn't matter, I just want them exported. I tried the _Export Comments_ plugin, the standard one, but couldn't get it to work, I have to do it manually. Anyone can suggest something on this topic?


wp_ajax_[service] returning 0

I have a few Ajax services that I'm setting up. All of them require being logged in so I've attached hooks into the "wp_ajax_[$service]". The problem is when I call these services I just get a "0" response. I also get no record of anything in my php error log. What I'm wondering is:   1. Is there a way to hook into ALL Ajax requests and dump some debug information into the log file so I can get some more info out what is going on?   2. Has anyone seen this problem before? Are there any tips about solving for this type of problem? UPDATE: Including code to give more context. First the the Javascript, it is:               ServiceCall ( 'get-action-template' , {'action' : action} , function(response) {// callback function});      and the ServiceCall function is:               function ServiceCall ( service , parameters , callback ) {         console.log ('getTemplate was called: (' + service +', ' + parameters + ')' );              //initialise a request object         var requestObj = {};         requestObj.response = 'ajax-response';         requestObj.type = 'POST';         requestObj.url =  my_config['ajax-service-list'][service]['url'];         requestObj.data = $.extend ( requestObj.data , {                                                 'service': service,                                                 'request_parameters': JSON.stringify(parameters),                                                 'ajax_nonce': my_config['ajax-service-list'][service]['nonce']         });         requestObj.global = false;         requestObj.timeout = 30000;         requestObj.success = function ( r ) {             alert ( "Success: " + JSON.stringify (r) );             callback ( r );         }         requestObj.error = function ( r ) {             console.log ("FAILURE WITH AJAX Call ( " + JSON.stringify (r) + ")");         }         $.ajax( requestObj );     }      This then generates the following message (taken from network panel in browser's debugger): ![debug](http://i.stack.imgur.com/piYOq.jpg) Finally, here's the code for the handler function (which NEVER gets called):               public static function ajax_handler () {         error_log ( "AJAX HANDLE"  );          $service = $_POST['action'];         $request_parameters = json_decode ($_POST['request_parameters']);         if ( LG_Utility::key_from_hash ( self::$services_list , $service , false ) ) {             $object = new self::$services_list[$service]['class'] ($service);             $object->handle( $service , $request_parameters );         } else {             if (class_exists ('AppLogger') ) AppLogger::error ( "Trying to handle a service ({$service}) which is not registered!");          }     }      I have validated, however, that it is hooked correctly to the wp_ajax_get- action-template event. The shorthand "proof" is using the popular "debug objects" plug-in I was able to validate that it was set. Here's the whole PHP class that's managing the AJAX transactions (some methods/consts removed for brevity):                class LG_AjaxServiceManager      {        private static $services_list = array(         'get-action-template' =>    array ( 'class' => 'LG_GetActionTemplate' , 'login_required' => true ),         'some-other-service' =>     array ( 'class' => 'LG_FooBar' , 'login_required' => false )        );        public static function add_listeners () {         foreach ( self::$services_list as $id => $service ) {             add_action ( 'wp_ajax_' . $id , 'LG_AjaxServiceManager::ajax_handler' );             if (class_exists ('AppLogger') ) AppLogger::log ( "Registering $id as an Ajax service" );          }           }         public static function ajax_localize () {         // add hook for script localisation; this is important so that JS scripts have nonce and URL information         foreach ( self::$services_list as $id => $service ) {             $service_url = wp_nonce_url ( admin_url ( 'admin-ajax.php?action="' . $id .'"' ) , self::AJAX_APP_NONCE_KEY . '_' . $id );             preg_match ( '/.*action=%22(.*)%22&_wpnonce=(.*)/' , $service_url , $service_parts );             self::$ajax_js_array [ $service_parts[1] ] = array ( 'nonce' => $service_parts[2] , 'url' => esc_url ( $service_url ) );         }              $localize = array (                 'SiteURL' => get_bloginfo ('url'),                 'AjaxURL' => admin_url ('admin-ajax.php'),                 'ajax-service-list' => self::$ajax_js_array         );         wp_enqueue_script ( 'jquery' );         wp_enqueue_script ( self::JS_FILE_HANDLE  , plugins_url ( '/js/lg-ajax-client.js' , dirname(__FILE__)) , 'jquery' );              wp_localize_script( self::JS_FILE_HANDLE , self::JS_NAMESPACE , $localize );             }        public static function ajax_handler () {         error_log ( "AJAX HANDLE"  );          $service = $_POST['action'];         $request_parameters = json_decode ($_POST['request_parameters']);         if ( LG_Utility::key_from_hash ( self::$services_list , $service , false ) ) {             $object = new self::$services_list[$service]['class'] ($service);             $object->handle( $service , $request_parameters );         } else {             if (class_exists ('AppLogger') ) AppLogger::error ( "Trying to handle a service ({$service}) which is not registered!");          }        }     }


Custom ajax call returns 0

I' am still searching on why am getting 0 when doing a ajax call on wordpress. I know that when a ajax call is successfull it returns 0. I' am returning some value from the ajax call and it returns 0 with it. Here's my code Javascript               $.ajax({         url: "/wp-admin/admin-ajax.php",         type: 'POST',         data:{             action: 'registerform',             name: 'John',             age: '38'         },         success: function( data ){             alert(data);         }     });      PHP Function               function registerform(){         echo $_POST['name'];     }     add_action('wp_ajax_registerform', 'registerform');     add_action('wp_ajax_nopriv_registerform', 'registerform');      Above Code returns John0 Please help?


wp_list_categories in in nav_menu

I have a website and I want to add automatically categories to my menu. I mean when I create new category it should appear in my menu. How I can make it?                 <?php wp_nav_menu( array( 'theme_location' => 'header', 'container' => '' ) ); ?>          Home | Categories | Contact               category1               category2               category3


linking to post outside the loop

Is there an easy way to link to a specific page/post outside the loop? I used the `get_permalink()` code as follows.               <a href="<?php echo get_permalink( 164 ); ?>/post-slug/"> </a>      But this meant that I had to get the post ID from the Shortlink in the Admin for the post I wanted and then append the slug to it. Is there a better way to get the post ID of the post I am looking for, without using the loop? My permalinks are set up to use the post name so this seemed to work.


How to correctly include jquery-ui effects on wordpress

I've been trying to include the jquery ui effects (more specifically the shake effect) on my wordpress theme. So far, I've only been able to include the jQuery script, but I really have no clue where to place the ui scripts and how to enqueue them. This is the code I have. It obviously doesnt work:                   <?php wp_enqueue_script("jquery"); ?>     <?php wp_enqueue_script("jquery-ui-core"); ?>     <?php wp_head(); ?>     <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" />     <script type="text/javascript">         var $j = jQuery.noConflict();         $j(document).ready(function() {             $j("#manita-imagen").mouseover(function(){                 //$j(this).animate({ opacity: "hide" })                 // alert('asd');                 $j(this).effect("shake", { times:3 }, 300);             });         });           </script>      Thanks for your help!


What is the new Network Admin section?

Previously, in WordPress 3.0, multisites were managed through a Super-Admin section of the administration interface. The 3.1 update seems to have moved the administration of multisites to a new "Network Admin" section, which has a similar layout to the standard WP administration panels, but only contains options related to network administration. This section, however, seems to be pretty similar to the old Super-Admin section. Has there been any additional network management features added, or is the Network Admin section just a separation of options?


Get FaceBook Friend Count

Is there a simple PHP or Javascript method of getting the total number of FaceBook friends? Twitter makes it super easy to do that, and I need to do the same for one of my WordPress installs.


How to get the post content from a category on my homepage

I'm trying to get posts with a specific category to show in a box on my home page. But ive only been able to get one post on my homepage. How can I make this work in the code below? With getting the title, excerpt (limit the characters - without read more) and post link (in the read more button below?)               echo '

';                 echo get_the_title();                 echo '

';                 the_excerpt();                 echo '

                 Read More

';      EDIT: Thanks Pieter Goosen. This is the code with your suggestions and some minor edits which I ended up using with some jquery and css to create a pretty sliding box:               function homepage_highlights() { ?>     <?php $my_query = new WP_Query('category_name=accommodation&posts_per_page=3'); ?>     <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>

                 <div class="item" <body style="background-image:url(<?php echo catch_that_image() ?>)">

<?php echo '' . get_the_title() . ''; ?>

             <?php the_excerpt(); ?>


Copying Custom Meta Values from existing post to a duplicate post

I'm trying to revise an existing WP plugin BU Versions to accept different custom meta field values from items I've set-up using the Advanced Custom Fields (ACF) plugin. BU Versions will copy over the title, excerpt, content and a few other page specific features from one page to another, but I can't get it to copy over the custom meta values. For example, when I print_r($new_version), I get this in my results for what exists within the array, so I know it is adding the custom meta fields and values that are currently on the live page I am testing post duplication on.               Array(     [post_type] => page_alt     [post_parent] => 40     [ID] =>     [post_status] => draft     [post_content] =>     [post_name] => resources     [post_title] => Resources     [post_excerpt] =>      [_subheading] => For ELI Students     [_edit_last] => 3     [_wp_page_template] => default     [_edit_lock] => 1368111234:3     [add_columns] => 0     [_add_columns] => field_37     [left_column] => Array()     [_left_column] => field_39     [right_column] => Array()     [_right_column] => field_61     [header_image] => 426     [_header_image] => field_64     [_yoast_wpseo_linkdex] => 0     [3] =>     )      And this is the part of the code where I think the plugin creates a new post based on existing post values               /**      * Create a new alternate version.      *      * @param mixed $post      * @param mixed $alt_post_type      * @access public      * @return int|WP_Error      */     function create( $post_id, $alt_post_type, $meta_keys = null ) {         $this->get_version( $post_id );         if ( $this->has_version() ) {             return new WP_Error( 'alternate_already_exists', __( 'An alternate version already exists for this post.', BUV_TEXTDOMAIN ) );         }         $this->original = get_post( $post_id );         if ( ! isset( $this->original ) ) {             return new WP_Error( 'alternate_no_original', sprintf( __( 'The post ID: %s could not be found.', BUV_TEXTDOMAIN ), $post_id ) );         }         $new_version['post_type'] = $alt_post_type;         $new_version['post_parent'] = $this->original->ID;         $new_version['ID'] = null;         $new_version['post_status'] = 'draft';         $new_version['post_content'] = $this->original->post_content;         $new_version['post_name'] = $this->original->post_name;         $new_version['post_title'] = $this->original->post_title;         $new_version['post_excerpt'] = $this->original->post_excerpt;         $new_version['_subheading'] = $this->original->_subheading;         // Loop through Post Custom Meta and add to array          $custom_field_keys = get_post_custom_keys($new_version['post_parent']);         foreach ( $custom_field_keys as $key => $value ) {             $new_version[$value] = $this->original->$value;         }         //         $result = wp_insert_post($new_version);         if ( ! is_wp_error( $result ) ) {             $this->post = get_post( $result );             $this->copy_original_meta( $new_version );             update_post_meta( $this->original->ID, self::tracking_meta_key, $this->post->ID );         }         return $result;     }     /* Because of sanization and serialization, it may be better to use SQL, but for now we are using the API      **/     private function copy_original_meta( $new_version ) {            foreach ( $new_version as $key ) {             $values = get_post_meta( $this->original->ID, $key );             foreach ( $values as $v ) {                  update_post_meta( $this->post->ID, $key, $v );             }         }         update_post_meta( $this->post->ID, '_bu_version_copied_keys', $meta_keys);     }     /**      How can I get per say "Header Image" which is a ACF image field with a value of "field_64" on my page to populate the image field with the image ID of "426" when I duplicate the post? Or

         Header Image         Choose the image that will display in the header. If none is chosen, then a default image will be displayed. Make sure image chosen has dimensions that meet or exceed 1170 pixels across.

         <input class="acf-image-value" type="hidden" name="fields[field_64]" value="">

Remove

Edit

No image selected <input type="button" class="button add-image" value="Add Image">


Executing query_posts after wp_insert_post

am working on a custom plugin. I'm programmatically adding a new post in the plugin use `wp_insert_post`. Works fine, the post gets added and I get the `$post_id`. However, if I immediately run `query_posts` and try and reset the $wp_query to point to the new post_id I get nothing. I feel I am not using `query_posts` correctly ... because I would think it should return the new post.               <?php     wp_reset_query();          $args = array(         'post_title' => 'test post',         'post_author' => 1,         'post_status' => 'publish',     );          $post_id = wp_insert_post( $args );          if ( $post_id != 0) {         query_posts( array( 'post_id' => $post_id ) );     }


WordPress 3.1 and Disqus throws Warning: number_format() error in Posts List

After upgrading to WordPress 3.1, the comment count for each post in the Posts list now shows the PHP error `Warning: number_format() expects parameter 1 to be double, string given in /wp-includes/functions.php on line 155`. This problem is definitely related to the Disqus comments plugin, which I suspect is manipulating the comments count. I see how I could fix this error by editing the WP core file /wp-admin/includes/class-wp-list-table.php and neutering the "get_comments_number()" function, but I'd rather find a solution for whatever is being manipulated in disqus.php. Any thoughts?


How to add a filter to all widget output

Is there one last filter that is ran over the widgets before they are sent out to the browser? I would like to add a filter that adds `rel="nofollow"` to all links in all widgets. For instance, I can add a filter to the text widget:               add_filter('widget_text', 'xrvel_nfp_modify_nofollow');      But I don't want to hunt down every single hook for every widget. (Also, the RSS widget doesn't even HAVE a filter. Trac ticket submitted)


Delete Post From front Page ( With Wp-admin restriction )

am using this function to delete post from front               // Delete from Front-End Link          function wp_delete_post_link($link = 'Delete This', $before = '', $after = '', $title="Move this item to the Trash", $cssClass="delete-post") {         global $post;         if ( $post->post_type == 'page' ) {             if ( !current_user_can( 'edit_page' ) )                 return;         } else {             if ( !current_user_can( 'edit_post' ) )                 return;         }         $delLink = wp_nonce_url( site_url() . "/wp-admin/post.php?action=trash&post=" . $post->ID, 'trash-' . $post->post_type . '_' . $post->ID);         $link = ''.$link."";         return $before . $link . $after;     }      its work 100% but am using function to restrict no admin to access wp-admin, using this function :               function restrict_admin(){     //if not administrator, kill WordPress execution and provide a message         if ( ! current_user_can( 'create_users' ) ) {             wp_die( __('You are not allowed to access this part of the site') );         }     }     add_action( 'admin_init', 'restrict_admin', 1 );      **my problem** , how can i allow user ( not admin ) to delete his post own post ?


Check category_name or taxonomy slug for a Custom Post Type?

I am checking the current page I am on and then using that to set a variable to change the category name like so.                   <?php             if (is_page('apples')) {                 $categoryname = 'Apples';             }                  $args = array (                  'posts_per_page' => -1,                 'post_type' => 'products',                 'category_name' => $categoryname             );                  $fruit_query = new WP_Query( $args );                  if ( $fruit_query->have_posts() ):                 while ( $fruit_query->have_posts() ) :                     $fruit_query->the_post();                           if ( has_post_thumbnail() ) {                        the_post_thumbnail();                     }                 ?>                          <?php the_title(); ?>
                     Harvest Week: From <?php the_field('harvest_week_from'); ?> to <?php the_field('harvest_week_to'); ?>
                     Colour: <?php the_field('colour'); ?>
                     Market Season: <?php the_field('market_season'); ?>
                     Market Sector: <?php the_field('market_sector'); ?>
                     <a href="<?php the_permalink();?>">Link to product
                      <?php endwhile;             else:                 // Insert any content or load a template for no posts found.             endif;                  wp_reset_query();              ?>      The problem however is that this a Custom Post Type so I think I should be checking the taxonomy since the category is not working. I have already tried examples from this page http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters but to no avail. Is there something else I am mean to be doing? Thanks **EDIT: This is the setup of my Custom Post Type**                   add_action('init', 'register_products');         function register_products() {         register_post_type('products', array(             'label' => 'Products',             'description' => '',             'public' => true,             'show_ui' => true,             'show_in_menu' => true,             'capability_type' => 'post',             'map_meta_cap' => true,             'hierarchical' => false,             'rewrite' => array('slug' => 'products', 'with_front' => true),             'query_var' => true,             'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes','post-formats'),             'taxonomies' => array('category'),             'labels' => array (               'name' => 'Products',               'singular_name' => 'Product',               'menu_name' => 'Products',               'add_new' => 'Add Product',               'add_new_item' => 'Add New Product',               'edit' => 'Edit',               'edit_item' => 'Edit Product',               'new_item' => 'New Product',               'view' => 'View Product',               'view_item' => 'View Product',               'search_items' => 'Search Products',               'not_found' => 'No Products Found',               'not_found_in_trash' => 'No Products Found in Trash',               'parent' => 'Parent Product',             )         ));}      **Screenshot of the Dashboard:** ![enter image description here](http://i.stack.imgur.com/UeRsL.png)


template_redirect causing infinite loop when get_queried_object is called

I have a situation where I am calling get_queried_object() in the 'wp' action hook and it is causing an infinite 301 redirect. I can temporarily fix this by adding: > remove_filter( 'template_redirect', 'redirect_canonical' ); but I know this is a temporary fix because this disabled the auto redirect 404 errors. http://www.mydigitallife.info/how-to-disable-wordpress-canonical-url-or- permalink-auto-redirect/ http://docs.dev4press.com/tutorial/wordpress/canonical-redirect-problem-and- solutions/ The error seems to be server specific though because I've not seen it on dozens of other. And even stranger, caching prevents the issue from occurring when not logged in (using W3 Total Cache) 2012 theme activated and all other plugins are deactivated except the one calling get_queried_object. I also discovered that this was only an issue on the client's homepage.


Is it possible to make *.js and folders visible in theme-editor

I just created a file `test.js` in the folder of my own child-theme. Unfortunately it is not visible in the Theme editor. How can I make it visible? And is it possible to make folders visible?


Export plugin omits many images

I think I have never seen the WP Importer plugin work perfectly a single time. It always skips a few featured images. Is there a manual and hopefully more reliable procedure to export and import all posts/CPT with featured images?


Theme Activate Hook

I would like to write a function to email me the URL of the website when my theme is activated. What is the hook initiated when the theme is activated?


parallels plesk plugins installation fail error

Whenever I try to install Worldpress or any other plugin in Parallels Plesk 11.5 I get the Following error                   Error: Installation of WordPress at http://example.com/wordpress failed. ODBC         error #42S22: [MySQL][ODBC 5.1 Driver][mysqld-5.5.24-0ubuntu0.12.04.1]Unknown         column'T100253344.app_id' in 'where clause'       that didn't happen before I upgrade Plesk.


Enqueueing Scripts and Styles

I'm trying to enqueue my custom script and style with the block of codes, the scripts works but not the style. I don't know what I'm doing wrong.                   function my_scripts_method() {                  wp_deregister_script( 'jquery' );                         wp_deregister_script( 'style' );                      wp_register_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' );                         wp_register_style( 'style', '//siteripe.com/style.css' );            }                       add_action('wp_enqueue_scripts', 'my_scripts_method');         add_action('wp_enqueue_style', 'my_style_method');


How to remove "read more" link from custom post type excerpt

Is there a way I can add some kind of `pre_get_posts()` filter to strip out the "read more" link that appears at the end of `the_excerpt()` for only 1 certain custom post type that I specify? If so, can someone please help me out with the code? I've been working at it for a while but haven't gotten anywhere. Any help would be greatly appreciated. Thanks!


How to embed form data within the 'Add new post'

I want users to be able to use a car template in new posts. The template will include items such as a photograph of a car, make, model, number of doors, colour of car, etc. Users will not want to use the template in every one of their posts. How should I do this? My idea is to: **Create a new widget within the 'Add new post' page. This would contain a form in which the user can upload a photograph and enter data (in text input fields).** **Once the user has completed the form (within the widget), they could press a button (either in the widget or in the 'Add new post' toolbar) which will embed the form data into the new post.** Please can you tell me if this would be a good/best approach, or if I should do it another way.


Can't get blog entry to format properly using wp-load

I'm setting up a blog that I'm trying to integrate the posts of into old site pages. The               $id = $_GET['article_id'];     $post = get_post($id);     setup_postdata($post);     echo $post->post_content;      However, when I echo the blog post from `$post->post_content`, it seems that the html has been stripped out. The lines all run together. There are line breaks in the source, but there are no html `<BR>`s or `<p>`s. However, the post looks fine when I view it through the actual WordPress page. I have to use `<pre>` to get it to display properly, but then on the page, lines don't wrap and it defaults to that typewriter font. What am I doing wrong?


How to make multi -column, interesting home page in Weaver 2010?

(I am pretty new to wordpress - am a C++ developer, not an html/css coder, but I am trying.) I am having trouble figuring out how to make a home page that has blurbs about some of our products, etc and generally make something better than just a static page of text. I want to have some pictures, perhaps a three columns or two columns of little bits of intro text that users can click on to go to other pages. I am at a loss about how to do that. Do I need the widgets, or something? It is very unclear to me how to make it work. I'll try to post some samples of what I am looking to do - but it really isn't all that fancy. Some links to resources would be great - I am so new to this I don't know where to go for help or documentation. What I need is a simple "how to do this" tutorial. Thanks


Custom Post Type Query for Sidebar Doesn't Work on Front Page

Interesting issue here. I have this:               $args=array(     'meta_key'=>'_simple_fields_fieldGroupID_1_fieldID_8_numInSet_0',       'post_type' => 'stores',       'post_status' => 'publish',       'posts_per_page' => 10,       'caller_get_posts'=> 1     );     $my_query = null;     $my_query = new WP_Query($args);     if( $my_query->have_posts() ) {       while ($my_query->have_posts()) : $my_query->the_post(); ?>

     <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php $selected_value = get_post_meta(get_the_id(), "_simple_fields_fieldGroupID_1_fieldID_9_numInSet_0", true);       echo "$selected_value"; ?> at <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>

     <?php       endwhile;          }     wp_reset_query();  // Restore global post data stomped by the_post().      Which intends to display a list of a specific post type (stores) in the sidebar if a specific custom field is not empty. On single posts that works great - on the main page (home.php) it doesn't - the sidebar widget is empty. I'm stumped. Any ideas? John


Specifying # of Posts per page using inline post plugin (:

I am working on a website for my school. I downloaded the inline post plugin. This plug-in allows you to make posts on multiple pages throughout the site. However, I am having trouble displaying a certain number of posts per page. Please let me know what I can do. Thank you (:


Disable Create New tags for posts

> **Possible Duplicate:**   >  Can I turn off write-in tags/taxonomies? I am trying to disable creation of new tags for posts. If a tag is in exisiting list of tags, it will be added with post otherwise deleted. The code i am using doesn't seem to work. Here is the code               add_filter( 'pre_post_tags_input', 'no_tags_input_create' );                         add_action( 'publish_post', 'no_tags_input_create' );           add_action( 'publish_updated', 'no_tags_input_create' );          add_action( 'save_post', 'no_tags_input_create' );               function no_tags_input_create($post_ID) {     $taxonomy_ar = wp_get_post_tags( $post_ID );                 if (count($taxonomy_ar) > 0){         foreach ($taxonomy_ar as $taxonomy_term) {               $term_ids= $taxonomy_term->term_id;      $tags_name[]= $taxonomy_term->name;     }          }         $output = array();              foreach( $tags_name as $tag )             if( !term_exists( $tag, 'post_tag') ){                  wp_delete_term($term_ids,'post_tag');              wp_set_post_tags( $post_ID, '', false );                 }          }      Can anyone point out where i am wrong?


How to create a sharing marketplace with wordpress for bicycles?

I want to create a marketplace for bicycles with wordpress. Users can register/login and sell their bicycle to other users. They also can create a pre-defined page for their bicycle... Which wordpress plugins do i have to use or do I have to write my own plugin? How would you create such a site?


What are the critical theme files when building a custom theme?

What are the critical files a theme MUST have to be a WordPress theme and validate properly?


Get plugin_dir_url() from one level deep within plugin

I've written several plugins using the structure : /plugins/myplugin/myplugin.php /plugins/myplugin/class/class-myclass.php So as to take advantage of OO and overall structuring my code From within the class file there are times I need to get the URL of the base plugin... I have been using the following, but I'm sure there's a better way:               $this->plugin_location = substr(plugin_dir_url(__FILE__),0, strrpos(plugin_dir_url(__FILE__), "/",-2)) . "/";      Another idea I toyed with was having an additional singleton class that stores all of the settings for the plugin and adding an abstraction layer via the class files. Any help is greatly appreciated.


Exclude comments on page X from site's comments RSS feed

I would like to exclude comments on a certain page from the site's comments RSS feed (site.com/comments/feed/). I've done some searching but failed to find any info on how this could be achieved. Any help would be appreaciated.


Rewrite rules custom post type

I created a new custom post type "video" and a new taxonomy "singers". There are 3 singers: Michael Jackson, Madonna, Eminem. I'd like change the permalink and so I'd like this URL: www.example.com/madonna/video-like-a-prayer (where "madonna" is the singer, "video" is the post type and "like-a-prayer" is the post name). How can I resolve please? Thanks.


Translating form labels shortcode output

I'm using MyMail plugin to manage my newsletter.   I'm also using WPML to manage translations, there is no compatibility between the two plugins.   The subscription form, is placed in the footer area, through a MyMail shortcode and the wordpress text widget. I want to translate the field labels, to the active language: So I was thinking on writing a filter for the "widget_text", search the "label name" and preg_replace() its output... But I don't find the way to achieve it. Looking in the php class that manage the form, I could see that the function that outputs the form, stores the final code as:               return apply_filters('mymail_form', $html, $formid, $form);      So I guess that I need "search and replace" in the $html variable. Any ideas? Many thanks!


I turned on debug mode and see the following in my header: **Notice: Use of undefined constant - assumed ' '** I'm using the following function in header.php:               <?php if ( is_user_logged_in() ) {           global $current_user;         get_currentuserinfo();         echo $current_user->display_name; //affected line     } else {     ...     }?>


I need to dynamic insert post containing javascript from my other website?

I am trying to dynamicly add some content post (also containing some js), but the javascript part is filter out. I thought by using wp_set_current_user the js would be included. This is my main function which generate the post                  function mydomain_which_page2($atts) {         extract( shortcode_atts( array(             'temp_title' => 'something'         ), $atts ) );             //post exists?         if( wp_exist_post_by_title( $temp_title ) ) {             $redirect_title = sanitize_title( $temp_title);             header('Location:' . $redirect_title);             exit();         } else {              // post does not exist             wp_set_current_user(NULL, 'Test user');             //GET THE MAPS             $output = getIncludeContent('myotherdomain.com/generate.php');              //SAVE AS WP POSTS             mydomain_add_post($temp_title,$output);             //REDIRECT             $redirect_title = sanitize_title( $temp_title);             header('Location:' . $redirect_title);             exit();         }        }      directly going to myotherdomain.com/generate.php will output the js in source code also $output will show the source code with js. and add_post function               function add_post($title, $content){         // Create post object wp_strip_all_tags         //$content = strip_tags($content);              $my_post = array(           'post_title'    => $title,           'post_content'  => $content,           'post_name'   => sanitize_title($title),           'post_status'   => 'publish',           'post_author'   => 1,           'post_category' => array(1)         );              // Insert the post into the database         wp_insert_post( $my_post );      }      Any tips, suggestions? regards


Create a custom capability to allow an 'Editor' to edit only 'Subscriber' users

I want to create a new "Moderator" role (in between Administrator and Editor), that can edit only "Subscriber" type user accounts. I can create the role and add existing wp capabilities, but I don't know how to create a new capability, 'edit_subscriber', that can do that. Any insight appreciated.


How to 'If Author' Comments Check

I would like to add extra markup to a comment made by the site admin/post author. Is there a check for this and how would I add it to my code below? Basically, if the comment is from the post author I would like to add HTML next to their name (Author or Admin). Thanks
                              <?php printf(__('%s said on'), get_comment_author_link()) ?>                     <a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>">                     <?php                         printf( __('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?><?php edit_comment_link(__('(Edit)'),'  ','' );                     ?>


How to echo JS right after enqueued script to put it into noConflict mode?

I want to include and use third party JavaScript file (Bootstrap Tooltip) in my plugin. Since Bootstrap is highly popular framework and `tooltip()` is rather generic name I want to make use of included `noConflict()` functionality to isolate tooltip's instance in my own variable. If I understand timing at all right, this needs to be done right after script file loaded - so that nothing else has a chance to mess up instance (it had just set up) or get messed up by it either. However there seems to be no convention in queue functionality to echo JS at such point. `$wp_scripts->print_extra_script()` is called _before_ the script. Is this at all possible to accomplish with current queue implementation?


count number of posts (public , private , protected) by category name

I wanted to count number of posts (public, private, protected) according to a category name suppose `blog` . To get all the posts no matter what category i used `$total_pages = wp_count_posts()->publish;` But i cant figure out how to count number of posts for a category name `blog`


How to get Gallery ID in nextgen template

I want to retrieve gallery description in file ...\wp-content\plugins\nextgen- gallery\products\photocrati_nextgen\modules\nextgen_basic_gallery\templates\thumbnails but it is must to know gallery id.How can i retrieve variable gallery id?


Why is archive.php used for my page

I have a page "Portfolio", it contains a loop that outputs the list of portfolio (Custom Post Type, _is this the problem?_ ) items using `page- portfolio.php`. Problem is somehow WordPress used the `archive.php` to render my portfolio page, why is that?


Remove media button from the custom post type support editor

Below code removes the medial button from other editors as well.. how to remove the editor from the post type support editor                  add_action('admin_head', 'remove_mediabuttons');               function remove_mediabuttons()     {         global $post;              if($post->post_type == 'custom_post_type' && current_user_can('edit_post') )         {             remove_action( 'media_buttons', 'media_buttons' );         }     }


Wordpress stylesheet isn't being added

I have recently started to learn WordPress and after learning how to use it at basic level I immediately started to learn how to develop templates since this is what interested me from the start when I started to learn it. I am reading WordPress 3 Complete and at Chapter 6 the book guides you to develop your first basic theme. The only problem is that it seems that my theme is not taking the style sheet. I have tried to use:               <link rel="stylesheet" type="text/css" href="style.css"/>       and               <style type="text/css">@import url("style.css");</style>      None of them seem to get the style on the page. What should I do?


WordPress Custom Application form

* I want to implement an application form with WordPress, Preferably using a plugin. What I need here is not a contact us form, But I need a complete registration form or customer registration form or student registration form. This means fields could be customized according to particular need. or   * I want a fixed number of columns table plugin which has a form and store data to that table. Because i want to show that table in my reports under wordpress admin panel. I am open to any suggestion. Even if i am going totally wrong. Please guide me. Thanks,


Loop from another WP site onto mine

What i'm trying to achieve is bringing a loop from one WP site into another WP Site. I used this method to get the loop into an external php file (which all works fine, the results show)               <?php     define('WP_USE_THEMES', false);     require('path_on_server/wp-blog-header.php');     query_posts('showposts=5');     ?>          <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
             <a href="<?php the_permalink() ?>"><?php the_title(); ?>" />
     <?php endwhile; endif;  ?>      I then try and include the file in my sidebar using a simple php include call but the results don't show.... I imagine this is because of some sort of confliction between my WP & the other sites WP. Any help on achieving this? Thanks


Can't access WordPress functions in file called via Ajax?

I am trying to reload the fresh posts using jQuery. As far as I know, I can't reload the contents of a div inside the page so I reload a file into that div. The problem is that my loaded file gives me a **Fatal error: Call to undefined function wp_query()** How can I implement functions to a newly created file inside the theme directory to work properly? _**This is my jQuery_**               <script language="JavaScript">     $(function() {         var SANAjax = function(){              }         setInterval(SANAjax, 15000 );     });     </script>      _**And this is what i have in`reloadhomeposts.php` (I have deleted the content though)_**               <?php $recent = new WP_Query("cat=3,4,5&showposts=10"); while($recent->have_posts()) : $recent->the_post();?>     .     .     .     <?php endwhile; ?>


How to get posts from network blog

So I have function that gets posts with URL(id) (ajax stuff). It works but now I would like also fetch posts from other blogs in my network. I'm baffled how can I achieve this? Do I have to know the blog ID too somehow? So now it pass to my function the URL and with get_blog_id_from_url I get ID of the post and fetch all data and pass it via JSON back to fronded. But if I pass url of some of network blog, it doesn't know how fetch post data from that post. EDIT: here is the function:               function my_query(){       $url = $_POST['url'];            $rsp_post = array();            $post_id = url_to_postid( $url );            global $post;       $post = get_post( $post_id );            $rsp_post[] = array(         'post_title' => $post->post_title,         'post_date' => $post->post_date       );       print json_encode( $rsp_post );            exit;     }


Conditional statement to show pagination

I'm using pagination to navigate between posts from the same category. Here is my code:

             <?php next_post_link('%link', 'Article Précédent', TRUE); ?>

             <?php previous_post_link('%link', 'Article Suivant', TRUE);?>

      It works perfectly. But what I am trying to do is to add an `if` statement, to show the div with ID `article_single_prev_next` only if there are next of previous pages inside the category. I tried using this code without success:               <?php if (show_posts_nav('%link')) : ?>

                 <?php next_post_link('%link', 'Article Précédent', TRUE); ?>

                 <?php previous_post_link('%link', 'Article Suivant', TRUE);?>

      Can anybody help me with this?


What is the expected limit for acceptable performance of WordPress without any adjustments?

In your experience, when is the time one needs to start thinking about scaling up? **What is the expected performance of a common WordPress installation on a standard Apache web server, without any [performance tweaks or plugins]** (Steps to Optimize WordPress in Regard to Server Load?)? In terms of page loads (let's assume no caching): **Is it in range of 100's/1000's/+ of page loads per second?** In terms of traffic: **At which number of users per day can one expect to start hitting performance bottlenecks (ignoring traffic, assuming great connection)?**


Profiling a WordPress Website for Deployment on Shared Hosting?

I am having a problem with CPU usage on my website, and am looking for a way to detect (and fix) what is causing it. A topic not covered in this question. Following on Hakre answer here, I now realize that what I need to do is profile my PHP calling. Is it reasonable to put the website on my own computer, run the profiler, and use that information to improve my website? Any other suggestions on how to do this in the best way?


Inserted double quote when prepending to the_content

I am trying to write a plug-in to display the RunKeeper Healthy button on single posts, but my output has an extra space and double-quote when I look at the page source. What I'm trying to do with the button is open a new window via inline JavaScript. I've tried switching between single and double quotes and have also ensured that I was escaping nested quotes properly. Trying to append the `get_permalink()` breaks the generated link for the RunKeeper sharing URL. The image tag for the link itself is fine, but I see an incomplete link when I hover over it. The link output is:                     But what I would expect is:                     This is what my plug-in code is so far:               add_filter('the_content', 'add_runkeeper_btn' );          function add_runkeeper_btn($content) {         $output = "";              if (is_single()) {             $output .= "";             $output .= "";             $output .= "";         }              return $output . $content;     }      For reference this is what is in the page source of the RunKeeper blog post. I am trying to modify it so that the `healthyUrl` query parameter references the permalink for the post.


wp_nav_menu and fallback

I am using this code to call any custom menu and display:               <?php      wp_nav_menu( array(          'container' => 'none',          'container_class' => 'menu-header',          'theme_location' => 'primary',          'menu' => get_post_meta( $post->ID, 'MenuName', true) )      ); ?>      At the moment if there is no custom menu defined it falls back to the primary menu. I am trying to edit this code, so if there is no custom menu then display nothing. Having no luck, doesn't help that I'm new to php and wordpress. I have searched online and tried a few other solutions. Knowing my luck it's probably something really simple. If anyone could help me out, I'd appreciate it a lot! Thanks


Get_the_term_list inexplicably adds values in foreach

I'm trying to get three values from all my custom posts, to populate a Google Map with the places where I've been. All is going fairly well, except for an issue I'm having with `get_the_term_list`. For some reason it adds the number **"1"** in front of each correctly returned value. As an example, my below code will output the following for "name":               Key: name, Value: 1     Grossglockner
      The problem code:               <?php      //get custom posts ids as an array     $loop = get_posts(array(         'post_type'   => 'trips',         'post_status' => 'publish',         'posts_per_page' => -1,         'fields' => 'ids'         )     );     //loop through each post     foreach($loop as $p){         //get the meta and taxonomy data          $name = get_the_term_list($p, "mountains",true);          $wtr_longitud = get_post_meta($p,"wtr_longitude",true);          $wtr_latitud = get_post_meta($p,"wtr_latitude",true);              //Add to Array         $map_array[] = array ("name" => $name, "latitude" => $wtr_latitud, "longitude" => $wtr_longitud);     }             //Print array             foreach($map_array as $y) {                         foreach( $y as $key => $value){                         echo "Key: $key, Value: $value
";                         }                 }     ?>


$wpdb->insert() and Values for Datetime Columns?

I have a custom table with a DATETIME column. I have a function to add records; I would like to add an `$expires` argument to this function which can hold a unix timestamp noting when the record should expire. I would like to use `$wpdb->insert()` to populate this column. So far I've been unable to find a WordPress convenience function to massage the timestamp into 'YYYY-MM-DD HH:MM:SS' format. Is there such a builtin, or should I just use `$wpdb->prepare()`, or possibly a third option?


Is there a WordPress plugin to design WebGL?

I have been working as a WordPress designer/developer for some time and now I've decided to write a plugin myself. I also have some OpenGL experience (not web based). I was thinking is it worth investing my time learning WebGL and then using it to create a WebGL designer plugin for WordPress? **To elaborate:** My plugin would allow designers and non-coders to design WebGL based animations and games using basic building blocks and preset animations. It wouldn't be as good as writing the code yourself but it'd be a good start. It would be as simple as "drag and drop" and all the code will automatically be generated by this plugin. Is it a good idea? Is there really a need for it? Is WordPress a suitable platform for this? And most importantly are there any existing plugins for designing WebGL out there?


When click Update button all changes are lost

when I update the slider on my site's home page and click `preview changes`, I can see the changes. But when I click `Update` everything is lost. What causes this? How to solve this? Any suggestions will be appreciated. Thanks in advance.


How to delete custom taxonomy terms in plugin's uninstall.php?

I am writing my plugin's uninstall.php file and would like it to delete any terms that were created in the plugin's custom taxonomy. In the plugin's uninstall.php file I am using this:               // Delete all custom terms for this taxonomy     $terms = get_terms('custom_taxonomy');     foreach ($terms as $term) {         wp_delete_term( $term->ID, 'custom_taxonomy' );     }      The problem seems to be that the custom taxonomy isn't registered at this point, so get_terms returns an error for "invalid taxonomy", thus I can't delete the custom terms in this manner, which seems the most straightforward way to do so. If the custom taxonomy isn't registered when uninstall.php is called, how can I have it so that my plugin is able to clean up it's custom data? Any help is greatly appreciated. Thanks.


comment meta_query for keys that aren't yet set

I need query help! I am trying to set up a `meta_query` (for `get_comments`) for keys that aren't yet set. I have some code that allows moderators to add a custom meta key to individual comments. Click the checkbox and the meta key is set to `shadow`, unclick it the meta key is set to an empty string. This means that there are three possible states for a comment to have. It can either have the 'shadow' meta key, it can have an empty string and the meta key, or the meta key could not be set. What I would like to do is query all comments that either don't have this meta key set or have the meta key that is NOT shadow. It is fairly easy to select all comments that have the meta key not equal `shadow` but I haven't found a away to also select comments that don't have the meta key set. This is the code I am using, but it doesn't work. It selects every comment that has the meta key set, regardless of what it is set to.                           $comments = get_comments( array(                      'meta_query' => array(                         'relation' => 'OR',                         array( // Select comments that don't have the 'shadow' p3_comment_status meta                             'key' => 'p3_comment_status',                             'value' => 'shadow',                             'compare' => '!='                         ),                         array( // Select comments that don't have the p3_comment_status set                             'key' => 'p3_comment_status',                             'compare' => 'NOT EXISTS'                         )                     )                     )                 );      Any help would be appricieated. Thanks **UPDATE:** For the record this is the code that ultimately worked for me:                           $comments = get_comments( array(                      'order' => 'ASC',                     'post_id' => get_the_ID(),                     'meta_query' => array(                         'relation' => 'OR',                         array( // Select comments that don't have the 'shadow' p3_comment_status meta                             'key' => 'p3_comment_status',                             'value' => 'shadow',                             'compare' => '!='                         ),                         array( // Select comments that don't have the p3_comment_status set                             'key' => 'p3_comment_status',                             'compare' => 'NOT EXISTS',                             'value' => ''                         )                     )                 ) );      The key was to set `'post_id' => get_the_ID()`


Allowing shortcodes inside attributes

I want to do a Wikipedia-like infobox for some articles on a WP site. I guess the most logical thing to do it is to use a custom shortcode—one that returns a table-like markup with a fixed order of fields, each with more markup at custom along some conditional stuff for showing or not fields if they are not set, somewhat emulating something like this:                <!--MediaWiki markup-->      {{infobox-cd      |name=Abbey Road"      |cover=[[File:laserdisc.jpg]]      |artist=[[The Bombay Beach Boys]]      |country={{flag id=mx}} Argentina<br />{{flag id=dk}} Vanuatu (post-production)      |rating={{stars no=3}}      |prev=[[The Wall]]      |next=[[Born in the U.S.A.]]      }}      Yet I have been blocked from using them in a more literal approach for years due to shortcodes breaking while having brackets inside attributes. It theoretically should work, but doesn't because the shortcode regex stops with the first occurrence of a closing bracket (]) in a shortcode, so in this:               [foo bar="[baz /]"]content[/foo]      it "outputs":               [foo bar="[baz /]      I'm not sure how else I can get this markup working or something else with the same goal.


How to delete user on logout and when session expires?

I am looking for a way to delete a user when they logout and when session expires...whatever one happens first? Reason being is that all login authentication happens through an api to another company and checks if the user is a registered user with that company. Then the login will give them WP login authentication. All of this works, but I now want to delete users when they log out or when their session expires. Thanks.


How to include specific post terms in Facebook share?

So I already added the necessary scripts to add a Facebook share button in my posts

               <div class="fb-share-button" data-href="<?php the_permalink(); ?>" data-type="button_count">
      But so far, it is only showing the Title and Content of the post. How do I include specific post terms in the share function?


How to exclude scripts from being moved to the footer using their handle?

I'm working on a small plugin that moves all scripts to the footer using the following code:               function move_scripts_to_footer() {              global $td_options;              if ( !is_admin() and isset( $td_options['scripts_to_footer'] ) ) {             remove_action( 'wp_head', 'wp_print_scripts' );             remove_action( 'wp_head', 'wp_print_head_scripts', 9 );             remove_action( 'wp_head', 'wp_enqueue_scripts', 1 );         }     }          add_action( 'wp_enqueue_scripts', 'move_scripts_to_footer' );      In the plugin options page I added the following option that is supposed to exclude certain scripts using their handles (e.g. "jquery") but it seems to be a real challenge to make it work with the above function:               <textarea name="js_exceptions" id="js_exceptions" value="<?php echo $js_exceptions; ?>" /><?php echo $js_exceptions; ?></textarea>      Since I noticed that some of scripts need to be in the head, I need to know how can I exclude certains scripts from being moved to the footer using their handles. I tried all sorts of variations for 2 days but nothing works so any help will be greatly appreciated. Thank you!


One of the messages in .po file doesn't show up

I've changed a file `wp-content/languages/pl_PL.po`               #: bfa_header.php     msgid "notice"     msgstr "napis"          msgid "Online Information Website"     msgstr "Internetowy Portal Informacyjny"          msgid "something"     msgstr "coś"      I've added the second pair. It works for another language, but doesn't work for this one. All other messages are working. What might be the problem?


quey posts from different categories with taxonomy

I wonder if someone could help me. I just upgrade my wordpress and start to use taxonomy. what I want to do is to query posts from different categories. I used to do it like this `query_posts('cat=5');` but with taxonomy added to my categories, doesnt work anymore for example if I go to a category page the link goes like this `www.website.com/ad-category/cars` I guess my taxonomy category name is "ad-category" and the category name is cars but how could I query posts from categories ids, example 5,6,7,8 etc.. Thak you for your time!!


What is a good robots.txt?

What is the "best" setup for `robots.txt`?   I'm using the following permalink structure `/%category%/%postname%/`. My `robots.txt` currently looks like this (copied from somewhere a long time ago):               User-agent: *     Disallow: /cgi-bin     Disallow: /wp-admin     Disallow: /wp-includes     Disallow: /wp-content/plugins     Disallow: /wp-content/cache     Disallow: /wp-content/themes     Disallow: /trackback     Disallow: /comments     Disallow: /category/*/*     Disallow: */trackback     Disallow: */comments        1. I want my comments to be indext. So I can remove this   2. Do I want to disallow indexing categories because of my permalinkstructure?   3. An article can have several tags and be in multiple categories. This may cause duplicates in google. How should I work around this? Would you change anything else here?


Password protected photo galleries

What is the best way to password protect individual photo galleries so individual users can log in and view their user specific photo gallery?


Show 'Read more' in rss feed

How can I show 'Read more' links in rss feed instead of showing excerpt? The settings in reading only allow to choose between full content and excerpt.


Initialization Script for "Standard" Aspects of a WordPress Website?

I am about to have to write **a script to take a fresh install of WordPress 3.0.1 and add-in all the initial features for a website**. This is for a company that installs lots of similar websites and they need a standard starting point in configuration and data.   * **I'm wondering if anyone else has already done this and if so if they can share their code?** **I envision we will tweak this script each time** they create a new site so _hard-coding is fine_ although eventually (after enough experience) I'd like to convert into a plugin. **Here's the basic list of tasks** I think we'll need _(these assume I've started with WordPress 3.0.1 already installed and my custom plugins and custom theme copied into the appropriate directories)_ :               // Create users for the current site     // Delete Hello Dolly Plugin     // Download, Install and Activate repository plugins     // Activate Custom Plugins (assume the plugins are already there)     // Activate Custom Theme     // Delete Hello Post     // Delete Comment on Hello Post     // Create Pages with Starter Content     // Create Initial Custom Post Types with Starter Content     // Create Multiple Menus      // Create Menu Items for those Menus linking to Pages and wp-login.php     // Create Initial Taxonomy Terms     // Set Desired Permalinks Setting     // Set Static Front Page Setting      That's about it (though I may identify more as I get into it.) Again, I'm **looking for code that I can just copy and modify** so I don't have don't have to figure out all these details myself _(which is not hard, just tedious and time consuming)_. Oh one more thing, **I have to start on this _now_** so the sooner the better! :-)


Widget constructor: about $id_base and $options

in the book professional wordpress, they use something like               $options = array(         'classname' => 'pp_widget',         'description' => '...'     );     $this->WP_Widget('pp_widget', ..., $options);      but in most tutorials               $this->WP_Widget(false, ...      is used. i wonder is there a reason to specify the `$id_base` param? i see that if i dont, an `id` will be generated. also, is there any need to specify the `classname` option? on a side note, i asked a related question on stack overflow: PHP: `parent::somefunction` or `$this->somefunction` if someone got an answer let me know :)


update_post_meta not adding anything.(Nor add_post_meta)

So I have made some kind of importer(From another non WP db to my WP db) which handles everything in a click of a button. Now it does correctly create a post type although one of the custom fields made with ACF in which I have to place the ID from the other DB is not filling in correctly and I did this according to `update_post_meta`. Now I have no idea what the issue is because when I look into my Wordpress DB it shows that it adds it correctly into the database but it does not add(Better said Show) WITH the custom post in the WP-Admin. This is the code i've used:               <form action="" method="post">         <input type="submit" value="Test" id="submit" name="submit">         <?php              if(isset($_POST['submit'])){         foreach ($result as $c) {             $postargs = array(                 'post_title'   => $c->member_name,                 'post_status'  => 'draft',                 'post_type'    => 'bedrijf'             );                  $thisid = wp_insert_post ( $postargs, true);                  if ( is_wp_error($thisid) ) {                 return get_error_codes();             } else {                   update_post_meta( $thisid, $meta_key, $c->memberID);             }           }         }              ?>           </form>      A screenshot from my DB showing that it does add(Yes the meta key is correct as I only have one custom field). The meta value is also correct as I put it on LIMIT 1 in the query I have so it shows the first value of the DB only. ![DB Image](http://i.stack.imgur.com/rHlhf.png) EDIT: To be exact it adds it in the `wp_postmeta` table.


Translate arguments of a user added custom code

I needed to hardcode some extra code to a existing portfolio-template. Now there are two arguments which values need to be translated:

News

                precisely `href` value `/news/` and `News` between `<h4>` tags. I'm using WPML to translate the rest of the sites content but I cannot get these values to appear in the **string translation** admin area. How do I achieve this?


How to create a custom search form and handler?

I'm trying to build a search that, depending on what user chosen in admin, will either query one of several external api search methods with user input, save all the results in database and then display them or it will search the custom tables in database, it should also be fully encapsulated in a plugin. I already have the business logic that does this, I'm having trouble hooking it up to WP. What would be the best way to accomplish this? edit: sorry, it was probably quite vague question, what I have is an app I described above built on php framework, what I want to do is move it to WP, the problem is while the logic itself will require little modification, I have no idea how to hook it up to wordpress via plugin, essentially how do I create a form with plugin and how do I take input from that form and direct it to the logic that will handle that request?


Enqueue script in specific page

I am building a wordpress theme with a theme dashboard with options, but as I read somewhere, the enqueue script code I am using just enqueues it in the backend but it loads in every page in the backend. So I am having some js conflicts... I have this code:               add_menu_page($themename, $themename, 'administrator', basename(__FILE__), 'ikos_admin');     add_submenu_page(basename(__FILE__), $themename . ' Options', 'Theme Options', 'administrator',  basename(__FILE__),'ikos_admin'); // Default     }               function ikos_add_init() {              $file_dir=get_bloginfo('template_directory');         wp_enqueue_style("ikosCss", $file_dir."/functions/theme-options.css", false, "1.0", "all");         wp_enqueue_script("ikosScript", $file_dir."/functions/theme-options.js");         wp_enqueue_script("ikospickerScript", $file_dir."/functions/color-picker.js", array( 'farbtastic', 'jquery' ) );         wp_enqueue_style( 'farbtastic' );         wp_enqueue_style( 'farbtastic' );         wp_register_script('my-upload', $file_dir."/functions/upload.js");         wp_enqueue_script('my-upload');                  if(function_exists( 'wp_enqueue_media' )){             wp_enqueue_media();     }else{             wp_enqueue_style('thickbox');             wp_enqueue_script('media-upload');             wp_enqueue_script('thickbox');           }          }      So, how do I enqueue those scripts in that specific admin page only??? Thanks :D **EDIT** YEAH NOW IT IS WORKING! New code using the hook, then I added the var_dump( $hook_suffix ); exactly before the abort/return statement as @kaiser told me in the comments and it printed this: **string(0) "" string(27) "toplevel_page_theme-options" **. So I just added the "toplevel_page_theme-options" in the ikos_add_init($hook_suffix) and it works!               $hook_suffix = add_menu_page($themename, $themename, 'administrator', basename(__FILE__), 'ikos_admin');     add_submenu_page(basename(__FILE__), $themename . ' Options', 'Theme Options', 'administrator',  basename(__FILE__),'ikos_admin'); // Default          }               add_action( 'admin_enqueue_scripts', 'ikos_add_init' );          function ikos_add_init($hook_suffix) {         if ( 'toplevel_page_theme-options' !== $hook_suffix )         return;         $file_dir=get_template_directory_uri();         wp_enqueue_style("ikosCss", $file_dir."/functions/theme-options.css", false, "1.0", "all");         wp_enqueue_script("ikosScript", $file_dir."/functions/theme-options.js");         wp_enqueue_script("ikospickerScript", $file_dir."/functions/color-picker.js", array( 'farbtastic', 'jquery' ) );         wp_enqueue_style( 'farbtastic' );         wp_enqueue_style( 'farbtastic' );         wp_register_script('my-upload', $file_dir."/functions/upload.js");         wp_enqueue_script('my-upload');                  if(function_exists( 'wp_enqueue_media' )){                 wp_enqueue_media();     }else{             wp_enqueue_style('thickbox');             wp_enqueue_script('media-upload');             wp_enqueue_script('thickbox');           }          }


Difference between stylesheet_directory and template_directory

What is the differene between stylesheet_directory and template_directory? Is that representing Child theme and Parent theme?


Do I need to flush rewrite rules when creating new user if using custom author rewrite rules?

I am using custom urls for my author pages like this: `http://site.com/author_name` After I create a new user, that author page appears as not found; however, if I update my permalink structure from admin panel, the author page is found. So, is it necessary to flush rewrite rules after a new user is created? Is there any other way? From codex, I read that flushing rewrite rules is a very expensive task. So, I would like to avoid this. Is it possible? EDIT:               add_filter('author_rewrite_rules', 'no_author_base_rewrite_rules');     function no_author_base_rewrite_rules($author_rewrite) {          global $wpdb;         $author_rewrite = array();         $authors = $wpdb->get_results("SELECT user_nicename AS nicename from $wpdb->users");             foreach($authors as $author) {             $author_rewrite["({$author->nicename})/page/?([0-9]+)/?$"] = 'index.php?author_name=$matches[1]&paged=$matches[2]';             $author_rewrite["({$author->nicename})/?$"] = 'index.php?author_name=$matches[1]';         }            return $author_rewrite;     }          add_filter('author_link', 'no_author_base', 1000, 2);     function no_author_base($link, $author_id) {         $link_base = trailingslashit(get_option('home'));         $link = preg_replace("|^{$link_base}author/|", '', $link);         return $link_base . $link;     }


Converting HTML5 to XHTML

What do I need to ponder if I want to convert Twenty Eleven theme to XHTML? Is it just the matter of replacing the HTML5 for divs?


how to add class to the ul returned by wp_list_bookmarks

wp_list_bookmarks returns HTML that has a `ul` with classes `xoxo blogroll`. I'd like to add another class to that ul, but can't seem to find an elegant way to do so. wp_list_bookmarks does accept an argument "class", but that is applied to the li, not the ul. Is there some argument I'm missing? Or is there a hook I can hook onto and add a class?


Cannot access WordPress install on subdirectory of drupal site

I want to convert my site from Drupal to WordPress. I installed WordPress in a subdirectory so I can tweak it until I'm ready to delete drupal and move it to the root folder. After installing I cannot access the WP index in the subdirectory. I get this in firefox: "The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete.               *   This problem can sometimes be caused by disabling or refusing to accept           cookies."      I have cleared my browser and still get the same error. It must have some conflict with drupal. The drupal part of the site is still working ok. When I try to load my WP admin login url in the subdirectory it loads ok, but as soon as I submit my username and password, it redirects me to the login again. Any clues? Thanks UPDATE: I contacted my host and the problem was WP was not creating an .htaccess file when installing to a subdirectory. I tried installing WP a few times and it would never create an .htaccess file within the subdirectory. I'm using hostgator. I don't know if it was because there already was an .htaccess in root (from drupal) or something to do with my host.


How to add URL-Parameter for Javascript Widgets?

I need to add pamarameters to URLs that are read by javascript widgest/gadgets run on the site. Whenever I just add them e.g. the original URL is `http://example.com/blog/page/` and the parameter is called _foo_ with a value called _bar_. The new URL becomes: `http://example.com/blog/page/?foo=bar` The original URL is working fine, **but the new URL is giving a 404**. I assume that I need to register any additional parameter so that this works first. Is this true? How can I make new URL parameters not triggering 404s?


Contact Form 7 - Show image on successful send?

I am running Contact 7 form, and looks good for my needs. I have added it to Wordpress, for people to suggest ideas for our product. When users send an idea, they are given a message to say thanks.   This message is configurable via the settings for the form in wp-admin ![enter image description here](http://i.stack.imgur.com/UUu53.png) Does anyone know how I could get Mr Burns to appear once they have successfully sent an idea? i.e. Make a picture visible, and ideally place the picture to the side of the contact form.


Change URL for Blog?

Using WP 3.1.1 as a CMS, using the Boldy theme.   Home page is at http://www.dekho.com.au Advantage of using this theme, is that it comes setup with a homepage that has a gallery slider and some homeboxes at the bottom. To get to the blog, I had to dump all my posts into a category called blog.   \- The themes docco advises to do this]3.   I can then link to this blog category from the top menu. This then passes me to this URL: http://www.dekho.com.au/?category_name=blog **I want to know how to retain the home page provided by Boldy, but have the blog on a separate page with the following URL:**   _dekho.com.au/blog_


Get terms by taxonomy AND post_type

I have 2 custom post types 'bookmarks' and 'snippets' and a shared taxonomy 'tag'. I can generate a list of all terms in the taxonomy with get_terms(), but I can't figure out how to limit the list to the post type. What I'm basically looking for is something like this:               get_terms(array('taxonomy' => 'tag', 'post_type' => 'snippet'));      Is there a way to achieve this? Ideas are greatly appreciated!! Oh, I'm on WP 3.1.1


index.php template is used instead of blog page

I am trying to set WordPress so that home page is static, and the blog page is a separate page. So, I created two page templates in my theme., lets call them **home_template** and **blog_template**. Then, I created two WordPress pages (from Pages -> Add New). The first page is called **Home,** and is using **home_template** ; and the second is called **Blog** and is using **blog_template**. Then I went to the Settings -> Reading setting, and chose **Front Page Displays A Static Page**. And in the two drop downs that follow, I chose **Home** for **Front Page** , and selected **Blog** for **Posts Page**. Then I went to Appearance -> Menu, and added the Blog page as a menu item. Now, when I go to view my site, the home page is nice and dandy. **However, when I click on the menu item for the blog page, I see that the blog page is using index.php to display its content, it is not using the page blog_template to display the content.** How can I make sure that the blog_template page is used? Please help and thanks.


Mail isn't sent after local site registration

I installed a new WP site on local machine with wamp server. When a new user registers it gets the "registration successful" message but a mail with the password is never sent. Also checked the junk folder.   What can be the cause?


Will my Wordpress site become vulnerable to Cross-Site Scripting (XSS) if I allow img tags in the comments area?

I'm planning to follow this tutorial in order to allow my subscribers to add images to comments (actually a custom post type called "Replies"). Wordpress filters `<img>` tags by default (except for the admin). Will my Wordpress site be vulnerable to Cross-Site Scripting (XSS) if I allow img HTML tags in my comment section?


Using gettext to translate wp-login.php can't translate `Back to` into other language

I created a plugin to translate text of wp-login.php page into Arabic, every thing translated well except `Back to` which appear at the bottom of login form, I can't catch it to translate into Arabic My site name called Foodonia, and I want to translate `← Back to Foodonia` to `العودة إلى فودنيا` , I tried each one of below:               ← Back to Foodonia     Back to     Back to Foodonia     ← Back to Foodonia     ← Back to      here is my code               function my_custom_login_label( $translated_text, $text, $domain ) {         if (in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) )) {              if ($translated_text === 'Username') $translated_text = 'اسم المستخدم';             if ($translated_text === 'Password') $translated_text = 'كلمة المرور';             if ($translated_text === '← Back to Foodonia') $translated_text = '← العودة إلى فودنيا';              return $translated_text;       }     }     add_filter( 'gettext', 'my_custom_login_label', 20, 3 );      My site URL: http://foodonia.com (changing language between English and Arabic using site nav menu will effect the login language)


Gallery order specified by shortcodes is ignored in gallery function

I have the following gallery order in a shortcode:               [gallery ids="1996,2431,372,447,645,641,647,642,649,643,650,648,653,697,652,390"]      And I have this function, which creates a nicer looking gallery:               add_filter('post_gallery', 'pab_gallery');           function pab_gallery($attr) {              global $post;              extract(shortcode_atts(array(             //'order'      => 'ASC',             'orderby'    => 'menu_order DESC, ID ASC',             'id'         => $post->ID,             'columns'    => 3,             'size'       => 'thumbnail',             'include'    => '',             'exclude'    => ''         ), $attr));              $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => $orderby) );              #print_r($attachments);                   $output = '
';         $output .= '
';         foreach ( $attachments as $id => $attachment ) {             $link = wp_get_attachment_link($id, $size, false, true);             $output .= sprintf('
%s
', $link);         }              return $output.'

';     }      I have two problems with this: First of all, the order specified by ID is completely ignored, even though I pass "orderby". Additionally, image#1996 is also not displayed by the function, even though it's attached to the post (which I thought isn't necessary anyway when providing IDs to the short codes). This is the order I receive from the plugin :               Array ( [0] => 2431 [1] => 656 [2] => 652 [3] => 651 [4] => 648 [5] => 650 [6] => 643 [7] => 649 [8] => 642 [9] => 647 [10] => 641 [11] => 645 [12] => 629 [13] => 676 )      As you can see it's neither the order I specified using the shortcodes, nor is it in any way ascending or descending. I want the function to display the IDs in the exact order that they're specified in the shortcodes. Is this possible?


How to tune search argument in WP_Query to show only exactly the same results?

Right now I am using this:               $args_search = array(          's' => $search,         'post_type' => array( 'post' )     );          $wp_query = new WP_Query( $args_search );      But the problem is that it shows everything. E.g. if `$search` is just `"2386"` and I have in my db 3 posts: `"12386111"` `"23861111"` `"11112386"` I will get 3 results. But I want to get 0 results. because it's not a full match. Only if the search is `23861111` then I need to get the 1 result 23861111. Or when it is `11112386` I need to type the full `11112386` as a $search variable and not only 2386 or 238 to get the result `11112386` How to change my query to get the results as I want instead of everything that contains the search string?


Change "posts per page" depending on width

I'm working on a responsive theme. One part is a sort of news flow (blog). In desktop widths (above 767px) the news template is vertically divided in two. The left part is a navigation which lists titles and dates linking to the actual news item. The right part is where the content displays. "Posts page" is set to this page and "Posts per page" is set to 1, and thus the right content area displays one news item at a time. This vertically divided template structure works well in desktop widths but not so much on smaller widths. So for widths less than 768 I'm having a more traditional approach with the left nav part removed and the content displaying at 100% width (all through media queries). In a case like this "post per page" would be set to like 5-7 posts. So how can I change "posts per page" depending on sreen width? Or are there some other way to accomplish this?


hardened wordpress linux install

Are there any best practices for wordpress hardened install on Linux? I have recently had a WAMP server get malware attacked via word press so I want to harden the server up using read only apache permissions and move them and all future wordpress sites to Linux only the plan:   1. chown everything root:root -R so that apache can't write to anything    2. chmod so that only owner can write   3. chown only the uploads / updated files/ themes/ dirs of wordpress to apache: root this last bit is the bit I need help on, can you tell me which bits of auto- updatedness wordpress is likely to need? I have looked online and no-one is talking about this.


How to add functionality to an existing theme (using child themes)

The reason why I ask such a question isn't because I don't know how to do so at all, but rather I think the way I've trying to go about it may be wrong and that I don't understand how wordpress works well enough to know what is the best way to add functionality and custom fields to an existing theme. For example I have a theme for a website (a reverse auction project bidding theme) and a child theme was created so that of course changes could be made without changing the parent theme (for update/upgrade purposes). Now if I wanted to add a captcha box to an existing form, I know that I would have to change the files in the child theme (or use a plugin, which also requires a change to the file anyway). Now this is the bit where I get a bit confused, I know that template files get overriden if you have the same file name in the child theme. But what if the file isn't a template file? I read on some other answers here that unfortunately they dont get overriden, and that coincides with what I've been doing (only modifying the file in the parent theme makes a change to the actual website). The issue here is that there are many pages on the website which use one template and these other pages are just coded as normal html/php files. So my question can be asked in two ways, but I don't know which one is the right way: 1) If I wanted to add some php or html to these files (which can't be overriden), how would I do it. 2) or rather how can I get the file to be overriden in the child theme (when it is not a template file itself). As you can tell, I'm a wordpress beginner so I reckon I'm missing something basic and fundamental about how everything works. To be honest I don't even know if this is the best way to go about making changes to a website, I'm new to all this and it seems odd to me that one would use wordpress to make a website that isn't a blog and also that in order to add functionality to a website you have to change the theme. Sorry I haven't provided any code snippets, for one thing the theme was bought so I don't know whether I can show any of it, and secondly the question is more about concepts and the workings of wordpress. P.S. sorry for the long post.


Add inline HTML to posts published within last 24hrs

Basically I'm looking to add this line of code to posts published within the last 24hrs:               New!      When the post is over 24hrs old, remove the inline HTML element. This is my code so far but have no idea how to implement this feature, anybody got any ideas?

<a href="<?php bloginfo( 'url' ); ?>/explorers">All

<a href="<?php bloginfo( 'url' ); ?>/category/stories" class="stories">Stories

<a href="<?php bloginfo( 'url' ); ?>/category/missions" class="missions">Missions

<a href="<?php bloginfo( 'url' ); ?>/category/questions" class="questions">Questions

                           <?php                 $temp = $wp_query;                 $wp_query= null;                 $wp_query = new WP_Query();                 $wp_query->query('posts_per_page=10'.'&paged='.$paged);                 while ($wp_query->have_posts()) : $wp_query->the_post();                 ?>                          <?php if (in_category(3)) {?>                          <article class="mission" id="post-<?php the_ID(); ?>">                         <a href="<?php the_permalink(); ?>">

<?php the_title(); ?> <?php echo get_the_date(); ?>
                                 <?php global $more; $more = 0; the_content(''); ?>

Accept

                          <?php } ?>                          <?php if (in_category(4)) {?>                              <article class="story" id="post-<?php the_ID(); ?>">                             <a href="<?php the_permalink(); ?>">                                     New!

<?php the_title(); ?> <?php echo get_the_date(); ?>

<?php the_field('author_details'); ?>

Read more

                          <?php } ?>                          <?php if (in_category(5)) {?>                              <article class="question" id="post-<?php the_ID(); ?>">
<?php the_title(); ?>

                          <?php } ?>                      <?php endwhile;?>
                     <?php next_posts_link('Older Posts') ?>                     <?php previous_posts_link('Newer Posts') ?>
                                    <?php $wp_query = null; $wp_query = $temp; wp_reset_query(); ?>


Script to run at completion of Page Loading

On the home page I a have 2 lines of code I would like to run in JavaScript. Where should I put these two lines of code. Does WP have a specific way to do this. Or should I just pick the last .js file that loads and add it there?


meta_query with array as value

I am writing some PHP which allows users of my site to submit a form and query posts by their post_meta. Everything works fine except for one thing, I used Advanced Custom Fields to create the post_meta and ACF saves meta values as a serialized array. I need to keep the data in this format so ACF can pre-fill the custom fields in the admin panel. I need a way to compare an array of values (the user selects via checkboxes in the form) to a serialized array in the database. The first part of my query looks like the following, with $amenities being the array of checkbox values:               $the_query = new WP_Query(         array(             'post_type' => 'listing',             'meta_query' => array(                 array(                     'key' => 'distance',                     'value' => $distance,                     'type' => 'numeric',                     'compare' => '<='                 ),                 array(                     'key' => 'amenities',                     'value' => $amenities[0],                     'compare' => 'LIKE'                 ),                 array(                     'key' => 'amenities',                     'value' => $amenities[1],                     'compare' => 'LIKE'                 ),                 array(                     'key' => 'amenities',                     'value' => $amenities[2],                     'compare' => 'LIKE'                 )             )         )     );      The only way I can get the query to work is by querying for each possible value ($amenities[#]) the user could have entered in the checkboxes but this seems to be too cumbersome for my database to handle.


How to mark every 3rd post

I'm working on a WordPress site for my band and I'd like to mark every 3rd post on our blog page to have a special class applied to it, anybody have any pointers on how to achieve this? Any help is very very appreciated, thanks! rock n roll.


Style every four posts differently

> **Possible Duplicate:**   >  How to mark every 3rd post Is it possible to style every four posts differently? I mean something like this:

1st post

2nd post

3rd post

4th post

     ...Repeat      I'm using cssgrid, so it would be great if I could experiment more with that.. :)


Style first 3 posts differently with WP_Query

I've got the following code, which gets the first 3 posts. However, I am hoping to style each differently with `if statements`. But when I add `if statements` (to determine whether it is the first or second post), they are added, which on top of the first 3 posts: accidently creating 5 posts. Is there a proper way to style the posts depending on whether they are first, second and third, but keep within the `showposts => 3` attribute?                   <?php              $lifestyle_cat = array(             'category_name' => 'lifestyle',             'showposts' => 3,             'post_type' => 'post',             'post_status' => 'publish',             'orderby' => 'date',             'order' => 'DESC'         );              $lifestyle_query = new WP_Query( $lifestyle_cat );         if ( $lifestyle_query->have_posts()) {             $i = 0;              while ( $lifestyle_query->have_posts()) {                  $i++;                 $lifestyle_query->the_post();                     if ($i==1) { // these are added and not within the 3 show posts                        ?>
 <?php  the_title();?>  i = 1
 <?php                     } elseif ($i==2) { // these are added and not within the 3 show posts                          ?>
 <?php  the_title();?>  i = 2
 <?php                     } ?>
<?php the_title(); ?>
          <?php } } else {             // no posts found         }              wp_reset_postdata(); ?>


Split archive results in rows and columns

> **Possible Duplicate:**   >  How to mark every 3rd post I want to redesign my Archives template, so I want do display posts from archive in 3 columns and 6 rows. I have the following code:               <table width="100%" border="0" cellpadding="4" cellspacing="3" bgcolor="#CCB294">                    <?php                   rewind_posts();             if (have_posts()) {                 while (have_posts()) : the_post();                 global $post;                     include(TEMPLATEPATH. '/includes/templates/loop.php');                     $postcount++;                 endwhile;             } else {                 include(TEMPLATEPATH. '/includes/not-found.php');             }              ?>      but the code is displaying in one row and many moore columns. How can I force the code to display as I wwant? Thank you.


Wordpress custom post type odd and even styling

I've got a custom post type that I would like to be able to show in the following: is this possible using the following code:               <?php query_posts(array('post_type' => 'story', 'orderby' => 'title', 'order' => 'asc', 'post_status' => 'publish', 'paged' => $paged)); ?>          <?php if ( have_posts() ) : ?>      <?php /* Start the Loop */ ?>     <?php while ( have_posts() ) : the_post(); ?>          <hgroup>
       <?php the_title(); ?>
     </hgroup>

       <?php the_post_thumbnail(184, 260); ?>

     <?php the_content(); ?>
<?php the_tags(); ?>


Apply class to every third list item?

> **Possible Duplicate:**   >  How to mark every 3rd post I'm trying to give a class to every third list item on my page. I know how to give a class to every item, but not to specific items in a row, or in my case - the third. This is the code I am using:               <?php                 $pages = get_pages('child_of=10');                 if ($pages) {                     echo '
';                     foreach ($pages as $page) {                         echo '
ID).'">';                         echo get_the_post_thumbnail($page->ID);                         echo '';                         echo get_the_title($page->ID);                         echo '';                         echo '
';                     }                     echo '
';                 }                 ?>      I know I need to use a counter (and probably something to reset it after each third list item) but I am unsure of how to code this logic in PHP. Can anyone assist? Thanks


Styling every second Post differently?

I wanted to style every second post inside of a query post and I found a solution which nearly works. the thing is: it outputs just two posts (older ones will be igrnored) but i want to output ALL posts but with every second one with a sepcific class. Here's what i did so far…               <?php     $paged = (get_query_var('paged')) ?   get_query_var('paged') : 1;     $wp_query = new WP_Query();     $wp_query->query('posts_per_page='.get_option('posts_per_page').'&paged=' . $paged);                      global $wp_query;                             query_posts(array_merge($wp_query->query, array(                                 'paged'          => get_query_var('paged'),                                 'posts_per_page' => 9999999                             )));                     ?>     <?php if ($wp_query->have_posts()) : ?>     <?php $count = 0; ?>     <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>     <?php $count++; ?>          <?php if ($count == 1) : ?>

           <?php elseif ($count == 2) : ?>

           <?php endif; ?>     <?php endwhile; ?>     <?php endif; ?>


Woocommerce Product Categories shows invalid sub-category

I'm going to try my very best to explain the issue I'm experiencing. When using the widget "woocommerce product categories", I select only "Only show children for the current category". Next, when I view the widget, I see the following: ![enter image description here](http://i.stack.imgur.com/h2ekM.png) The sub-categories for Video Games/Xbox 360 are shown as expected, but one additional sub-category seems to have snuck in: Second Hand. This category is not a sub-category of Xbox 360 and is a stand-alone category. If I switch on "show hierarchy" it shows as a category above Xbox Games, see the following: ![enter image description here](http://i.stack.imgur.com/eUecb.png) This one additional (non-related) sub category seems to sneak into every single page I use the "woocommerce product categories" widget in. What is causing this and how can I remove it? Thanks in advance for your suggestions!


How do I add nested categories to drop-down menu in twenty-eleven?

I know how to do it by writing a separate ul/li css for wp_list_categories, but I find menus of "twenty eleven" already well designed and flexible, so I`d like to use them. Custom menus, when I have to add subcategories manually, are not a solution, sinse I will allow my users to create new categories. What would you do?


Fatal error: Call to undefined function register_new_user()

Have a wordpress theme with custom registration. Registration works on the registration page. If I take the form and place it on another page , eg. Homepage.. it gives me this error. Here is the code for my form               // Form
                    <?php if(edd_get_errors()){?>

<?php __( 'Please review the following issues that occurred', 'forest' ); ?>

                           <?php forest_print_errors();?>

                     <?php } else if(isset($_GET['success']) && $_GET['success'] == "ok") {?>

<?php echo __( 'Thank you, You will receive your new password via email.  For security, please change this upon login', 'forest' ); ?>

                     <?php }?>

                             <?php if (get_option('users_can_register')){ ?>                                                  <form id=""  class="horizontal-form" action="" method="post">                                               <fieldset>
                                                                     <?php echo __( 'Username', 'forest' ); ?>:
                                                                       <input name="user_login" id="user_login" class="required" type="text" value="<?php echo isset($_POST['user_login']) ? esc_attr(stripslashes($_POST['user_login'])):''; ?>"/>

                                                                     <?php echo __( 'E-mail Addy', 'forest' ); ?>:
                                                                       <input name="user_email" id="user_email" class="required" type="text" value="<?php echo isset($_POST['user_email']) ? esc_attr(stripslashes($_POST['user_email'])):''; ?>"/>

                                                                      <?php echo __( 'The password will be e-mailed to you.', 'forest' ); ?>

                                                                      <input type="hidden" name="edd_redirect" value="<?php bloginfo('url') ?>/wp-login.php?action=register&success=ok"/>                                                                     <input type="hidden" name="edd-registre-nonce" value="<?php echo wp_create_nonce( 'edd-registre-nonce' ); ?>"/>                                                                     <input type="hidden" name="edd_action" value="user_registre"/>                                                                     <button type="submit" class="btn-icon submit"><?php echo __( 'Create Account', 'forest' ); ?></button>
                                                          </fieldset>                                         </form>                                          <?php } else {?>
<?php echo __('Registration is closed','forest'); ?>

<?php echo __('Sorry, you are not allowed to register by yourself on this site!','forest'); ?>

<?php echo __('You must either be invited by one of our team member or request an invitation by email.','forest'); ?>
                                     <?php }?>

      and here is the code for the function               function forest_process_registre_form( $data ) {             if ( wp_verify_nonce( $data['edd-registre-nonce'], 'edd-registre-nonce' ) ) {                          $errors = register_new_user($data['user_login'], $data['user_email']);                     if ( isset($errors) && is_array($errors) ){                             foreach($errors as $error) {                                     if(count($error) > 0) {                                             foreach($error as $e) {                                                     edd_set_error( 'email_incorrect', $e[0]);                                             }                                     }                             }                     }                     // Check for errors and redirect if none present                     $errors = edd_get_errors();                     if ( ! $errors ) {                             $redirect = apply_filters( 'edd_login_redirect', $data['edd_redirect'], $user_ID );                             wp_redirect( $redirect );                             exit;                     }             }     }     add_action( 'edd_user_registre', 'forest_process_registre_form' );      Full function code here Why won't register_new_user() work if the form is placed anywhere else?