the_content() Returns post content when I want page content

I'm very new to WordPress, but I'm currently doing work on a site built on the platform. I'm making my way through, but I've run into a bit of a problem. I'm trying to add content from the text editor of the site's blog `page`, which uses the standard index.php template. However, when I use `<?php the_content(); ?>` like other pages use, it returns the content of the latest `post`. Is there a way to get the content from the page editor instead? I've been looking all morning without really finding anything satisfactory. Any advice would be greatly appreciated!
                     <?php the_content(); ?>
                              <?php if (have_posts()) : ?>                                  <?php get_template_part('inc/loop', get_post_type() ); ?>                              <?php else : ?>                                  <?php get_template_part('inc/content', 'none' ); ?>                              <?php endif; ?>


Creating completely new WordPress site from old WP contents

I have an **old WordPress 3.5 site** , but now I'm working in **creating completely a new** WordPress project, it will be using the latest WP 3.8.1 and new design with a theme that i bought. Kindly, if someone can help me with this points:   * I need to use all the content from the old WP site ( the data itself as a raw martial e.g: if i have 1000 post i need to use them in my new site, i don't need to enter them again instead reuse them). Taking in consideration that the new website will be different in (categories, tags, new pages, new menu) that's what i mean by completely new, so **i'm not upgrading or migrating**. I hope that i make it clear.


Remove wordpress author's capability to moderate comments on their own posts

WordPress authors have permission to edit others comments on their own post. How to disable this and still allow the authors to edit their published posts?


Problem with Yoast SEO and GD Press Tools

I am having a small problem with getting Yoast SEO to work along side GD Press Tools, which i am hoping i can get some help from you guys. I am look to move from Platinum SEO Pack to Yoast, as I been told its all round better. But when I install Yoast SEO, GD Press Tools (another plugin) does not work as it should and keeps saying: Working, Please wait. Are You sure? Operation is not reversible The following is at the bottom of every setting page for GD Press Tools. ![enter image description here](http://i.stack.imgur.com/JZLUi.png) I spoken to the developer of the GD Press Tools and this is what they said: > It is very likely that the plugin is adding its own JavaScript where it > should not do it, causing problems to GD Press Tools. Plugins should load JS > files only on own pages, not messing with other plugins. So then, has anyone got any ideas one what could be up with it and how to fix it, as i don't really have a clue where to start.


Renaming/translating "your profile" page

I need to rename/translate the "Your Profile" page. I've used the function below               function pietergoosen_hoofskerm_vertaling( $translated ) {      $words = array(                         'Name' => 'Naam',                          );      $translated = str_ireplace(  array_keys($words),  $words,  $translated );      return $translated;     }     add_filter(  'gettext',  'pietergoosen_hoofskerm_vertaling'  );      The problem is, this change all instances of Name to Naam, even when name is part of word or sentence, like 'UserName' get changed to 'UserNaam' and 'Display Name publicly as' get changed to 'Display Naam publicly as'. Any other ways to this


Using Ajax with a Class file

At the moment I have an ajax that works (I get a success [200] response), but having an issue with the action hooks on the response. The JSON object is not coming back, instead **I'm getting a 0**. I have the die(); after my return so I'm thinking the issue is the hook not working. I've tried multiple methods within the Class constructor but I'm not sure if this approach is right, I've done it before with a plugin I made, but this is within the **theme**. ## Form.php _(included in functions.php with`add_action('after_setup_theme')`_               public function __construct(){      // Test #1      add_action( 'wp_ajax_nopriv_process_reservation', array( &$this, 'process_reservation' ) );           // Test #2       add_action( 'wp_ajax_process_reservation', &$this->process_reservation ); //with and without '&' before $this           // Test #3 (this is incorrect)      add_action( 'wp_ajax_nopriv_process_reservation', $this->process_reservation );               //If I wrap this with **add_action('init',function(){... *** then it does not load      wp_enqueue_script('ajax_script',THEME_MODULES_URL.'/Reservations/form.js',array('jquery'),TRUE);      wp_localize_script( 'ajax_script', 'myAjax', array(           'ajaxurl'               => admin_url( 'admin-ajax.php' ), //don't change this           'itemNonce'             => wp_create_nonce("ajax_nonce"), //don't change this       ));     }      Just in case it is needed here is the test of my callback function at the moment as well               private function process_reservation(){         check_ajax_referer( 'process_reservation_nonce', 'nonce' );              if( true )             wp_send_json_success( 'ok' );         else             wp_send_json_error( array( 'error' => $custom_error ) );          }      Form data in the XHR console shows both the action and nounce passed               action:process_reservation     ajax_nonce:6f155a1e17      I've done enough Ajax to know what to expect so I'm pretty sure its a hooking issue here, perhaps something with the theme scope that I don't understand, either way any suggestions or help from the community would be great! Thanks in advance


Can wp_schedule_single_event be used to run background proccess?

I got a plugin that let users send invitations to their friends. If the user have like 4000 friends we run into trouble. At the moment i use a simple batch like the following for emails. But we also send facebook and twitter messages. USer don't need to wait until procces is complete and this is called actually with a ajax call               set_time_limit(60*60);          if( $quantity < 40 ){              foreach( $emails as $email )         {             wp_mail( $email, $subject, $message, $headers);             sleep(1);         }          }     else     {         $counter = 0;         //Lets create batches         foreach( $emails as $email )         {                 $counter++;             wp_mail( $email, $subject, $message, $headers);             sleep(1);                  if( $counter == 50 )             {                 sleep(10);                 $counter = 0;             }         }     }      As cron jobs are usually not allowed in shared hosting, the same way exec sometimes is not available we were thinking on use wp_schedule_single_event. Should be possible or i would need to try a `exec("doTask.php $arg1 $arg2 $arg3 >/dev/null 2>&1 &");` approach to run the process in the background?


500 Error when opening multiple WPMU domains in one browser

We have a WPMU instance with ~50 sites on it and, if we open multiple domains in a single browser, the CPU and memory usage on the server goes through the roof and further pages result in a 500 error. We have not tried disabling plugins to see if that was the cause yet, that will be done tonight in off- hours. I'm hoping that someone else has seen similar behavior and might be able to steer us in the right direction.


Is it possible to customize the layout of Gallery Shortcode?

Is it possible to customize how my gallery shortcode works. eg. have a div for showing the image then a list of thumbnails at the bottom or side? Or perhaps I can create a custom template file to loop through my page's gallery images?


Trouble Installing Wordpress Get PHP Not Running Answer

I have seen this topic discussed several places on the internet, both in the Wordpress official forums and on individuals' blogs. Despite having worked through some of the suggestions, I am still getting the error, when I try to run wp-admin/install.php in my browser locally logged into the console of the server. Here is what I have done: 1) Apache is installed. 2) MySQL is installed. 3) PHP is installed both according to yum, and the following works the command line, and if I put               <?php     phpinfo();     ?>      into /var/www/html/index.php and point my browser to `http://localhost` I get the phpinfo page. 4) The OS is CentOS 6.4 5) Here is the output of mysql Server version: 5.1.69 Source distribution 6) From command line php -version PHP 5.3.3 (cli) (built: Feb 22 2013 02:51:11) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies 7) From /etc/httpd/conf/httpd.conf `LoadModule rewrite_module modules/mod_rewrite.so` What else do I need to do to install WordPress? Here is part of the error page: ![enter image description here](http://i.stack.imgur.com/sWDZB.png) What is weird is I have not installed db tables from the MySQL server into the MySQL server on this system. It says the config has a bad database entry in it, so I'll go look at that, and update the OP.


Check if any users are logged in before running update

Before I update a Wordpress install (including the theme and various plugins) I wanted to ensure no one is logged in and editing the site. Is there a way to do this? Thanks!


Wordpress Admin Panel Search posts with custom post meta values along with title

Trying to modify default admin search by including search by custom post type fields, Below is my code,               function custom_search_query( $query ) {         $custom_fields = array(         // put all the meta fields you want to search for here         "rg_1job_designation",         "rg_2job_designation"         );         $searchterm = $query->query_vars['s'];         // we have to remove the "s" parameter from the query, because it will prevent the posts from being found         $query->query_vars['s'] = "";         if ($searchterm != "") {         $meta_query = array('relation' => 'OR');         foreach($custom_fields as $cf) {         array_push($meta_query, array(         'key' => $cf,         'value' => $searchterm,         'compare' => 'LIKE'         ));         }         $query->set("meta_query", $meta_query);         };     }     add_filter( "pre_get_posts", "custom_search_query");      But it's not working. i have a post **title** -> **John** & **Designation** -> **Designer** On search by **Designer** can get 1 result, But on search of **John** result is empty (This should also fetch one result). Now the default search for title is lost want to use that too. Did anyone know what's wrong in my code ?


How to use categories in the URL with Advanced Custom Fields?

Using the Advanced custom fields plugin: 1) I want to post to the ACF and use a category just like a regular blog post, but the URL would be: `mysite.com/customPost/category/post-name` Is this possible? And how can I do it? 2) Can I add a custom page template to each category page?


Where is the order of a menu saved in the database

I want to use a custom menu from the wordpress database but I get the elements disordered and I want them to have the same order how can i do that? There is a place in the database where the order is stored?


How to display the post of child custom taxonomy but not that post in parent?

I want the archive page of custom page having custom post type in order with custom taxonomy. like               -parent1_taxonomy        -child1_taxonomy          -child1_taxonomy_post1          -child1_taxonomy_post2                -child2_taxonomy                      -child2_taxonomy_post1                      -child2_taxonomy_post2     parent2_taxonomy      -likewise       ................      I use following code for archive template.               <?php     /**     *Display categories list and post     */          $query_category = mysql_query("SELECT wp_terms.term_id,wp_terms.name, wp_term_taxonomy.parent FROM wp_terms INNER JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_id WHERE wp_term_taxonomy.taxonomy = 'food_menu_food_category' ORDER BY name");         $data = array();         $index = array();         while ($row = mysql_fetch_assoc($query_category)) {             $id = $row["term_id"];             $parent_id = $row["parent"] === NULL ? "NULL" : $row["parent"];             $data[$id] = $row;             $index[$parent_id][] = $id;         }         function display_child_nodes($parent_id, $level){             global $data, $index;             $parent_id = $parent_id === NULL ? "NULL" : $parent_id;             if (isset($index[$parent_id])) {                 echo "
";                 foreach ($index[$parent_id] as $id) {                     if($level == 0){                         echo "

".$data[$id]["name"]."";                         //$ca=$data[$id]["name"];                                                 ?>              <?php                     }                     if($level == 1){                         echo "

".$data[$id]["name"]."

";                           $ch=$data[$id]["name"]  ;                           //echo $ch;                                  //For post content                                  $post_type = 'food_menu';                                 $tax = 'food_menu_food_category';                                 $tax_terms = get_terms($tax, array('orderby' => 'id', 'order' => 'ASC'));                                 if ($tax_terms) {                                     foreach ($tax_terms as $tax_term) {                                         $args = array(                                             'post_type' => $post_type,                                             "$tax" => $tax_term->slug,                                             'post_status' => 'publish',                                             'posts_per_page' => - 1,                                             'orderby' => 'title',                                             'order' => 'ASC',                                             'caller_get_posts' => 1                                             ); // END $args                                         $my_query = null;                                         $my_query = new WP_Query($args);                                         if ($my_query->have_posts()) {                                             //echo '
' . $tax_term->name . '
';                                             $c=$tax_term->name;                                             //echo $c;                                             while ($my_query->have_posts()) : $my_query->the_post();                                             if($ch==$c){                                                 //echo '
'. $ch .'
';                                                 ?>

 <a href="<?php the_permalink(); ?>">                                                 <?php $scat=get_the_title();                                                 echo $scat; ?>                                                 <a href="<?php the_permalink(); ?>">                                                 <?php echo esc_html( get_post_meta( get_the_ID(), 'food_price', true ) ); ?>

                                            <?php                                                  }                                             ?>                                           <?php                                             endwhile;                                         } // END if have_posts loop                                         wp_reset_query();                                     } // END foreach $tax_terms                                 } // END if $tax_terms                          }                                    // Child of child class                     if($level == 2){                         echo "

".$data[$id]["name"]."

";                           $ch=$data[$id]["name"]  ;                           //echo $ch;                                  //For post content                                  $post_type = 'food_menu';                                 $tax = 'food_menu_food_category';                                 $tax_terms = get_terms($tax, array('orderby' => 'id', 'order' => 'ASC'));                                 if ($tax_terms) {                                     foreach ($tax_terms as $tax_term) {                                         $args = array(                                             'post_type' => $post_type,                                             "$tax" => $tax_term->slug,                                             'post_status' => 'publish',                                             'posts_per_page' => - 1,                                             'orderby' => 'title',                                             'order' => 'ASC',                                             'caller_get_posts' => 1                                             ); // END $args                                         $my_query = null;                                         $my_query = new WP_Query($args);                                         if ($my_query->have_posts()) {                                             //echo '
' . $tax_term->name . '
';                                             $c=$tax_term->name;                                             //echo $c;                                             while ($my_query->have_posts()) : $my_query->the_post();                                             if($ch==$c){                                                 //echo '
'. $ch .'
';                                                 ?>

 <a href="<?php the_permalink(); ?>">                                                 <?php $scat=get_the_title();                                                 echo $scat; ?>                                                 <a href="<?php the_permalink(); ?>">                                                 <?php echo esc_html( get_post_meta( get_the_ID(), 'food_price', true ) ); ?>

                                            <?php                                                  }                                             ?>                                           <?php                                             endwhile;                                         } // END if have_posts loop                                         wp_reset_query();                                     } // END foreach $tax_terms                                 } // END if $tax_terms                          }                                         //Child of child of child class                     if($level == 3){                         echo "

".$data[$id]["name"]."

";                           $ch=$data[$id]["name"]  ;                           //echo $ch;                                  //For post content                                  $post_type = 'food_menu';                                 $tax = 'food_menu_food_category';                                 $tax_terms = get_terms($tax, array('orderby' => 'id', 'order' => 'ASC'));                                 if ($tax_terms) {                                     foreach ($tax_terms as $tax_term) {                                         $args = array(                                             'post_type' => $post_type,                                             "$tax" => $tax_term->slug,                                             'post_status' => 'publish',                                             'posts_per_page' => - 1,                                             'orderby' => 'title',                                             'order' => 'ASC',                                             'caller_get_posts' => 1                                             ); // END $args                                         $my_query = null;                                         $my_query = new WP_Query($args);                                         if ($my_query->have_posts()) {                                             //echo '
' . $tax_term->name . '
';                                             $c=$tax_term->name;                                             //echo $c;                                             while ($my_query->have_posts()) : $my_query->the_post();                                             if($ch==$c){                                                 //echo '
'. $ch .'
';                                                 ?>

 <a href="<?php the_permalink(); ?>">                                                 <?php $scat=get_the_title();                                                 echo $scat; ?>                                                 <a href="<?php the_permalink(); ?>">                                                 <?php echo esc_html( get_post_meta( get_the_ID(), 'food_price', true ) ); ?>

                                            <?php                                                  }                                             ?>                                           <?php                                             endwhile;                                         } // END if have_posts loop                                         wp_reset_query();                                     } // END foreach $tax_terms                                 } // END if $tax_terms                          }                                  // echo str_repeat("-", $level) . $data[$id]["name"] . "
";                    display_child_nodes($id, $level + 1);                     if($level != 1){                         echo "
";                     }                 }                 echo "
";             }         }         display_child_nodes(0, 0);          ?>      This code display the post like ..               -parent1_taxonomy      -child1_taxonomy          -child1_taxonomy_post1          -child1_taxonomy_post2          -child2_taxonomy_post1          -child2_taxonomy_post2                -child2_taxonomy                      -child2_taxonomy_post1                      -child2_taxonomy_post2      parent2_taxonomy        -likewise...      Also the post of its sub category in root category.. Thank you in advance.


Special Character Appearing in my WordPress Pages Content

Can somebody please assist as to why I am getting the following special character � in my WordPress content pages. Not sure how it got in there. You can see this special character at this url: PPS Victoria and then just scroll down to "Restoration and Recovery Services" sub-section. Any help would be great. Thanks.


Opinions whether to go multisite VS 3 separate WP installation

I've been reading a lot of questions here regarding about multiple blogs/sites in one Wordpress installation and I've added some of them to my favorites. But I still have the urge/nerve to post this question as I'm excited to have my first attempt in blogging. I will ask for your opinions and experiences on how to best solve my dilemma. My goal is to launch 3 blogs based on my varied interests. I've already bought domains and web hosting. Now the questions going through my head are:   1. It might be better to have one account to manage the 3 blogs I'm planning. Is that the multisite feature of Wordpress? Those 3 blogs will be on 3 different domains as they are different (niche) in category. They'll also be having their own themes.   2. In this multisite feature, will they point to one database only? If that's the case, it would be better to have separate databases for those blogs of mine to avoid bloating the database. **I think this database thing is my main issue.** What do you guys think?   3. I've really no need for unified user registration as of the moment, contrary to what other users reason out for setting up multisite in WP. These are just blogs not forums anyway, besides users/visitors just can use OpenID or their WP accounts to comment right?   4. Finally, am I just better having 3 separate WP installations on my host? What pros and cons can you guys give from choosing multisite versus 3 separate WP installations? The perfect example might be the account one could have on Wordpress.com. You only have one account but you get to create many blogs that will be on their own domains later on. The benefit is that you control it on one account only. Hope to hear your opinions and thank you.


new WP_Query based on average values of meta fields

I have 5 different meta (numerical) fields for a custom post type and I need to create a query based on the average values from those fields (kinda like a rating system, post with highest average rating from those 5 different rating field should come first). The meta boxes are setup and working smoothly, however I am stuck when I have to query the posts by the average values.. I have absolutely no idea how to get those values before the query, any help will be appreciated. Thanks


Resize images in batch

I want to resize images on server, I have more than 7000 images in library of my WordPress site. I want to resize all images on server itself. I know that regenerate thumbnails plugin can be used, but for that I will have to keep my browser window open all the day and it can even crash somewhere in middle that will lead me to resize all images again. Does anyone have better idea to do this stuff? Please explain answer in brief.


Add custom field to existing meta box?

First off, I have been able to successfully implement custom fields within a custom meta box in Wordpress. I understand how this works. My question is, is there a way for me to add a custom field to an already existing meta box? For instance, I want to add field within Wordpress's "Author" meta box because it is directly related to the author of a post. I haven't found any documentation or examples of this, just many regarding adding an entirely new meta box. Is it possible to add a custom field to one of Wordpress's existing meta boxes? Thanks.


How do I determine if the user who registered is not spam?

I've recently set up a forum on my site with the bbpress-plugin. Now a user has registered on the site but the email-adress looks suspicious to me. How can I determine if the user is real? Is there a security risk if it is spam and I do not remove the user? Thanks


posts2posts query using connected_items array issue

**My setup is as follows** I hava a custom post type named 'events' and a custom post type named 'genres' which I link with scribu's Posts2Posts plugin. Each event can have multiple genres linked to it. **What I would like to do** _On an event page_ , I'd like to show other, related, events based on the genres the current event has. What I think I should do   1. Run a query which gets all the genres IDs of the current event   2. Pass these IDs in a second query which finds all the events which have one or more of these genres linked to it  I have a p2p query which I'd like to output all events which have one AND / OR more of the given genres in connected_items. I pass them as an array, just like in the documentation. To illustrate my outcome, lets say that   * event1 has linked genres with post ids 1240, 1241, 1242 and 1250   * event2 has linked genres with post ids 1240, 1241 and 1260    * event3 has linked genres with post ids 1241 and 1242 In the first query I get all the genre IDs, this works. The second query which gets all the events with the given genres (I pass them as an array):               $args = array(             'connected_type' => 'genres_to_events',             'connected_items' => array(1240,1241,1242),             'post_status' => 'publish',             'posts_per_page' => -1,         );          $query = new WP_Query($args);      The thing is that the output checks for each connection in the array, and therefor the output of the query is:   * event1    * event1   * event1    * event2   * event2   * event3   * event3 But I'd like to output each event once based on if it has one or more of the genres connected to it. I don't think this is explained in the documentation, any ideas?


Wordpress and WebRTC?

I'm pretty new to WordPress and I was wondering about WebRTC integration : user permissions, page integration... I'm especially interested in chat communications (writing and audio, video is not my first concern). At the moment the only available plugins are about video communications and use an external solution (service). Does someone has already addressed this topic and would share some hint ? Thanks


clicking on page title

In the website I'm looking for something so that I can disable clicking titles in category posts. Just want them to be a simple text not a link one How can I do that? Thanks


Get sidebars depending on page

Is there a way to get only the sidebars used on a particular page? Using:               global $wp_registered_sidebars;     $widget_map = wp_get_sidebars_widgets();      Can get me all of the sidebars, but I'm interested in getting the sidebars only for a particular page. Something sounding like `get_sidebars_by_page_id()`


Proper hook for W3TC defines, or dynamically disable w3 total cache

I have a site that uses a shopping cart plugin (Shopp), a plugin I wrote, and W3 Total Cache. In my plugin, I'd like to make sure that W3 Total Cache does not serve any cached pages if the user has any items in their cart, however, I can't seem to find the proper hook to define the constants that will disable W3 Total Cache caching. This is what I have at the very top of my plugin file (the shopp_init function runs during wordpress `init`):               // do not cache anything if items are in cart     add_action('shopp_init', function(){         if (shopp_cart_items_count() > 0)         {             define('DONOTCACHEDB', true);             define('DONOTCACHEPAGE', true);             define('DONOTCACHEOBJECT', true);         }     });      It seems like if the `DONOTCACHEPAGE` constant is detected once for a page, it won't check for it again. So if I have any items in my cart at any point, it'll never cache anything. Likewise, if my cart is empty once, it'll always allow all pages to be cached. How can I dynamically disable w3 total cache?


Redirect user if they are not logged in

If user enters the url www.abc.com in the browser and he is not logged in, then we want to redirect him to www.abc.com/de. How can I do this within WordPress?


get permalink of page children in loop

I have some landing pages that show the page title, feature image and excerpt of their children. The image is linked to the child page, but I need the page title linked to the same place - and I can't figure out how. Here is my existing code - it works perfectly, except the title is not linked. Any recommendations?               <?php while ( have_posts() ) : the_post(); ?>     <?php get_template_part( 'content', 'page' ); ?>     <?php if ( is_page( 'foo' ) ) {         $pageChildren = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'menu_order', 'hierarchical' => '0' ) );         if ( $pageChildren ) {         foreach ( $pageChildren as $pageChild ) {         echo '

' . $pageChild->post_title . get_the_post_thumbnail($pageChild->ID).'
       ';       if ($pageChild->post_excerpt){       echo '
'.$pageChild->post_excerpt.'

     ';         }         }         }     }     elseif  ( is_page( 'bar' ) ) {         $pageChildren = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'menu_order', 'hierarchical' => '0' ) );         if ( $pageChildren ) {         foreach ( $pageChildren as $pageChild ) {         echo '

' . $pageChild->post_title .'
       ' . get_the_post_thumbnail($pageChild->ID);       if ($pageChild->post_excerpt){       echo '
'.$pageChild->post_excerpt.'
       ';       } echo '
     ';         }         }     }     ?>     <?php comments_template( '', true ); ?>


remove_action("wp_ajax_function", "function"); not working

I have the following code in a file called contact-form.php. The file lives here: wp-content/themes/NAMEOFTHEME/ (premium theme)               function theme_contact_form() {        // some code here (send mail when submit a form)     };     add_action("wp_ajax_theme_contact_form", "theme_contact_form");     add_action("wp_ajax_nopriv_theme_contact_form", "theme_contact_form");      All I want to do is remove this function and use my own. So I wrote a plugin which does a `remove_action()` and adds my own:               function extend_contact_submit() {        remove_action("wp_ajax_theme_contact_form", "theme_contact_form");        remove_action("wp_ajax_nopriv_theme_contact_form", "theme_contact_form");        function custom_theme_contact_form() {           // some code here (send email differently)           };        add_action("wp_ajax_custom_theme_contact_form", "custom_theme_contact_form");        add_action("wp_ajax_nopriv_custom_theme_contact_form", "custom_theme_contact_form");     };     add_action('shutdown', 'extend_contact_submit');      Using this plugin I can see the function is hooked and shortly _after_ that removed by my plugin. Everything seems to be fine, BUT: the function is still active. (Because the original email is sent.) Setting `$priority` to `10` has no effect at all... I have no idea what's going on. I'm stuck on this problem for about five hours, googling and trying different approaches like `add_action('after_setup_theme', 'extend_contact_submit');` but none of them worked for me. Might this be caused because my plugin code is executed too early? Or because of using AJAX? I'm really new to PHP, AJAX and writing plugins, so please bear with me! Thanks!


Why is wordpress permalink path wrong for single blog posts?

I'm developing my site with MAMP and my homepage is at localhost:8888/wordpress When I click on the link to my blog page (home.php) the url looks like this: localhost:8888/wordpress/blog All good so far. However, when I click on a blog post from the home.php template the url looks like this: localhost:8888/wordpress/blogpostname How can I make it so it's localhost:8888/wordpress/blog/blogpostname ? When I changed my permalink settings to localhost:8888/wordpress/%category%/%postname%/ it still left out the /blog in the URL. Why is it doing that and how can I fix it?


From where wp ecommerce is loading plugin theme files?

I updated my checkout page by updating the file which was in ....wp- ecommerce/wpsc-theme/wpsc-shopping_cart_page.php It worked fine for a while, but now some of the changed states reverted to the previous state. Actually, I can even delete the file that I mentioned above, so it means wordpress is loading this file from somewhere else. Any ideas from where and what had happened? Thanks for your help.


Is there a plugin that lets users request an account on the site?

Is there a Wordpress plugin that lets users fill in a form to request an account that then has to be cleared/activated by an admin for the user to get access?


How to can I search range of products using between

I want to show the range of my houses as per size. Ranges will be: 1-50   50-100   100-150   150-200   200-250   +250.   **HTML code**               <select name="size" id="search-type" class="text<?php echo $select_wide; ?>">         <option value=""><?php _e('Size..', TS_DOMAIN); ?>…</option>         <option name="size" value="1">1-50 M2</option>         <option name="size" value="5000">50-100 M2</option>         <option name="size" value="10000">100-150 M2</option>         <option name="size" value="15000">150-200 M2</option>         <option name="size" value="20000">200-250 M2</option>         <option name="size" value="999999">+250 M2</option>          </select>      **PHP code**               // check size custom fields          if($search_get['size'])         $meta_query_size = array(                 'key' => '_size',             'value' => array($search_get['size'],10000),             'compare' => 'BETWEEN',             'type' => 'NUMERIC'         );        Note: If I use the query below, then it works, but not for `between`.               // check size custom fields          if($search_get['size'])         $meta_query_size = array(                 'key' => '_size',                 'value' => $search_get['size'],                 'compare' => '<=',                 'type' => 'NUMERIC'             );        Please advise.


Do you clean up your self-written plugins' at deactivation?

After developing some plugins for myself, some of them is ready to be published. For all, I've written deactivation functions, which deletes the set options, the database, etc. after themselves. But I'm having doubts about the reason for these, for example, what if it's only a temporary inactivation? What do you think, does a process need a cleanup hook for deactivation or not?


get_post_meta not working on category.php

I'm referencing an attached image in my header.php page which is displayed as a full screen background on my posts:               global $wp_query;     $page_id = $wp_query->get_queried_object_id();     $background_image = get_post_meta($page_id, 'mb_background_image', true);     $src = wp_get_attachment_image_src($background_image, 'full');      This works fine on single posts, but doesn't work when displaying just one post per page in category.php. How can I fix this? Thanks


Display Plugin Panels Outside of Admin Areas

I'm trying to find a way to display the work area content of different plugins on pages/posts/areas aside from the admin backend. For example, how would I display the options panel for a certain plugin in a page instead of it's default location? If the plugin also has an output view, like Google Analytics dashboard, how would I call that output content to display in a post? I essentially want to move a lot of the settings and other panels from the admin areas to other locations, or have them display in other locations where they're called. Any pointers on how I might go about that?


301 Redirect all posts urls from .html to / (without .html)

How can i redirect all posts permalinks from .html to / ,in Wordpress ? now all my posts url are ending in / ,but before it was with .html to be more clear ,for example a post url like this http://sitename.com/%category%/%postname%.html to be redirected to http://sitename.com/%year%/%monthnum%/%postname%/ . It's simple to redirect them one by one,but i need a rule to redirect all posts . my curent .htaccess               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress          ======      Thank you


Enabling XML-RPC Accross 500 blogs

How would I update 500 different blogs hosted on separate hosting accounts and enable xml-rpc publishing? We are writing a unified system for our clients who use a customized deployment of WP, allowing them to interact with their blogs from our site.


Generating images from an array of categories

I'm using the following code to display images based on the category id:               <?php      if (is_category( 'web-design' )){     ?>        <img src="<?php bloginfo('template_directory'); ?>/images/slider_webdesign.png" title="خدمات تصميم وتطوير المواقع" height="200px" width="960px" />     <?php     }else if (is_category( 'printing' )){     ?>     <img src="<?php bloginfo('template_directory'); ?>/images/slider_printing.png" title="تصميم مطبوعات" height="200px" width="960px" />     <?php     }else if (is_category( 'online-marketing' )){     ?>      I would like to make an array of only one condition to display an image with the category slug, is that possible?


Insert shortcode in post editor from javascript (Visual / HTML)

I want to insert a shortcode in the Wordpress Post Editor from javascript (not a tinymce plugin). I currently use:               tinyMCE.activeEditor.execCommand('mceInsertContent', false, "[SHORTCODE]test[/SHORTCODE] ");      but this only seems to work when the editor is in "Visual" mode (and sometimes activeEditor == null). How do I accomplish this regardless of the state of the editor? (I'd think this is a fairly common scenario)


can registration be enabled programatically?

I need to allow registration as part of a build for a client, and I am aware this can be turned on in the admin panel, but can I turn it on in the function?


Quick login from mobile phone

I have a site which is essentially a blog carrying alerts to Doctors. The idea is that the Doctors will get an SMS alerting them to the fact that a new alert has been posted and a link to the alert. The alert will contain images. It is public, hidden from SE but might contain some sensitive info. I was wondering if there was any way of authenticating a user by mobile phone number, or any easy way for a mobile phone user to log in to a Wordpress site?


how to add <span> around each author using wp_list_authors

how to add span around each author using wp_list_authors, so the result would be like this               author Aauthor B


How to create Custom Taxonomy Search Drop Down for specific Post Type

I have a number of custom post types which share a custom taxonomy. I'm trying to implement a dropdown search box using php (to insert into a widget or elsewhere) that allows selection of a taxonomy term, and returns the posts which have that term, but only within a specific post type. I'm hoping to then create one of these dropdown search boxes for each post type so a user can easily navigate to posts under a taxonomy term and within a post type. Can anyone assist with this please?


Disabling tooltip on menu items

For some reason, my menu items are showing tooltips on hover-over- In other words, the menu links have "title" attributes being added to them. Looking at my other, older WordPress sites, this is not the case. I can't remember having this issue before- Why would this be happening? Thanks-


How can I allow users to edit text that will be displayed on a custom post type archive page?

I like the custom post types Wordpress offers. Most of the time I like the way that the archive of custom posts is displayed. For example if you have a custom post type of `top_hats` you can visit `yoursite.com/top_hats/` if it is set as publicly queryable. I realize that a description can be set for custom post types, but I am looking for something that supports the built in rich text editor. I also realize that you can edit a post-type archive template, something like `archive-top_hats.php`, which could be edited to have a custom message in the top of it - however I am looking for something that will give the user more control. The expected (and ideal) behavior would be if you had the Admin Bar enabled and you were logged into the Wordpress site. Imagine if you visited the `yoursite.com/top_hats/` page and there was the menu bar option that said "edit this page" which made editing that page as simple as editing any other page. If you added a message and then updated the page and viewed it, you would see your content at the top, followed by the `custom_post_type` entries below (in archive format). Seems like that's how it should work, but I really am not sure the ideal way to get that integrated.


Enqueue script on every page except one

I want to load my javascript and exclude 1 page, so I tried the following without success:               function mypage_scripts()          {     if ( !is_admin() )     {          wp_deregister_script('jquery');         wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js', true, '1.6.2', false);         wp_enqueue_script('jquery');     /* My Script */      if ( !is_page('contact') )             {                        wp_enqueue_script('myscript', get_bloginfo('template_url') . '/js/myscript.js', array('jquery'), '1.1', false);             }     }          }          add_action( 'wp_print_scripts', 'mypage_scripts');      The result is that the script loads on every page except on Admin (as expected) but can't manage to not load on "Contact" page. Any ideas? Of course I can list all the pages I want to load it, but as the site is going to have more pages in the future I don't want to change the functions.php file everytime a new one is created. Thanks.


How can I do a variable for meta_query?

I have a code which needs a variable compare string               array(             'key' => 'rob_value',             'value' => $rob,             'compare' => '='             )        the compare `=>'=`' needs to be `'='` to get values according a variable data from search form, but sometimes the value is null (empty) and the compare line needs to change to compare `=>'!='` I have tested changing the code manually and it works perfectly. Now I want to do the code change according the values on search form.


Multisite pagination with get_posts

I'm looking for a way to paginate my get_posts :               $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                     $args = array(                         'posts_per_page'   => 5,                         'offset'           => 0,                         'orderby'          => 'post_date',                         'order'            => 'DESC',                         'post_type'        => 'post',                         'post_status'      => 'publish',                         'suppress_filters' => true,                         'paged'            => $paged,                         );                           $query = get_posts($args);      I've been trying to get this on my own but I did not succeed. Here is my paginate function :               function my_pagination($query = false){     global $wp_query;          if ( !$query ) $query = $wp_query;          $big = 999999999; // need an unlikely integer         echo paginate_links( array(             'base'         => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),             'format'       => '?paged=%#%',             'current'      => max( 1, get_query_var('paged') ),             'total'        => $query->max_num_pages,             'type'         => 'list',             'prev_text'    => __('%s Previous','textdomain'),             'next_text'    => __('Next %s','textdomain'),         ) );     }      I call it in my template with :               if ( function_exists('my_pagination') ) my_pagination($query);      Any help would be much appreciated.


Tags Sorted By Characters?

If i put multiple tags in a post then after publishing the post all tags are auto arranged by Character Serial, like A B C D... any idea if i wish to have all tags will not sorted or arranged by Character serial.... so, first tag will be first and last tag will be placed at last... though the first tag may be start with Z and the last tag start with A .. So what is the way to keep tag serial static as i have put?


Latest 5 posts (custom post type), each post different CSS

While creating our portfolio i'd like to make a dynamic header with the latest 5/6 featured images in a row. All these posts come out of the 'apps' custom post type.

      How would I create something like this? Thanks in advance.


Set Featured Image Front Frontend Form

I have been struggling for days to figure this one out. I have successfully implemented a form to submit posts from the front end of my site. ButI can't figure out how to make the image uploads work. I want whatever image the user uploads to automatically attach to the post and become its featured image. Can someone please explain how to do this with my existing code? I have searched through all relevant questions on this forum and none of the solutions work for me.                               <?                      if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['insert_post'] )) { //check that our form was submitted                 //If it has, redirect to the dashboard                 ?> <?php                      $title = $_POST['thread_title']; //set our title                      if ($_POST['thread_description']=="") { // check if a description was entered                 $description = "See thread title..."; // if not, use placeholder                 } else {                 $description = $_POST['thread_description']; //if so, use it                 }                      $tags = $_POST['thread_tags']; //load thread tags (custom tax) into array                      $post = array( //our wp_insert_post args                 'post_title'    => wp_strip_all_tags($title),                 'post_content'  => $description,                 'post_category' => array('0' => $_POST['cat']),                 'tax_input' => array('thread_tag' => $tags),                 'post_status'   => 'publish',                 'post_type' => 'tsv_userpost'                 );                      $my_post_id = wp_insert_post($post); //send our post, save the resulting ID                      $current_user = wp_get_current_user(); //check who is logged in                      add_post_meta($my_post_id, '_your_custom_meta', $var); //add custom meta data, after the post is inserted                           } else {                      if(is_user_logged_in()) { // check that the user is logged in before presenting form                      $current_user = wp_get_current_user();                      ?>
                      <form id="new_thread" name="new_thread" method="post" action="" enctype="multipart/form-data">                      <input class="required" type="text" id="thread_title" value="" tabindex="1" name="thread_title" placeholder="Thread Title" />                      <textarea id="thread_description" name="thread_description" cols="80" rows="20" tabindex="2"></textarea>
                 <select name='cat' id='cat' class='postform required' tabindex="3">                 <option value="" selected="selected">Choose:</option>                 <option class="writing" value="90">Writing</option>                 <option class="image" value="91">Image</option>                 <option class="video" value="92">Video</option>                 <option class="audio" value="94">Audio</option>                 <option class="link" value="95">Link</option>                 </select>
                      <input type="text" value="" tabindex="4" size="16" name="thread_tags" id="thread_tags" placeholder="Tags" />
                                       Featured Image:                 <input type="file" name="user-image-featured" id="user-image-featured" size="20">
                 <input type="submit" value="Save Post" tabindex="5" id="thread_submit" name="thread_submit" class="thread-button" />                      <input type="hidden" name="insert_post" value="post" />                      <?php wp_nonce_field( 'new_thread' ); ?>                      </form>
                      <?php } else { echo 'please login'; } } ?>


Load facebook php sdk problem

I am trying to load the facebook php sdk in the wordpress template. I've added the code to the header.php file:                   locate_template( 'facebook/facebook.php', true );          $facebook = new Facebook(array(          'appId'  => appid,          'secret' => appsecret     ));          $signedRequest = $facebook->getSignedRequest();          if ( isset($signedRequest['app_data']) )     {         echo $signedRequest['app_data'];         }       But I get get this error:               Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent..      How can I load the facebook sdk before any other file is loaded


Repeated nav bar queries failing to be cached

Every time a page view occurs, wordpress is sending a complex non-indexed query below. The exact same query is sent over and over and it seems that it is being passed through some "caching" code. But why doesn't the cache actually prevent re-executing the query over and over? The query being caught, which is asked repeatedly on every page view, is:               # Query_time: 0 Lock_time: 0 Rows_sent: 320 Rows_examined: 1608     SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN      (2366,2363,4066,...etc, about 30 entries);      I noticed this using log-queries-not-using-indexes in mysql. The pertinent call stack is:   * wp_get_nav_menu_items(3) in nav-menu.php (around line 495) calls   * get_posts in post.php (around line 1461) calls   * WP-Query->query in query.php (around line 2941) calls   * WP-Query->get_posts in query.php (around line 2767) calls   * update_post_caches in post.php (around line 4454) calls   * update_postmeta_cache in post.php (around line 4474) calls   * update_meta_cache in meta.php (around 560)   * which makes the nasty SELECT statement The SELECT statement is basically getting all the info from wp_postmeta for menu items whose post_id there has term_taxonomy_id = 3 in wp_term_relationships. In other words, it's getting some metadata corresponding to the menu bar. But, why is the cache _updated_ , and db re-queried, on every single page view? I have very little clue how the cache works (I'm just starting to read about it) and that's why I'm writing here. All I can say is that the "cache_results" is automatically turned on inside of the call to WP- Query->get_posts around line 1970. That's great, but why might the cache get refreshed on every single page view? If the cache is operating as I would normally expect a cache to operate, I don't get why it keeps making this query over and over. How can I best fix the lack of effective caching? Or is this the expected behaviour? (xref: http://wordpress.org/support/topic/core-code-caching-issue-w-nav )


How can I safely use $_SERVER['REQUEST_URI'] to avoid XSS?

I've seen a lot of warnings about using `$_SERVER['REQUEST_URI']` because it can open things up to XSS, but I haven't been able to find anything confirming a safe way to use it. Some people have mentioned using `esc_url()`, but I wasn't able to find anything confirming how to safely use it. This is my best guess, would this safely prevent XSS attacks? `echo esc_url(( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);` If I want to use the URL internally rather than display it, it seems I have to use `esc_url_raw()`. Is this safe as well? `$pageurl = esc_url_raw(( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);`


Contact form won't submit

I posted this on the Stackoverflow site and haven't received much assistance with the issue. I hope that, by reposting it on here, someone could please offer me any assistance. I am creating a theme in Wordpress, using an Akismet form and a jQuery AJAX script (now using a new script). I have modified all of the relevant areas to integrate into my Wordpress site, even using the Akismet API key that is already there from the Akismet plugin. Here is my code: **Form**               <form method="post" id="contact_form">       <input id="name" type="text" name="name" tabindex="1"/> Name       <input id="email" type="text" name="email" tabindex="2"/> E-mail       <input id="website" type="text" name="website" tabindex="3" value="http://" /> Website       <textarea id="message" tabindex="4" rows="10" cols="60" name="message"></textarea>       <input type="submit" value="Send E-mail" tabindex="5" />     </form>      **jQuery**                     **PHP Script** _(now in 'functions.php', not 'inc/email.php')_               <?php         include (TEMPLATEPATH . 'inc/Akismet.class.php'); // Using require seems to stop the page from loading, but include seems to show the page.         function evetheme_sendmail( $name, $email, $website, $ip, $is_spam, $message) {         $subject = '';         if( $is_spam == true )             $subject = "[SPAM?]";          $subject .= "[Your_site.com] E-mail received from ".$name."//".$email;          //    wp_mail( get_option('admin_email'), '[WP] ' . $subject, $message, 'From: '. $name . ' <' . $email . '>');         mail( get_option('admin_email'), '[PHP]' . $subject, $message, 'From: '. $name . ' <' . $email . '>');     }     function evetheme_subconfor(){         foreach($_POST as $key=>$value)             $key = $value;             $wp_key = get_option( 'wordpress_api_key' );             $our_url = get_bloginfo( 'url' );                  $name = $_POST['name'];             $email = $_POST['email'];             $website = $_POST['website'];             $message = $_POST['message'];             $ip = $_SERVER['REMOTE_ADDR'];                  $akismet = new Akismet($our_url, $wp_key);             $akismet->setCommentAuthor($name);             $akismet->setCommentAuthorEmail($email);             $akismet->setCommentAuthorURL($website);             $akismet->setCommentContent($message);             $akismet->setUserIP($ip);                  evetheme_sendmail( $name, $email, $website, $ip, $akismet->isCommentSpam(), $message);         die();     }          // creating Ajax call for WordPress       add_action('wp_ajax_nopriv_evetheme_subconfor', 'evetheme_subconfor');     add_action('wp_ajax_evetheme_subconfor', 'evetheme_subconfor');      I have tried numerous things to get this to send emails to me. I have tried replacing the `get_option('admin_email')`, `get_option('wordpress_api_key')` and `get_bloginfo('url')` references with their respective values, but I am not receiving any emails from the script. I have tested by adding a new user to the site and the problem seems limited to the script, as I am receiving emails from the `wp_mail` function via Contact Form 7 and the main system. Could someone please help me? I am getting to my wits end here. I have tried including the form submission script on the page itself and calling it, both in the jQuery script and in the form via the `action` attribute, but in both instances it brings back a 400 server error for the permalinked page or a 500 server error on the admin-ajax.php page or with `wp_mail()`. **Note: Since using the new code, I have only had 500 server errors when loading the admin- ajax.php file, regardless of whether I use wp_mail() or mail().** I'm really lost and the only thing that is stopping me from giving up is I'm a stubborn so-and-so.


Can't set custom taxonomy terms via custom form

## Question I am creating my first plugin and in it users will be able (among other things) to create new post via custom form from wordpress backend. This post uses custom post type and custom taxonomy. Form creates new post but it fails to set custom taxomony. Creating post regularly (not via my custom form) works fine ie. allows me to add custom taxomony to it. Custom post type and custom taxonomies are registered by the book, terms are already inserted in db. * _taxonomy is not a variable for debugging purposes_                   add_action('plugins_loaded', 'newpost');              function newpost() {             if (isset($_POST['new_post']) == '1') {                 $post_title = $_POST['posttitle'];                 $post_content = $_POST['postcontent'];                 $new_post = array(                     'ID' => '',                     'post_author' => 1,                     'post_type' => 'cars',                     'post_content' => $post_content,                     'post_title' => $post_title,                     'comment_status' => 'closed',                     'ping_status' => 'closed',                     'post_status' => 'publish',                     'tax_input' => array('cars' => array('bmw', 'audi'))                 );                      $post_id = wp_insert_post($new_post);             }         }      I've even tried to remove **'tax_input'** and use **wp_set_post_terms** and **wp_set_object_terms** but results were same. Two days I'm stuck on this, so any help would be greatly appreciated... ## Solution The solution was to change **plugins_loaded** to **init** with low priority.                  add_action( 'init', 'newpost', 200 );      So the issue was that user privileges have not yet been set, upon firing the plugin.


LESS compiler for Wordpress

can I compile some .less-files automatically by using Wordpress. I found just lessphp Thanks Ogni


Count posts for each taxonomy term for each month

Cannot figured it out... I need to count how many posts there are for each taxonomy term form each month.


WP Rewrite for a custom variable

I know there are dozens of posts on this, but (I'm embarassed to say this) I'm having a rough time following them. My goal here is to have `/resources?audience=teachers` become `/resources/audience/teachers` or event `/resources/teachers`. I have 2 custom taxonomies on attachments - Types and Audiences. I then have a page titled Resources which is going to house all of the attachments within these categories. If an audience of type is specified, I will only display that term's attachments. I've tried using the following this within an `init` hook:               add_rewrite_rule(         'resources/([^/]+)/?$',         'index.php?pagename=resources&audience=$matches[1]',         'top' );      With no success. I'm sure it's a no-brainer.


Using default wordcount javascript in Wordpress on custom wp_editor() areas

I have two `wp_editor()` instances on pages and posts used to populate the sidebars of my three-column website. I would like to use the default wordpress word-count script on the two wp-editor areas to get the word-count of the content within them. I enqueued the script and added the required HTML but the wordcount was always that of the main content editor area. Has anyone managed to use this functionality with custom wp_editor areas and what HTML will I use? I have searched on the web but could not find any examples where the default script is used. Thanks in advance nav


How do I correctly transfer my site from one domain to another?

I developed our wordpress site on a subdomain, so I did not disrupt our homepage while I got everything up and running with Wordpress (It was originally running under Orchard, and I needed tochange it). After the WP site was ready I changed the Wordpress Address general setting to the correct URL, and copied all the files over. Unfortunately, it seems like this is not all that really needs to be done. Today (quite randomly, since it worked before oddly), images for a part of my site weren't showing up. Long story short it was because all of my WordPress media are pointing to the URL for them on the subdomain, NOT the core domain the site was currently running on. After doing more research in the database, I can see other references to the subdomain still in the database, such as the `posts.guid` field in the database for all posts on the site. What do I have to do to correctly move everything over to my core domain, so when I nuke the subdomain it doesn't affect the main site? I would prefer not having to completely recreate content (like re-upload images) if possible.


How to delete posts which have same title?

Some of my posts duplicate title. How to delete them ? And keep only one. Example: I have 4 post which have same title. And I want to delete 3 posts and keep one post. How to do this ? Thank you very much ! Sorry for my poor English !


What makes a placeholder resizable in Tinymce?

It's not that hard to make a plugin to TinyMCE, similar to what the Wordpress gallery is doing in WP 3.5. Unfortunately, these custom placeholders are always non-resizable, although they show the resizer handles. A new image inserted into a post is resizable with the handles, an embedded iframe is resizable, but a new gallery placeholder is not resizable (in this case it doesn't make sense, galleries don't resize). However, I need a custom placeholder that **is** resizable. Is there a special class that turns this on or off, or a function that I need to call to enable resizing on a certain element?


the_category() tag not styling HTML or CSS

I am having problems getting my the_category() template tag to style accordingly with the rest of my theme. I believe this is because the HTML isn't output the same way as the the_author() and the_comments() tags. I've looked into my category_template.php file but am having trouble identifying what exactly I need to tweak to get it to style the same. Here is my code for the category post details:                                   <a href="<?php get_category_link( $category_id ); ?>" class="post-item">                                                          <?php the_category( '•' ); ?>                               I am almost certain there is a filter I need to apply in the category_template.php page but am not sure what to change. For a visual demonstration look at http://blog.diginomics.com EDIT: I've used your advice with some success. It is falling in place and styling correctly, but now I have two category links. Take a look at the page. Here is my index.php code:               <?php the_category( '•' ); ?>      And here is my category_template.php:               $categories = get_the_category( $post_id );     foreach ($categories as $category){     echo 'term_id) . '">' . '

 ' . $category->cat_name . '';     }


Readonly input text appears unlocked while the page is loading

I need help with a code for locking editing an input of type text in the profile page of Wordpress. I added the following code:               (function(){         $("#email").attr("readonly","readonly");     });      But while the page is loading, the field appears unlocked, and if the user press 'Esc', the page loading is stopped and he can edit the field. Is there any way to avoid this?


Add classname to the_category() function?

is it possible to use `add_filter` or something similar to add the `slug` of the category as classname to the `the_category()` function? Right now when using `the_category()` the output looks like this …

             News

      Is it possible to somehow get this …

             News

      Or something similar, at least some classname with the `slug` of the category so I can select it via CSS? Thank you in advance, matt.


Exclude Child Term Posts from Parent Term Archive

I have created a custom hierarchical taxomony and when viewing a taxonomy archive page would like to only display the posts that have been assigned to that term. This works fine on the child term pages, but the parent term pages display posts assigned to them AND any child terms. I found a solution that solves this for categories by inserting the following link after the beginning of the loop:               <? if ((is_category()) && in_category($wp_query->get_queried_object_id())) { ?>      But I haven't been able to find a similar solution that works for custom taxonomies. I also tried:               function exclude_children($wp_query) {         if ( isset ( $wp_query->query_vars['custom_taxomony'] ) ) {             $wp_query->set('tax_query', array('include_children' => false));         }     }       add_filter('pre_get_posts', 'exclude_children');       But that does not seem to have any effect. So the question is, how do I do this?


How do I get the custom category URL from the custom post type?

I'm using a custom post type "portfolio" to create new posts and categories. I'm trying to retrieve the correct category/taxonomy URL from the post. I'm a couple days in on this and could really use some help. Registering post and tax below:               function portfolioposttype() {          $labels = array(         'name'               => __('Portfolio'),         'singular_name'      => __('Project'),         'add_new'            => __('Add New'),         'add_new_item'       => __('Add New Project'),         'edit_item'          => __('Edit Project'),         'new_item'           => __('New Project'),         'view_item'          => __('View Project'),         'search_items'       => __('Search Projects'),         'not_found'          => __('No projects found'),         'not_found_in_trash' => __('No projects found in Trash'),         'parent_item_colon'  => __('Parent Project:'),         'menu_name'          => __('Portfolio')     );     $args = array(         'labels'                => $labels,         'supports'              => array('title','editor','thumbnail'),         'taxonomies'            => array('portfolio-categories'),         'public'                => true,         'show_ui'               => true,         'show_in_menu'          => true,         'show_in_nav_menus'     => true,         'exclude_from_search'   => true,         'has_archive'           => true,         'rewrite'               => array('slug'=>'case-study'), //singe project slug         'capability_type'       => 'post',         'menu_position'         => 5,         'menu_icon'             => Z_BASE_URL.'functions/assets/img/icon-portfolio.png',         'query_var'             => true     );     register_post_type('portfolio', $args );          $taxonomy_portfolio_category_labels = array(         'name'                       => __('Portfolio Categories'),         'singular_name'              => __('Category'),         'search_items'               => __('Search Categories'),         'popular_items'              => __('Popular Categories'),         'all_items'                  => __('All Categories'),         'parent_item'                => __('Parent Category'),         'parent_item_colon'          => __('Parent Category:'),         'edit_item'                  => __('Edit Category'),         'update_item'                => __('Update Category'),         'add_new_item'               => __('Add New Category'),         'new_item_name'              => __('New Category'),         'separate_items_with_commas' => __('Separate categories with commas'),         'add_or_remove_items'        => __('Add or remove Categories'),         'choose_from_most_used'      => __('Choose from most used Categories'),         'menu_name'                  => __('Categories')     );     $taxonomy_portfolio_category_args = array(         'labels'            => $taxonomy_portfolio_category_labels,         'public'            => true,         'show_in_nav_menus' => true,         'show_ui'           => true,         'show_tagcloud'     => false,         'hierarchical'      => true,         'rewrite'           => array('slug'=>'projects'), //category slug         'query_var'         => true          );     register_taxonomy('portfolio-categories',array('portfolio'),$taxonomy_portfolio_category_args);          }      add_action('init','portfolioposttype');      So, from www.domain.com/case-study/sample-project-1 I need to be able to link it back to the category: www.domain.com/projects/category-1 There could be another www.domain.com/case-study/sample-project-2 that would link to www.domain.com/projects/category-2 I hope this makes sense and really appreciate any advice!


Admin menus and submenus

I created an options page for admin and displayed it as a top level menu -> `add_menu_page($themename, $themename, 'administrator', basename(__FILE__), 'mytheme_admin');` I want to add a sub menu under the top level menu I created to display exactly the same page (to be displayed as a sub menu but open this page also when user clicks the top level menu). Also I don't know how to add another theme page I created under this top level menu. I have read the wordpress documentation and couldn't make it, before asking here. Many thanks.


Gallery Shortcode: using size="full" doesn't call the actual thumbnail image size

I have my Media settings set up so that my thumbnail size is 60x60 pixels and the "Crop thumbnail" box is checked. I can see in the /uploads folder that there are in fact perfect square 60x60 thumbnails being generated for all the images are being uploaded. However, when I use the gallery shortcode like this: [gallery size="thumb"] It's not actually calling that image thumbnail file. What it is outputting instead is the originally uploaded image source file and scaling it down using width="" and height="" attributes creating a proportional scale down to 60 pixels in width like this: `<img width="60" height="45" src="/uploads/original-source.jpg" />` But I need it to be doing this: `<img width="60" height="60" src="uploads/original-source-60x60.jpg" />` Has anyone else run into this problem?


All pages are redirected to homepage if using Permalink Custom Structure

My website http://laptopre.net/ is running on WP 3.4.2. When I changed the Permalinks setting to Custom Structure - /%category%/%postname%/ , all the pages in my site are redirected to homepage. Could anyone guide me to solve this problem please. Here is content of my .htaccess file               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>     # END WordPress          ###Please Don't edit these comments or the content in between. kloxo uses this to recognize the lines it writes to the the file. If the above line is corrupted, it may fail to recognize them, leading to multiple lines.          <Ifmodule mod_php4.c>     php_value error_log "/home/admin/__processed_stats/laptopre.net.phplog"     php_value upload_max_filesize 2M     php_value max_execution_time  30     php_value max_input_time  60     php_value memory_limit  32M     php_value post_max_size  8M     php_flag register_globals  off     php_flag display_errors  off     php_flag file_uploads  on     php_flag log_errors  off     php_flag output_buffering  off     php_flag register_argc_argv  on     php_flag magic_quotes_gpc   off     php_flag magic_quotes_runtime  off     php_flag magic_quotes_sybase  off     php_flag mysql.allow_persistent  off     php_flag register_long_arrays  on     php_flag allow_url_fopen  on     php_flag cgi.force_redirect  on     php_flag enable_dl  on     </Ifmodule>          <Ifmodule mod_php5.c>     php_value error_log "/home/admin/__processed_stats/laptopre.net.phplog"     php_value upload_max_filesize 2M     php_value max_execution_time  30     php_value max_input_time  60     php_value memory_limit  32M     php_value post_max_size  8M     php_flag register_globals  off     php_flag display_errors  off     php_flag file_uploads  on     php_flag log_errors  off     php_flag output_buffering  off     php_flag register_argc_argv  on     php_flag magic_quotes_gpc   off     php_flag magic_quotes_runtime  off     php_flag magic_quotes_sybase  off     php_flag mysql.allow_persistent  off     php_flag register_long_arrays  on     php_flag allow_url_fopen  on     php_flag cgi.force_redirect  on     php_flag enable_dl  on     </Ifmodule>      Thanks, Nghiep


Using WP Query to search by multiple meta fields

I made a custom search form with select boxes and text fields. I have a select box with options like "renting" and "selling" (its a real estate site) There are also input fields for minimum and maximum price, for location etc. In the posts I have custom fields for all those filters. I used WP_Query for that. And it should work. Here is the query:               // Define the arguments for the WP query     $args = array(             'post_type' => 'post',             'relation' => 'AND',             'meta_query' => array(                     array(                             'key' => 'ex_lokacija',                             'value' => $grad ,                             'compare' => 'LIKE'                     ),                     array(                             'key' => 'ex_vrsta_oglasa',                             'value' => $adType ,                             'compare' => 'LIKE'                     ),                     array(                             'key' => 'ex_tip_nekretnine',                             'value' => $realEstateType ,                             'compare' => 'LIKE'                     ),                     array(                             'key' => 'ex_dio_pg',                             'value' => $dioGrada ,                             'compare' => 'LIKE'                     ),                     array(                             'key' => 'ex_dio_pg',                             'value' => $dioGrada ,                             'compare' => 'LIKE'                     ),                     array(                             'key' => 'et_square_footage',                             'value' => array( $squareFrom, $squareTo ),                             'type' => 'numeric',                             'compare' => 'BETWEEN'                     ),                     array(                             'key' => 'et_price',                             'value' => array( $priceFrom, $priceTo ),                             'type' => 'numeric',                             'compare' => 'BETWEEN'                     ),                     array(                             'key' => 'et_bedrooms_number',                             'value' => $roomsNum,                             'type' => 'numeric',                             'compare' => 'LIKE'                     )             )     );          $searched_posts = new WP_Query( $args );      I used preg_replace for each of the $_GET vars and assigned them to these you see in 'value'. Now, the problem is that it doesn't show anything, even if there should be results. Also, it won't work without the 's' field - something must be put in it in order to even load the empty results page. **Possible problem #1** I'm guessing there is a problem with the loop, which I created like this:                                   while ($searched_posts->have_posts()) : $searched_posts->the_post(); ?>                                            <?php the_title(); ?>                             <?php the_content(); ?>                                        <?php endwhile; ?>      That is just for testing. **Possible problem #2** I put all of this inside of one file - search.php. Maybe that is causing problems? Here it is: ‚‚               global $wpdb;          $grad           = preg_replace( '/^[0-9a-zA-Z-]/', '', $_GET['grad'] );     $adType         = preg_replace( '/^[0-9a-zA-Z-]/', '', $_GET['adType'] );     $realEstateType = preg_replace( '/^[0-9a-zA-Z-]/', '', $_GET['realEstateType'] );     $dioGrada       = preg_replace( '/^[0-9a-zA-Z-]/', '', $_GET['dioGrada'] );     $squareFrom     = preg_replace( '/[^0-9]/', '', $_GET['squareFrom'] );     $squareTo       = preg_replace( '/[^0-9]/', '', $_GET['squareTo'] );     $priceFrom      = preg_replace( '/[^0-9]/', '', $_GET['priceFrom'] );     $priceTo        = preg_replace( '/[^0-9]/', '', $_GET['priceTo'] );     $roomsNum       = preg_replace( '/[^0-9]/', '', $_GET['roomsNum'] );          // Change the defaults if not chosen     if($squareFrom == '') { $squareFrom = '0'; }     if($squareTo == '') { $squareTo = '10000000'; }          // Define the arguments for the WP query     $args = array(             'post_type' => 'post',             'relation' => 'AND',             'meta_query' => array(                     array(                             'key' => 'ex_lokacija',                             'value' => $grad ,                             'compare' => 'LIKE'                     ),                     array(                             'key' => 'ex_vrsta_oglasa',                             'value' => $adType ,                             'compare' => 'LIKE'                     ),                     array(                             'key' => 'ex_tip_nekretnine',                             'value' => $realEstateType ,                             'compare' => 'LIKE'                     ),                     array(                             'key' => 'ex_dio_pg',                             'value' => $dioGrada ,                             'compare' => 'LIKE'                     ),                     array(                             'key' => 'ex_dio_pg',                             'value' => $dioGrada ,                             'compare' => 'LIKE'                     ),                     array(                             'key' => 'et_square_footage',                             'value' => array( $squareFrom, $squareTo ),                             'type' => 'numeric',                             'compare' => 'BETWEEN'                     ),                     array(                             'key' => 'et_price',                             'value' => array( $priceFrom, $priceTo ),                             'type' => 'numeric',                             'compare' => 'BETWEEN'                     ),                     array(                             'key' => 'et_bedrooms_number',                             'value' => $roomsNum,                             'type' => 'numeric',                             'compare' => 'LIKE'                     )             )     );          $searched_posts = new WP_Query( $args );                     get_header(); ?>

                     <?php get_template_part('includes/breadcrumbs');                               while ($searched_posts->have_posts()) : $searched_posts->the_post(); ?>                                            <?php the_title(); ?>                             <?php the_content(); ?>                                        <?php endwhile; ?>
                       <?php get_sidebar(); ?>          <?php get_footer(); ?>      Thanks for viewing my problem!


Get Previous & Next posts by Post ID

How can I go about getting the previous and next posts from _outside_ the loop? Everything I try to do aside from the custom SELECT query (using `get_posts` or `WP_Query`) breaks stuff further down the page. I currently have a recursive function which will hopefully find the first "previous" post which satisfies a certain condition. I grab the first value to test from `get_previous_post()` but don't know how to get the `previous_previous_post()`.               add_action( 'wp_ajax_nopriv_myajax-submit', 'ajax_project_load' );     add_action( 'wp_ajax_myajax-submit', 'ajax_project_load' );          function ajax_project_load() {         $the_slug = $_POST['slug'];         $args=array(           'name' => $the_slug,           'post_type' => 'projects',           'post_status' => 'publish',           'showposts' => 1,           'ignore_sticky_posts' => 1         );         $my_posts = get_posts($args);         if( $my_posts ) :                  global $post;             $post = $my_posts[0];              $postCapabilityFilter = $_POST['capFilter']=='undefined' ? $_POST['capFilter'] : substr($_POST['capFilter'], 1);                  $response = json_encode( "Success" );             header( "Content-Type: application/json" );                    $next_post = get_previous_post();     function filtered_next_post($next_post){         if($next_post){             $next_slug = $next_post->post_name;             $next_ID = $next_post->ID;             global $wpdb;             global $postCapabilityFilter;             $querystr = "             SELECT $wpdb->postmeta.*             FROM $wpdb->posts, $wpdb->postmeta             WHERE $wpdb->posts.post_type = 'projects'              AND $wpdb->posts.post_status = 'publish'              AND $wpdb->posts.ID = $next_ID             AND $wpdb->posts.ID = $wpdb->postmeta.post_id             AND $wpdb->postmeta.meta_key = '_slideshow_content'             ORDER BY $wpdb->posts.post_name DESC             ";             $nextProjQuery = $wpdb->get_results($querystr, OBJECT);             foreach($nextProjQuery as $nextProj):                 $nextProjMetaArr = unserialize($nextProj->meta_value);                 foreach ($nextProjMetaArr['slides'] as $npSlideArr){                     echo 'and..';                     if ( !in_array( $postCapabilityFilter, $npSlideArr['slideCap'] ) ){                         echo 'not in it..';                         //$next_post = get_previous_previous_post();                         //filtered_next_post($next_post);                     }                 }             endforeach;                                     return $next_slug;         }     }     $next_slug = filtered_next_post($next_post);


How to check if a post is in categories x,y,z inludint their subcategories

I am trying to check whether a post is in categories X, Y, Z (including the subcategories within them). This is the piece of code I have tried in my single.php:               if ( in_category(array( '1', '2', '3', ) ) {                         echo "This post is in the selected categories or their subcategories";                                   }                     else {                     echo "this post inst in the categories or the subs.";                               }      I have also tried using the post_is_in_descendant_category (included the function from the codex above my code) but it still wont display true. Including the function This is my code I used on test 2#:                   if ( in_category(array( '1', '2', '3', ) ) || post_is_in_descendant_category( array( '1', '2', '3', ) ) ) {                         echo "This post is in the selected categories or their subcategories";                                   }                     else {                     echo "this post inst in the categories or the subs.";                               }


Open external links in a new window

Is it possible to make some sort of change or add a plugin that allows me to make every 'external' link open in a new window? Just an example: if my blog was called http//timmy.com/ and I wanted to link to http//tom.com/, it would open a new window instead of the same window, but I wanted to link from http//timmy.com/ to http//timmy.com/somewhere/ in the same window. So I want all external link from my website to another in a new window/tab, but I want every internal link, from my website to somewhere else on my website, to be in the same window/tab. Is this possible?


Explanation of the "posts_join" and "posts_fields" filter hooks?

I'm new to the "posts_" filter hooks and wanted to know a few things from those in the know:   * In this question, someone posted an answer using posts_join that took a second parameter of $query: add_filter('posts_join',array(&$this,'posts_join'),10,2); ... function posts_join($join,$query) { } Is this an instance of wp_query or something similar?   * -Same example: how would I determine the post type so that I can do custom joins for each custom post type I have on the admin side   * -What does the posts_fields filter hook do? from the example I've seen, it looks like it replaces the columns in the SELECT clause of an SQL call. Am I correct in that assumption? And does it too have more parameters that can be called?? I find some examples but I can't get any solid documentation anywhere. Thank you in advance for all answers given


Printing errors during save custom post type

I am trying to debug my save_post function and cannot get the $_POST array to print so that I can see what's being posted. Please help!               add_action ('save_post', 'save_events');          function save_events($post_id){         if (('event' == $_POST['post_type']) && ('publish' == $_POST['post_status']) && ( $_POST['original_post_status'] != 'publish' )){                     print_r($_POST);                                 //function code...                 }     }


Slider Plugins for header

I am new at wordpress. I need one header slider plugins like this Please suggest me plugins. I am use "header-image-slider" but it will not display below slider of main image. Thanks in advance


WordPress Pages into Sections edit.php PHP hack

Im currently working on a Theme for a WordPress website. The theme affectively splits the website up into three sections.               http://url.com/section1       http://url.com/section2       http://url.com/section3        I need to be able to split up Pages in the backend into these sections. So in the menu it appears:               - Pages         - Section 1         - Section 2         - Section 3      And when you go into the relevant section the "Add New Page" button would set the pages parent to be the corresponding section. I realise this is very complicated,I currently have divided the menu but need to provide functions for each menu item. Is there anyway to do this with action hooks? Or will I have to edit the core files new-post.php and edit.php?


Disable the "remember me" to wp-admin

I Look long enough to find the solution of my problem. Really, Is there any way to disable the "Remember me" to wp-admin? I want to disable it for safety reasons. Thanks in advance.


Restrict editing of a custom post type based on status and user capabilities

I have a custom post type `guest_blog` registered with `'capability_type' => 'guest_blog'` and `'map_meta_cap' => true`. I want to restrict users that do not have `publish_guest_blogs` capability from editing a `guest_blog` with `pending` status. Here is the code I was using which did not work:               add_filter( 'user_has_cap', 'wpse_user_has_cap', 100, 3 );     function wpse_user_has_cap( $allcaps, $caps, $args ) {         if( in_array( $args[0], array('edit_guest_blogs', 'delete_guest_blogs') )             && empty( $allcaps['publish_guest_blogs'] ) //user can not publish guest blogs             && ! empty( $allcaps['edit_guest_blogs'] ) ) //user can edit guest blog         {             // Load the post data:             $post = get_post( $args[2] );                  if( $post->post_status == 'pending' )                   $allcaps[$caps[0]] = FALSE;         }              return $allcaps;     }      I wrote this based on the example in Codex (user_has_cap) and some answers here on WPSE (1, 2). Then I found that `$args[0]` is asking for `edit_posts` and not `edit_guest_blogs` although I have `'map_meta_cap' => true` and `$caps[0]` is the one that has the actual required capability (edit_guest_blogs). So I changed the first line to check against `$caps[0]` instead of `$args[0]` and then it worked:               //...     if( in_array( $caps[0], array('edit_guest_blogs', 'delete_guest_blogs') )      The question is if this is the right way to do it or not, and why all the samples are using `$args[0]` and not `$caps[0]`? What is the difference between these two parameters?


Plugin: Unable to Save the Image Alignment Option to Display in the Widget in the Sidebar

I am trying to add a select option to help user align the gravatar image. The problem is all value are saved except for the Image Alignment. When they select Image Alignment, it will revert back to "None" http://pastebin.com/03fj7tc6 Any help would be highly appreciated


Retrieve current post's tags

Is it possible to use get_post() to retrieve which tags were selected in the post? I would like a way to store a single post's tags into a variable.


Functions.php error - when trying to change the theme

After trying to replace the wordpress theme , it says that the functions.php file in the theme catalogue - the last line - is not ok Parse error: syntax error, unexpected $end in ... /themes/themename/functions.php on line 1500 line 1500 is actually only symbol ?> **EDIT** ok, here is the pastebin link of the functions.php file that has error http://pastebin.com/by5TtZq6 p.s. i am wondering - since its supposed to be a ready made template - then how could it be error - its supposed to work p.s. may be its some kind of thing that can be messed up by changing wordpress settings or it uses some bad plugins ? ( like permalinks or some cache plugin etc. ) ...


Setting conditional background image from meta value

I am trying to set background image from meta value.I am successful also.But if the meta image is not set the out put

      But I do not want to show `background: url('')` if there is not meta value is set.My code to get image                       $bgimage= get_post_meta( $post->ID, 'settings_image', true );             $img=background-image: url('.wp_get_attachment_url( $bgimage ).');      To display `style="<?php echo $img;?>"` I have tried                   if(isset($bgimage)){         $img=background-image: url('.wp_get_attachment_url( $bgimage ).');         }