How to show the number of each post has been read in a while loop?

I have this code in my **header.php** and it is working:
             <?php query_posts('category_name=news'); ?>             <?php while (have_posts()) : the_post(); ?>
                     <a href="<?php the_permalink(); ?>">                     <?php the_post_thumbnail('thumbnail'); ?>                                          <a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
                                          <?php the_excerpt(); ?>
                         Author: <?php the_author(); ?> |                          Date: <?php the_date(); ?> |

                  <?php endwhile; ?>
      Now, I would like to do something like:               Views: <?php the_views(); ?> |       to show each post how many times was read. However, it is throwing an error. How to solve this?


Open attachments in new tab/window

I'm trying to make every attachment link open in a new tab/window but checking the 'Open link in a new tab' checkbox in the post editor or adding target="_blank" manually doesn't seem to work. Links always open in the same window. According to this topic the editor is stripping the target attribute. Any ideas on how I can get this to work? Thanks


Attach a private function at a hook?

I have a class with some private & public functions. The thing is that I don't want some of the functions to be able to be called outsite of the class, so I want to make them private. But I need to hook them at particular hooks and the hooks cannot call them if they are private. Is there some workaround for that?


List User Comments on User Profile BuddyPress

Does anyone know if there’s a way to create an option on the BuddyPress user profiles where it can list the users’ comments, so that the user can see a list of everything they commented on. I searched to find a plugin, but came up empty-handed.


How to prioritize a category using Yoast

Can anyone help me with prioritizing the post category on Yoast? I currently categorize each post with 2 categories (i.e. things to see and Things 100-200) but the Yoast breadcrumbs are picking up 100-200 instead of the Things to See category. does anyone know how I can choose which category Yoast displays?


RSS Feed Custom Title? (code placing)

> **Possible Duplicate:**   >  RSS Feed Custom Title? For some reason the RSS feed of my wordpress blog is repeating the site title twice without a space. "BlognameBlogname" for example. I want to change it to "Blogname" I found this answer but it doesn't say where to put the code - RSS Feed Custom Title? can anyone help me with that bit?? Thank you!


add_menu_page permissions - what am I doing wrong?

I am running a fresh install of Wordpress 3.3.2 and the only plugin enabled is one I'm developing, but I can't seem to get past a permissions issue in `add_menu_page`. With the exception of using anonymous functions instead of named functions, I'm following the documentation almost exactly. My plugin source:               <?php     /*     Plugin Name: Some Plugin     */          add_action('admin_init', function() {         add_menu_page('Some Page', 'Some Page', 'manage_options', 'some-slug', function() {             echo 'Hello, world!';         });     });          ?>      The menu link shows up fine at the bottom of the menu, but instead of "Hello, world!", I see: > You do not have sufficient permissions to access this page. I've also tried using the `administrator` capability in place of `manage_options`, but have the same results. What am I doing wrong?


Allow users to contribute images to a post

I'd like to curate, per-post, a collection of images submitted by many different users. Meaning - when a user views a post, they'll see as part of it the images that others have contributed, and will have the opportunity to contribute their own. What direction should I look in for implementing this? Thank you for you help. (I have a strong programming background, but not yet in Wordpress)


Allowing logged in users to create custom posts

I'm looking to create a site with a wide array of user contributed content. I have strong experience in programming, and I'm evaluating Wordpress for the task. My question: Having created a custom post type, can I allow a broad array of users (not necessarily per-approved or know to me) to create and manage their own instances of that custom post type?   What's the best way to go about this? Is there a front end for that creation, or do they need access to the admin? Thanks for any help.


Wordpress asking FTP Details

When i attempt to upload my plugin, WordPress asks for my FTP Credentials. After entering them, WordPress returns the error: > Failed to connect to FTP Server ftp.domain.com:21 but my FTP Credentials are set and work fine when connecting with FileZilla. i also tried to put my credentials in `wp-config.php` but the same issue is still occurring. > define( 'FTP_USER', 'username' ); > > define( 'FTP_PASS', 'password' ); > > define( 'FTP_HOST', 'ftp.example.org:21' ); and i also tried using: > define('FS_METHOD', 'direct'); after putting this , error shows that > Could not create directory I also reset my hosting CPanel by submitting a support ticket to my web host. they reset my CPanel to its factory settings, but the problem is not resolved. What else can I attempt for troubleshooting?


$wpdb and MySQL Create Trigger

Do `$wpdb`'s methods not accept a MySQL `CREATE TRIGGER` query? I tried it with `$wpdb->query( $sql_trigger )` over and over again without success. Throwing the create-trigger-query on phpMyAdmin the trigger is created, so the query seems to be fine.               $sql_trigger = "DELIMITER //                     CREATE TRIGGER triggerName                     BEFORE UPDATE                     ON `table_name`                     FOR EACH ROW                     BEGIN                         IF NEW.amount < 0 THEN                             SET NEW.amount = 0;                         ELSEIF NEW.amount > 100 THEN                             SET NEW.amount = 100;                         END IF;                     END; //                     DELIMITER ;                     ";      Just read EddyR used mysqli to create his trigger. http://wordpress.stackexchange.com/a/34653 Is there no way to use WP's 'native functions' to create a mysql trigger or am I doing something wrong? **edit:** Separating the DELIMITER settings and the query like this (or even changing the DELIMITER from `//` to `$$`)did not change anything. still the same issue.               $sql_before_trigger = "DELIMITER $$";     $sql_after_trigger = "DELIMITER ;";          $wpdb->query( $sql_before_trigger );     $wpdb->query( $sql_trigger );     $wpdb->query( $sql_after_trigger );


Send button using own contact form

I have an own contact template here , und built it according to this info. The submit button does not work because another event seems to block the reload of page. Looking in the console, I see an xml http post request which I do not want. Can you help to find the js code that blocks the reload. Should I post the header.php or the page-contact-us.php? Contact form 7 is installed, do I have to drop the plugin? I used contact form 7, but would like to change the required property of a field dynamically: if the checkbox is clicked, the address fields should change from non-required to required. This can be done with php, but I dont know how to change the php code of cf7


Distinction on meta value on pre_get_posts

I've got a special "position" meta field for posts which can be between 0 and 37. 0 Is ignored, and everything else can have obviously any number between and including 1 and 37. But this of course means that multiple posts can have the same number. Now I'm trying to select only the latest entry from these duplicates, however, I'm not having any luck. These are the hooks I've applied to achieve what I get at the moment:               add_action( 'pre_get_posts', 'foo_pre_get_posts' );     function foo_pre_get_posts( $query ) {         if (!is_admin() && is_home() && is_a( $query, 'WP_Query' ) && $query->is_main_query() ) {             $query->set( 'meta_key', '_position' );             $query->set( 'posts_per_page', 37 );             $query->set( 'meta_value', '0' );             $query->set( 'meta_compare', '>' );             $query->set( 'paged', 1 );         }     }          // order the stuff on meta value and then post date since pre_get_posts can't do it.     add_filter("posts_orderby", "foo_posts_orderby");     function foo_posts_orderby( $orderby) {         if (!is_admin() && is_home()) {             return "wp_postmeta.meta_value+0 ASC, wp_posts.post_date DESC";         }         return $orderby;     }          add_filter("posts_groupby", "foo_posts_groupby");     function foo_posts_groupby( $orderby) {         if (!is_admin() && is_home()) {             return "wp_posts.ID, wp_postmeta.meta_value";         }         return $orderby;     }      The SQL generated:               SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID     FROM wp_posts         INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)     WHERE 1=1  AND         wp_posts.post_type = 'post' AND         (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') AND         ( (             wp_postmeta.meta_key = '_position' AND             CAST(wp_postmeta.meta_value AS CHAR) > '0'         ) )     GROUP BY wp_posts.ID, wp_postmeta.meta_value     ORDER BY wp_postmeta.meta_value+0 ASC, wp_posts.post_date DESC LIMIT 0, 31      I tried a groupby, to no avail, tried playing around with `DISTINCT` directly in phpMyAdmin (copying the generated SQL of course), again, to no avail. The results I get:               [ ID ] [ position ] [ date ]       1         1         12/08/2012       4         1         07/08/2012       5         1         06/08/2012       6         2         08/08/2012       9         2         07/08/2012       8         5         09/08/2012      Note: this is just test data How can I make it select only the first option based on position so something like this:               [ ID ] [ position ] [ date ]       1         1         12/08/2012       6         2         08/08/2012       8         5         09/08/2012      Thanks!


What approach should I take for this URL structure?

For a website I am developing I have to create two pages with listings of courses. The first page is a "Trainings" page while the other page is "Coaching". I would like to use a single custom post type for the content of the courses, because this will be the same for the all the courses on the Trainings and Coaching listings. I also need to assign each courese to a sub category. These sub categories will only be used to display the courses in separate columns on the Trainings and Coaching pages, but the user should be able to specificy the sub category for each course, however, a course should only be allowed to have a single sub category. The URL structure I would like to have is the following: `Trainings > Training category 1 > Training one ==> /trainings/training-one` `Trainings > Training category 2 > Training two ==> /trainings/training-two` `Coaching > Coaching category 1 > Coaching one ==> /coaching/coaching-one` `Coaching > Coaching category 2 > Coaching two ==> /coaching/coaching-two` I am new to Wordpress so I would like to know what would be the correct Wordpress way to go about this.


How to point "add_menu_page" to HTML file rather than PHP function

I added a new menu item for my plugin like this:               add_menu_page(       'Control Panel',       'My Plugin',       'manage_options',       'control-panel',       array($this, 'control_panel_page'),       plugins_url('/images/menu_icon.png', __FILE__)     );          public function control_panel_page() {       // My HTML goes here     }      However, I feel uncomfortable with the fact that all my HTML resides in PHP function (`control_panel_page`). Is there an option/hack to point to HTML file rather than PHP function?


Assign single template to multiple custom post types?

I have a number of custom post types that I would like to display with the same template which I have created initially as `single-photography.php` in my theme. Is there any way to assign this template to multiple custom post types? I understand I can probably do this within the `single.php` file with a conditional include based on `get_post_type()`, but I'm wondering if there is a better way?


How can I modify the media upload form fields?

I would like to add a line of text under the description field in the media edit form to give users more direction as to how to fill out this field. What is the best way to do this? I know how to add form fields, but can't seem to figure out how to modify existing ones. I added               unset($form_fields['post_content']);       but for some reason this doesn't seem to remove the default description field. Thanks!


About pro paypal express

For our WP website http://www.interlinguals.com we want to use Paypal Express as part of our Ready Ecommerce plugin. We added the API and all credentials in the Paypal plugin part, but we cannot seem to connect the Paypal Express with the Ready Ecommerce plugin. Following instructions on http://docs.readyshoppingcart.com/paypal-express-plugin-configuration/ we followed the steps within the section Setup Paypal Express. In the WP Dashboard > Ready Ecommerce > Options > Payments it mentioned the Paypal Express PRO, so on the right side it said 'get it!'. We bought it, unzipped the file and tried to see if we could follow the next steps on the instructions. Now having arrived at the section Configure Gateway we still cannot find the 'Lable' option for this gateway neither the next steps. We tried adding the unzipped files through the ready ecommerce plugin folder using the FTP client. Still no result on the WP Dashboard Ready ecommerce Options > Payments screen. Also, the WP Paypal section doesnt give an option to connect PayPal with Ready Ecommerce. How can we make the Paypal Express to work? Thanks for your help!


allow BOTH post slug and meta key value in permalink for custom post type

I want to pull up a custom post type called `Schedule` whether the permalink uses the post slug OR a value stored in the post's meta values. E.g. `/schedule/jims-schedule/` and `/schedule/67sGHGj54hjs/` need to pull up the same post. A little more info so you understand why I'm doing this:   * The reason for the funky meta value "id" and corresponding permalink is that it's the link you can use to share with whoever you want so they can pull up your schedule, so I don't want to just use slugs because they could be easy to guess.   * using the default permalink with post slug needs to be something that only the signed-in post author can use to view the Schedule. They'll have options to modify and manage the schedule on the front-end.


Shortcode inserts paragraphs before and after executing shortcode

When my shortcode is executed, it inserts a `<p></p>` before and after the shortcode. My shortcode is the only thing in the text editor of the page. There is not a newline before or after my shortcode. Here's my shortcode functions:               //* Shortcode for child pages     function list_sub_pages( $atts ) {              extract( shortcode_atts(array('page' => 'home', 'display' => 'excerpt', 'show' => '3', 'speed' => '10'),$atts));                  $page_id = get_page_by_path($page);              switch ( $display ) {             case 'excerpt':                 $content = display_page_excerpt($page_id, (int) $speed);                 break;             case 'kids':                 $content = display_child_pages($page_id, (int) $show, (int) $speed);                 break;             case 'blog':                 $content = display_blog_posts((int) $show, (int) $speed);                 break;             default:             break;         }                   return $content;     }     add_shortcode('group', 'list_sub_pages');          function display_page_excerpt( $page_id = 1, $speed = 10 ){         $page_data = get_page($page_id->ID);              $output = '
post_name.'">';         $output .= '
post_name.'-bkgd" data-type="background" data-speed="'.$speed.'">

';         $output .= '
post_name.'">'.$page_data->post_excerpt.'
';         $output .= '

';                  return $output;     }          function display_child_pages( $page_id = 1, $show = 3, $speed = 10 ){         global $post;              //query subpages         $args = array(             'post_parent' => $page_id->ID,             'showposts' => $show,             'post_type' => 'page',             'orderby' => 'menu_order',             'order' => 'ASC'         );         $subpages = new WP_query($args);              // create output         if ($subpages->have_posts()) :             $output = '
post_name.'">';             $output .= '
post_name.'-bkgd" data-type="background" data-speed="'.$speed.'">

';             $output .= '
post_name.'-title home-titles">post_name.'">';             $output .= get_the_title($page_id->ID);             $output .= '

post_name.'">';             while ($subpages->have_posts()) : $subpages->the_post();                 $output .= '
post_name.'-link">
post_name.'-info">
post_name.'-img">'.get_the_post_thumbnail($page->ID,'icons').'

'.get_the_title().'

post_name.'-excerpt">'.get_the_excerpt().'

';             endwhile;             $output .= '
';             $output .= '

';         endif;              // reset the query         wp_reset_postdata();              // return something         return $output;     }          function display_blog_posts( $show = 3, $speed = 10 ){              $output = '
';         $output .= '

';         $output .= '
Recent News

';              $args = array(             'numberposts' => $show,             'order' => 'post_date',             'order' => 'DESC',             'post_status' => 'publish'         );           $posts = wp_get_recent_posts($args);         foreach( $posts as $post ){             $post_id = $post["ID"];                  $output .= '

'.$post["post_title"].'

'.$post["post_excerpt"].'

 ';         }              $output .= '
';         $output .= '

';              // reset the query         wp_reset_postdata();              return $output;     }      Here's what the HTML mark up looks like from my browser. ![enter image description here](http://i.stack.imgur.com/OWV3y.png) So, I'm in need of figuring out where these rogue paragraphs are coming from. Any insight would be greatly appreciated. Thanks!


Common page width?

I just made a new wordpress theme for a code type site, I am currently at 920px wide, I am curious what most people are using for a width now days, I would like to go wider but I just want to know if there is any kind of standard or common width that most people use?


How to list first (etc. 5) posts as new?

I am looking for a plugin or a way to list first five posts as new. It should be just a small picture added in the index.php. Any ideas of how I could achieve this? Thanks!


What filter should I use to insert a button inside on Media>Add New

I am adding a new way to upload a media file to WordPress. So I am looking for a way to add a link or a button to the Upload New Media page. What is the recommended filter? Or is there another better solution to add a button? Here is a screenshot of what I am trying to accomplish: ![enter image description here](http://i.stack.imgur.com/SZ359.png) I added a button named: "Other Option". I also added: "Another option: Other Option". On top of Maximum upload file size...


Difference between an archive and a page listing posts

I am wondering what is the difference between a wordpress archive page, and just a page template listing out posts? Right now I have a custom archive page, listing all entries of a custom post type. This could very well have been handled by just a normal page. Right now I am going to list out all blog posts (not on the front page, but as a `news` option in the menu), and I am wondering if I should use an archive page or create a page template that lists out posts. What is the different in intent for these pages?


Cannot install plugins on Centos VPS

I am unable to install plugins on my Centos 6 VPS. When I attempt the install I get this: > Installing Plugin: BotDetect WordPress CAPTCHA 3.0.Beta1.7 > > Downloading install package from   >  [web path to:]botdetect-wp-captcha.zip…   >  Unpacking the package…   >  Could not create directory.   >  Return to Plugin Installer UPDATE: This seems to have something to do with permissions -- I'm guessing there's some group that wordpress needs to be part of in order to change folders, create files, etc., but I can't figure out what that group should be. I have no www-data group -- I read something somewhere about this being a requirement. Can somebody tell me what groups and permissions need to exist for WP to operate? UPDATE: I have chmodded the permissions to my plugin and uploads folders to 777. I also have created an FTP user specifically for Wordpress and made the home directory for that user the same as my Wordpress root folder as recommended HERE. I then changed these lines in the wp-config.php file from:               /** Absolute path to the WordPress directory. */     if ( !defined('ABSPATH') )         define('ABSPATH', dirname(__FILE__ . "/"));          /** Sets up WordPress vars and included files. */     require_once(ABSPATH . 'wp-settings.php');      to:               /** Absolute path to the WordPress directory. */     if ( !defined('ABSPATH') )         define('ABSPATH', dirname(__FILE__));          /** Sets up WordPress vars and included files. */     require_once(ABSPATH . '/wp-settings.php');      This should eliminate the double slash conflict mentioned HERE. Note -- I was also having a problem uploading media but that issues was resolved with the chmod to 777. Now when I try to install a plugin I get this:               Unable to locate WordPress Plugin directory.          Return to Plugin Installer


orderby in WP_query doesn't works

I thought that this already works but now I tested it and it seems that it no longer works.   I have this code:               wp_reset_query();     $args=array(         'posts_per_page' => 3,         'meta_key' => 'info_tab_1',         'orderby' => 'meta_value_num',         'order' => 'DESC'                );     $info_tab = null;     $info_tab=new WP_Query( $args );      `print_r($args);` prints:               Array (        [posts_per_page] => 3        [meta_key] => info_tab_1        [orderby] => meta_value_num        [order] => DESC      )      `print_r($info_tab);` prints:               WP_Query Object (        [query_vars] => Array (          [posts_per_page] => 3          [meta_key] => info_tab_1          [orderby] => title          [order] => ASC          [error] =>          [m] =>          [p] => 0 ...


Understanding WordPress Search

I am trying to create a custom search similar to the one on totaljobs.com but through a WordPress site. Essentially I would be able to search for both search terms and location simultaneously. The way it's working now is that there is a search term field and then there is also a location search. They are two separate fields. For the search term field, I'm using the standard WordPress search and for the location search I am taking the jobs latitude and longitude and a radius setting and running them through the Google Maps API. As you can see, the search process is quite different on both searches. I've added custom fields to the posts for latitude and longitude and am querying them in the database for my search. What I don't know is how the standard WordPress search works. Is it looking in the post_content and post_title field, etc.? I can't seem to find the server side code to investigate it because the search.php is more of a generic loop code. I've found that $s is the global variable for search term but I can't find where that variable is being processed and am interested in how the database uses that variable because I think I'll need to build around the current WordPress search info. I appreciate the help. Thanks!


Don't load the theme for a page FROM a plugin EDITED

I'm developing a pseudo admin area for my client and they don't want the theme overlaid on it, rather have their admin area take up 100% of the page. Normally I would add `if (!is_page($id))` and be done with it however this admin area is part of a plugin that will be used on multiple sites and I would rather not be adding that line of code to every site that is created with this plugin. Essentially, is there a function akin to `use_theme(false)` that I can use as part of my plugins shortcode? **EDIT** Is it possible to call `define('WP_USE_THEMES', false);` from a plugin file? I have tried adding it to the top of my short codes function but to no avail. This is leading me to believe that the template is called before the plugins meaning by the time you get to calling plugins it's too late? **EDIT 2** I have had luck creating a page template using this plugin however it is still loading the page css. My template file is listed here on pastebin. The page still shows as if the theme is being called in it's entirety. I am fairly certain it's been called because the plugin is no longer outputting an incorrect `plugin_dir_path` which it was doing due to hierarchy fun.


Can Categories be used to hack a Multisite-like setup w/ a single MySql db?

I have a project which will effectively create multiple blogs that will be fed existing content (don't worry, this isn't copyrighted content from other blogs or anything like that). From a DB management and moderator point of view, and to limit hosting costs, I would like to avoid the built in multisite functionality which requires a separate DB for each blog. I am wondering whether, with some intelligent duct-tape hacking, it is feasible to run multiple blogs in one WordPress blog that appears as many separate blogs. I think that Categories might be hijacked to make this work. Basically each separate "blog" is a separate category. Is there anyone who has done this or has another, single DB multi blog approach (using WordPress)? Words of wisdom or caution about the kind of tweak I am suggesting?


Child theme within a child theme?

I'm developing a child theme, but also want to make it possible for that child theme to have a custom functions.php file that won't be overwritten during theme updates .. is this possible in any manner?


How does WP media uploader create the 3 different sized images, and how can I duplicate it

I have finally!! got this thing I've tried about 12 times to make and 12 different ways, but finally got it to work,... sort of. I made a custom metabox for uploading and attaching images to posts, and it doesn't require you to use the horrible thickbox media uploader built into WP. I hate that thing. No, what I've done is just a group of inputs (title, description, file), which you can also duplicate, to add additional attachments if you want. So you fill in the fields, select an image to upload, and save draft or publish the post. Once there are attachments added to a post, the metabox will display the input fields, along with a preview image of the attached image for each attachment you added. The title and description fields are used to generate the file meta data, nothing is saved as the post_meta, that I know of. That's currently all that I have gotten working so far. I need to make it so that when you save/publish a post, inturn upload/create the attachment files, it will create the three image sizes as the default wp uploader would, thumbnail, medium, large, and keeping the full size image too. If that's possible somehow. If not, I would like to otherwise use add_image_size() to create/define new custom sizes, and generate them that way instead, upon uploading. I'm not sure which function is the most ideal to use in this case, maybe the image_make_intermediate_size() function would be better, or wp_create_thumbnail() or wp_crop_image()... who knows!! I cannot figure out how to go about doing that, if I need to run the wp_handle_upload() function for each one, or maybe something involving the wp_generate_attachment_metadata() function. It's confusing to me since the 3 image sizes are to be associated as variants of the same attachment, and how to go about doing that. I have scoured the web, read the source of every wp media/upload/image related file, and played with just about every function there is for the media upload stuff and cannot find how WP creates the 3 image sizes anywhere, or how to do it myself. In wp-includes/media.php the image_resize() function looks like it would be best since it's exactly what it should be. I just can't figure out for the life of me what the hell I'm missing or have tried doing but did wrong to make the image thumbnails. Here's my working function that does the wp_handle_upload() stuff and things, but it also needs to create the 100px thumb, and make a resize version of the image that is max-width like 500px, and saved as new files of the uploaded one.               function update_attachment(){       global $post;            wp_update_attachment_metadata( $post->ID, $_POST['a_image'] );            if( !empty( $_FILES['a_image']['name'] )) { //New upload         require_once( ABSPATH . 'wp-admin/includes/file.php' );              $override['action'] = 'editpost';         $url = wp_handle_upload( $_FILES['a_image'], $override );              // $medium = image_make_intermediate_size( $uploaded_file['url'], 500, 400, true );         // $thumb = = image_make_intermediate_size( $uploaded_file['url'], 100, 100, true );              if ( isset( $file['error'] )) {           return new WP_Error( 'upload_error', $file['error'] );         }              $array_type = wp_check_filetype         $allowed_file_types = array('image/jpg','image/jpeg','image/gif','image/png');              $name_parts = pathinfo( $name );         $name = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] )) ));              $type = $file['type'];         $file = $file['file'];         $title = $_POST['a_title'] ? $_POST['a_title'] : $name;         $content = $_POST['a_desc']              $post_id = $post->ID;         $attachment = array(           'post_title' => $title,           'post_type' => 'attachment',           'post_content' => $content,           'post_parent' => $post_id,           'post_mime_type' => $type,           'guid' => $url['url']         );                   // Save the data         $id = wp_insert_attachment( $attachment, $_FILES['a_image'][ 'file' ]/*, $post_id - for post_thumbnails*/);              if ( !is_wp_error( $id )) {           $attach_meta = wp_generate_attachment_metadata( $id, $uploaded_file['url'] );           wp_update_attachment_metadata( $attach_id, $attach_meta );         }         update_post_meta( $post->ID, 'a_image', $uploaded_file['url'] );       }     }      Anyone able to help me finally fix this so it works proper would be loved. I've spent so many ridiculous countless hours numerous different times trying to develop this thing and the documentation sucks, and there's not really any good posts anywhere on how to do it. Thanks


Plugin to remove Admin menu items based on user role?

I searched high and low for a plugin that can remove/hide Admin menu items , including custom post types and taxonomies, based on user role. Every one I have tried only does a global hide, not based on user role. Other more complex ones like adminize do not display custom post types or taxonomies. Do I have to write my own function or is there a simple plugin I am overlooking?


Plugin Upgrade Strategy

Reading register_activation_hook() told me that in wordpress 3.1, this will only work for every plugin activation, not plugin upgrade. What I want to know is, what's the best plugin upgrade strategy? My though is:   1. on action 'admin_init' check for '{plugin_name}_version' option      1. if '{plugin_name}_version' doesn't exist, let's assume it's from previous version (because at that version, we don't have '{plugin_name}_version' option, yet. Go to process 2.     2. if '{plugin_name}_version' option exists and doesn't match with '{plugin_name}_version' set in script, go to process 2.     3. if '{plugin_name}_version' option match with '{plugin_name}_version' set in script, exit process.   2. launch our plugin upgrade function with '{plugin_name}_version' value as parameter   3. do whatever needed for this upgrade process   4. after upgrade process finished, set '{plugin_name}_version' option to '{plugin_name}_version' from script. Any comment for this process?


Filter Categories widget to allow custom sorting?

Man, I can't seem to ever get done with enhancements to WordPress categories. I hope there's more work done on core category options in the future. Especially with the emergence of site theming and siloing of late. I know WP is ahead of most publishing systems in terms of its early support for categories, but it seems they've left lots on the table after that. Does a hook exist that would allow one to enhance the widget options for the category widget in order to allow setting the default sort order? Also, I notice in the codex the options for sort appear to be one of any of these (id, name, slug, count, group) and either ascending or descending. So, Ideally a drop down menu on widget options panel to allow one to set those two parameters (order and orderby) is what I'm looking to do. Otherwise, I'll just filter wp_list_categories and add the order option to my theme options, but it seems more logical to put it on the widget control itself.


How to Make Multiple Pages Display Previous 2 out of 10 Next

I'm using wp_link_pages to split my post into multiple pages. I want to achieve something like this. Please help me with the exact codes. Thank you so much in advance. ![Display Previous count and Next Page](http://i.stack.imgur.com/fQMKx.png) Here's my code so far **Functions.php**               add_filter('wp_link_pages_args','add_next_and_number');     function add_next_and_number($args){         if($args['next_or_number'] == 'next_and_number'){             global $page, $pages, $numpages, $multipage, $more, $pagenow;             $args['next_or_number'] = 'number';             $prev = '';             $next = '';             if ( $multipage ) {                 if ( $more ) {                 $i = $page - 1;                 if ( $i && $more ) {                     $prev .= _wp_link_page($i);                     $prev .= $args['link_before']. $args['previouspagelink'] . '';                 }                 $i = $page + 1;                 if ( $i <= $numpages && $more ) {                     $next .= _wp_link_page($i);                     $next .= $args['link_before']. $args['nextpagelink'] . '';                 }             }         }         $args['before'] = $args['before'].$prev;         $args['after'] = $next.$args['after'];         }     return $args;     }      **single.php**               wp_link_pages(array('before' => '
', 'after' => '
', 'next_or_number' => 'next_and_number'));        That code displays page links as numbers like this: 1, 2, 3, 4 I want it to look like this: 2 of 4


Can't get rewrite rules working

Basically I want to rewrite: /edit/test-post to an existing page with a parameter: /edit?e=test-post From the examples in the Codex I created:               add_filter( 'rewrite_rules_array','my_insert_rewrite_rules' );     add_filter( 'query_vars','my_insert_query_vars' );     add_action( 'wp_loaded','my_flush_rules' );          // flush_rules() if our rules are not yet included     function my_flush_rules(){         $rules = get_option( 'rewrite_rules' );              if ( ! isset( $rules['(edit)/(\d*)$'] ) ) {             global $wp_rewrite;             $wp_rewrite->flush_rules();         }     }          // Adding a new rule     function my_insert_rewrite_rules( $rules )     {         $newrules = array();         $newrules['(edit)/(\d*)$'] = 'edit?&e=$matches[2]';         return $newrules + $rules;     }          // Adding the id var so that WP recognizes it     function my_insert_query_vars( $vars )     {         array_push($vars, 'e');         return $vars;     }      However, I simply cannot get it working, what am I doing wrong? Thanks!


Basic installation questions

I've downloaded WordPress and I want to ensure I'm uploading it to my server correctly:   1. I see there's a .zip file and a .tar.gz file -- which should I use? It's an Apache server. This is the place my site will be: http://plowtoplate.com/   2. I want the site to be at http not at www., but I do want either the site to also be visible at www. or for the www. to redirect to http -- where should I upload the WordPress files? Into public_html? or just into the place I get to when I login with ftp? (the 'root' I think that's called...?)   3. Do I unzip wordpress-3.2.1.zip and upload those files, or do I upload the .zip to the server?   4. Once the files are uploaded, is there anything else to do before it's ready to go?   5. How do I get the username and password to login to the admin panel so I can build the site? And what url do I go to to login? Beginner questions, I know. I appreciate help. Thanks, Richard


Specify what to do for a specific image number of the post

I want to specify for the images of my post - if is number x, output this, else if is number y output this instead, etc. I'm trying make specific treatments to my 1st, 4th, 9th images for that post. This code below is the code i'm using to just simply output all of my images for the post. Any ideas?               <?php $images = get_post_meta($post->ID, 'rw_postpage_images');  ?>     <?php foreach ($images as $att) {     $src = wp_get_attachment_image_src($att, 'full');     $src = $src[0];      $image_path =  thumbGen($src,80,80,"crop=1&halign=center&valign=center&return=1");     ?>

     <img src="<?php echo $image_path; ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" width="80"  height="80"/>

     <?php } ?>


Problems with loop

I have this loop in my index.php:                     <?php if (have_posts()) :               while (have_posts()) :                 get_template_part( 'post' );               endwhile;             endif; ?>      which calls this template               <?php         ?>      <h2 id="post-<?php the_ID(); ?>">      <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">      <?php the_title(); ?>
      <?php the_post();      the_content(); ?>
<?php the_time('l, j F Y'); ?>
      <?php trackback_rdf();     ?>      The loop behaves strangely printing out titles and posts in this order:   * Title post #1   * Content post #1 (and this is ok, but then...)   * Title post #1   * Content post #2   * Title post #2   * Title post #3 (and so on...) What am I doing wrong?


Catch 404 errors in nested installations

I have a site at the root of my `/http/` folder (I'm using Apache). In a subfolder, I have another WP site. When a 404 is encountered within the subsite, like this:               www.mysite.com/subsite/thisDoesntExist/      the 404 page for `www.mysite.com` comes up - instead of the 404 for `www.mysite.com/subsite/` Can I make the subsite catch these 404 errors?


How to set a static html front page

I'm trying to set a wordpress static HTML front page, which doesn't seem trivial. I tried three approaches: 1) add a index.html, and rename index.php to blog.php. Change the permalink into custom: `/blog.php?p=%postid%`. However for handling categories, the generated link is `/blog.php?p=cat=3`. 2) add a index.html, and rename index.php to blog.php. Change the installation position into `www.mydomain.com/blog.php` in my dashboard. This time it direct to `www.mydomain.com/blog.php/?p=123`. 3) add a page and set it to be displayed as frontpage in my dashboard/settings/reading. However for this solution, I don't know how to change the overall html of a page edited in wordpress. I can only modify the html for the body but I need to change it whole. Any suggestions?


problem using ajax url

I've got a `js` file like this:               var category = [];     var genre = [];     var type = [];     var mainContent = jQuery('#content');     var siteURL ="http://" + top.location.host.toString();         var URL = siteURL + "/?category="+ category +"&genre=" + genre +"&type="+ type +" #content";          jQuery('.ajax-cb').each(function() {         jQuery(this).click(function() {                      mainContent.load(URL,function(){                                     mainContent.animate({opacity: '1'});             });                            });          });       It does load `GET[]` parameters to change the loop, in the theme's `function.php` I've got:               function pre_selected_results() {       $taxquery = array(           'relation' => 'OR',           array(             'taxonomy' => 'category',             'field' => 'slug',             'terms' => $_GET['category'],             'operator'=>'IN'           ),           array(             'taxonomy' => 'genres',             'field' => 'slug',             'terms' => $_GET['genre'],             'operator'=>'IN'           ),           array(             'taxonomy' => 'types',             'field' => 'slug',             'terms' => $_GET['type'],             'operator'=>'IN'           )                                                );       $stack[] = "dog";       $the_query = new WP_Query($myquery);       while ($the_query->have_posts()) :        //the loop            //I then collect info from the loop displayed                 $args = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'slugs');       $results = wp_get_post_terms(get_the_ID(),'category',$args);             foreach ($results as $result){               array_push($stack, $result);           }       endwhile;     /*And I use wp_localize_script(); to send $stack back to js*/       wp_enqueue_script( 'feedback' );       wp_localize_script( 'feedback', 'jsdata', $stack);     }; //end of pre_selected_results      On my home page I call `pre_selected_results();` the loop display fine and refresh, but `$stack` only refresh if I edit the URL with `GET[]` manually in the browser, otherwise it just return 'dog', anything obvious to you that I'm missing?


Image upload and path to custom field

I build a script, to post from frontend. There are many custom-fields. Most works fine, but with one thing i have problems. First a description, then the script. It seems like, that images won't upload, cause i can't find them in the upload-directory or anywhere else. The cutom-field will be generated, that's no problem. I say that, cause the field appears at the backend - but empty. I think it's empty, cause it doesn't upload. Yes, for testing i have put 777 to my serversettings for the upload-directory, so i think the server is not disabling the upload. P.S.: I shortened the code to make it clear. If you want the hole code, just say a word. Thank you for helping!               if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&  $_POST['action'] == "new_post") {         // Funktion zum Image-Upload, falls sie noch nicht existiert         if ( ! function_exists( 'wp_handle_upload' )) {              require_once(ABSPATH . "wp-admin" . '/includes/image.php');             require_once(ABSPATH . "wp-admin" . '/includes/file.php');             require_once(ABSPATH . "wp-admin" . '/includes/media.php');         }              // Variablen für die Bilder         $image_1_gesucht = wp_handle_upload( $file['image_1_gesucht'] );         $image_2_gesucht = wp_handle_upload( $file['image_2_gesucht'] );              // Benutzerdefinierfte Felder für die Bilder         add_post_meta($pid,'image_1_gesucht',$image_1_gesucht['url']);         add_post_meta($pid,'image_2_gesucht',$image_2_gesucht['url']);     }          <form id="new_post" name="new_post" method="post" action="" enctype="multipart/form-data">
             <fieldset class="images">                 Bild 1:                 <input type="file" name="image_1_gesucht" id="image_1_gesucht">             </fieldset>

             <fieldset class="images">                 Bild 2:                 <input type="file" name="image_2_gesucht" id="image_2_gesucht">             </fieldset>
     </form>


Custom counter when link is clicked in Wordpress

I would like to monitor the number of times a user clicks the hyperlink assigned with a class name link_counter. I'm using jQuery and PHP to do this, for example:                   $('.link_counter').click(function() {            <?php           //Retrieve the current count from dB              @countdata = $wpdb->get_var($wpdb->prepare( "SELECT counter FROM $mycustomtable WHERE my_user_id=%d",$user_id));              //increment counter              $updated_count=$countdata+1;              //update back the dB table              $wpdb->query($wpdb->prepare("UPDATE $mycustomtable SET counter=%d WHERE my_user_id=%d",$updated_count,$user_id));         ?>              });      It works well. However the only issue is when there are more than one link page having the same class. If I click on the another link on that the same page, the count would not be updated. How do I modify my code and my query to update this count without using AJAX and not reloading the page? Thanks.


WP_Query arguments: Loop through custom post type - get all entries except excluded meta_key?

Can't seem to find out what I'm doing wrong.               $args = array(          'post_type' => 'wr_event', // my custom post type         'posts_per_page' => -1, // show all posts          'meta_query' => array(               array(                  'key' => 'event_announced', // a custom field either "on" or "off"                  'value' => 'on',                  'compare'  => 'NOT IN'                  )         )     );     $loop = new WP_Query( $args );      So all I want to do is loop through all `wr_events` but if an event has the custom field `event_announced` (a checkbox) checked I'd like to exclude it. Ideas? I tried setting "on" or "off" for the `value` and tried different solutions for `compare`


Can't change theme name

I am developing a theme and it currently has no theme information. Right now it is pulling it's name from the theme folders name and the "Author"is anonymous. I tried changing it by adding code into the style.css as such:               /*     Theme Name: Twenty Twelve     Theme URI: http://wordpress.org/extend/themes/twentytwelve     Author: the WordPress team     Author URI: http://wordpress.org/     Description: The 2012 theme for WordPress is a fully responsive theme that looks great on any device. Features include a front page template with its own widgets, an optional display font, styling for post formats on both index and single views, and an optional no-sidebar page template. Make it yours with a custom menu, header image, and background.     Version: 1.1     License: GNU General Public License v2 or later     License URI: http://www.gnu.org/licenses/gpl-2.0.html     Tags: light, gray, white, one-column, two-columns, right-sidebar, flexible-width, custom-background, custom-header, custom-menu, editor-style, featured-images, flexible-header, full-width-template, microformats, post-formats, rtl-language-support, sticky-post, theme-options, translation-ready     Text Domain: twentytwelve          This theme, like WordPress, is licensed under the GPL.     Use it to make something cool, have fun, and share what you've learned with others.     */      It succeeds at adding text into the author name, except it adds it all with the formatting messed up. It looks like this on my theme page:               Current Theme     Twenty TwelveTheme URI: http://wordpress.org/extend/themes/twentytwelveAuthor: the WordPress teamAuthor URI: http://wordpress.org/Description: The 2012 theme for WordPress is a fully responsive theme that looks great on any device. Features include a front page template with its own widgets, an optional display font, styling for post formats on both index and single views, and an optional no-sidebar page template. Make it yours with a custom menu, header image, and background.Version: 1.1License: GNU General Public License v2 or laterLicense URI: http://www.gnu.org/licenses/gpl-2.0.htmlTags: light, gray, white, one-column, two-columns, right-sidebar, flexible-width, custom-background, custom-header, custom-menu, editor-style, featured-images, flexible-header, full-width-template, microformats, post-formats, rtl-language-support, sticky-post, theme-options, translation-readyText Domain: twentytwelveThis theme, like WordPress, is licensed under the GPL.Use it to make something cool, have fun, and share what you've learned with others.          By Anonymous Version     Customize OPTIONS: Widgets Menus Customize      So basically what it is doing is adding all of the theme information into the Author description/heading, instead of adding the info into it's own correct description/heading. Can anyone tell me why this could possibly be happening? I haven't found anything at all about this issue, and I am baffled as to why it would even happen.


How to take the help button and link off the dashboard

I want to take the help button/link off fron the top right of the dashboard. I dont want to do it with a plug in so if you could tell me where the code is located and what to take off that would be great thanks.


Need to redirect a non-primary Multisite URL

I have two sites on a Multisite installation. During development they were at the addresses new.site1.com and new.site2.com. Site1 was the primary. I had a subdomain install as indicated in wp-config. I have succeeded in launching the primary site, whose URL is now www.site1.com. The second one I have changed all references in the Database and the Network Mapping area to www.site2.com, but I can't reach the site at that address now. There are now no references to the old URL in the database or anywhere in the admin. Is there anything else I should do?


How to control contextual help section by code?

I had added some content to contextual help section for plugin options page. Now I'd like that page defaulted/toggled to contextual help section open on specific condition in my PHP code. My only issue is that I am not strong with JS and don't see clear approach to coding that (I know how to pass variable to JS through localize, but not what code will actually get it done). I had found relevant JS functions in source, but not sure how to properly reuse them for my task.


Formatting error with source code on WordPress.com?

I've been trying to post some Java code to my blog, but it seems like it has some problems with the formatting. First, whenever I copy/paste code into the editor, it's pasted as pre- formatted, which means that it converts the indents to spaces, all on a single line. And when I try to separate the lines by making each line of code on a single physical line, it doesn't indent them automatically. I'm using the visual editor, and I've checked the HTML code, and nothing seems to be wrong with it. What am I doing wrong? Or is this a bug I should report to WordPress?


Custom functions for string data calculations

Just a quick question. I have a form that calculates values based on user entry. The information is then passed via ajax to a php file for calculation returning the results. The problem is that that PHP file needs to reference the header as it needs to use the get_posts function to receive the string and collapse it into an array. Problem is that that bulks up the file massively and courses functions to execute in the header that we do not want as then the whole damn header arses up the ajax load and we get a blank screen. So is there a way or a place to put this file whereby it can get_posts without having the bulky header load as well. Bit of code here if you are interested.                  <?php     if (is_page('main-functions')) {          $str = dataSting;     (explode(",",$str));          $totalprice_posts = get_posts('post_type=services&numberposts=-1');     $totalprice_array = array();     foreach ($totalprice_posts as $post) {         $productprice = $_POST['price'.$post->ID];         $productprice = $_POST['quant'.$post->ID];         $totalproductprice = ($productprice * $productquantity);         array_push($totalprice_array, $totalproductprice);     }     implode(',', $totalprice_array);     $totalprice = array_sum($totalprice_array);      echo $totalprice;               ;}           ?>      Any ideas, Marvellous.


Image still attached to post even after removing it as featured image

I'm sorry if this is too noob of a question, but when I upload an image and set it as the featured image then later remove it (as featured image), the media list still shows it's "Attached to" the post I removed it as featured image from. Any clue? More importantly, how do I then make it so that when I remove the featured image, it will be "Unattached"? Any hook I can attach to or the like? Thanks so much.


Pagination broke after updateto Wordpress 3.4

> **Possible Duplicate:**   >  Custom Post Type Pagination Doesn't Work in Wordpress 3.4 I updated to wordpress 3.4 and after so my pagination broke showing not found on page/2 etc. I am using custom post types and custom query such as:               <?php       $type = 'products';       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         $args=array(         'post_type' => $type,         'post_status' => 'publish',         'paged' => $paged,             'caller_get_posts'=> 1       );       $temp = $wp_query;       $wp_query = null;       $wp_query = new WP_Query();       $wp_query->query($args);     ?>      is there any possible fix for that? thank you.


wp-signup.php redirected to register.php

I have worpdress 3.4 multisite subdirectory set-up. (eg: example.com\username) I also have a buddypress installation installed as a secondary blog.(eg: example.com/community) http://codex.buddypress.org/getting-started/install- buddypress-on-a-secondary-blog/ All settings found in the above apply to my installaiton of Buddypress. Now, I would like users to register to example.com using example.com/wp-signup.php page so that they can create a new site and a new account. Unfortunately this is not possible as users are re-directed to example.com/community/register If I disbale buddypress though then users can create a site + account using example.com/wp-signup.php page. (eg: example.com/username) What setting should I apply for the above to be true considering that buddypress is intalled as a second blog?


Too many actions/filters!

New to wordpress here. The concept of actions/filters in and of itself is not too difficult to grasp. What I am overwhelmed by is the HUGE amount of actions and filters available. When I am looking at tutorials/guides, they say "simply add this function to the wp_head action or after_setup_theme". Without these tutorials, how on earth would i know to hook that function to that action? As a beginner, how the heck would i know what is the appropriate action to hook on to? Any advice on how to navigate this? Thanks


Category menu item and its last 10 posts as sub-menu

i have some posts categories as element of a main navigation menu, and i'd like to display the ten lasts posts of this category as sub menu. ex: Category1 Lastpost1 Lastpost2 The main menu is build in the admin panel, and i'm wondering if there is a hook or something to achieve that automatically. I know how to hardcode that, but i'd like to keep using the cool menu edition from admin panel. any ideas?


WordPress dashboard, viewing CPT results in 504

I created a custom post type with a custom taxonomy. I have about 1500 posts all of which are assigned to some sort of taxonomy term...some being assigned to 200+ terms. I noticed that from the dashboard, it takes an extremely long amount of time to view the custom post types, most of the time resulting in a 504 Gateway Time-Out. Querying these post from the front-end is just fine and I have no issues with that. It's my understanding that when the dashboard is trying to view these custom post types, it's trying to pull all the information assigned to each post, before it shows everything. I do have this WP install set to be able to use as much memory as needed (memory_limit = -1), as I was researching, some said it may be memory related. Is there something i can do to increase the performance of this query ...maybe not load all the taxonomy term relationships of a post until you're editing the post? **Errors after increasing`WP_MEMORY_LIMIT` from 1Gb to 2Gb:**               WordPress database error: [MySQL client ran out of memory]     SELECT t.*, tt.*, tr.object_id FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('locations') AND tr.object_id IN          WordPress database error: [Lost connection to MySQL server during query]     SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN          WordPress database error: [MySQL server has gone away]     SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month FROM wp_posts WHERE post_type = 'services' ORDER BY post_date DESC


How to skip woocommerce PayPal redirection?

I use WooCommerce plugin for my shop. I want to skip the PayPal redirection on the "Thank You" page, where users are redirect to PayPal site. I'd like to add to every order also the shipping prices which are different for every product due to product weight and courier distance. I can invoice the customer later with the updated price so they can proceed with payment via PayPal after that. Thank you.


Load external javascript files

I have some trouble with loading external javascript files inside my WordPress theme. Use the following markup:               <script src="<?php bloginfo('template_directory'); ?>/js/jquery-1.8.1.min.js" type="text/javascript"></script>     <script src="<?php bloginfo('template_directory'); ?>/js/custom.js" type="text/javascript"></script>      The above code is set inside the `<head>` of my `header.php` file of my WordPress theme. Why is this not working? Or should I also use the following for link external scripts?               function my_scripts() {         wp_enqueue_script( 'my-sweet-script', get_bloginfo('template_directory') . '/script.js', array('jquery') );     }      Thank you. Casper


Custom /page/2/ template (different from index.php)

I'm trying to create a custom page 2 template that's different from the main index.php. For example, the main index page would display the latest news + a lot of features like a magazine. When readers click to read on to page 2, 3, 4 etc of the news posts, they are taken to a more regular news page. Kinda like something on theverge.com (at the bottom, click "next page" and see what I mean). Anyone have any ideas on how to do this? I know it's possible to create archive pages for categories and tags, but I'm not sure how to do it for the index.php. Thanks!


add img class to native wordpress galleries

Trying to add an img class = "the image alt field" to the images in a native wordpress gallery so i can use jquery isotope to filter the gallery. I could use the image alt field or the description field to give the image a simple class of "apple" or "orange" or "apple tasty". This should probably be done using tags somehow but surprising that is not a feature of wordpress.               add_filter('wp_get_attachment_link', 'galleryWIthClass');          function galleryWithClass($src) {          global $post;     $alt= get_post_meta($id, '_wp_attachment_image_alt', true);          echo str_replace('<img', '<img class="'. $alt.'" ', $src);          }             This code results in : img class = "". I need to set $id = "something" in order to return some sort of value. I feel im approaching this wrong. Any advice?


Can I use core's "or Link to Existing Content" feature in my plugin?

When adding a link in the TinyMCE editor, you get a nice search with ajax function that searches your existing content and lets you select from it. Is it possible/reasonable to re-use this in a plugin? If so, how would I go about doing it? (I'm working on a Related Posts functionality, and while I can easily list ALL posts in the list, it seems it would get out of hand quickly without the ability to search/filter.)


Implementing "Random" to custom-background

I have a client site that requires a random background image. I figured that `custom-background` would have something similar to `custom-header` for randomizing which image is selected, but alas it does not seem to be the case. Does anyone have experience doing this, or know what direction would be best to extend `custom-background`? Or would the better approach be to ignore `custom-background` and create my own background theme support (I severely frown upon this method, but 'the easy route' is always there).


Custom password reset using AJAX

I used this (great) tuturial 'WordPress AJAX Login Without a Plugin – The Right Way' to make a custom login form and everything works fine. But I could need some help building the same functionality for the lost password form. The (perfectly working) login code uses these lines:                   $user_signon = wp_signon( $info, false );     if ( is_wp_error($user_signon) ){         echo json_encode(array('loggedin'=>false, 'message'=>__('Wrong username...')));     } else {         echo json_encode(array('loggedin'=>true, 'message'=>__('Login successful')));     }      For my password page I need to replace this with a WP function that checks the user input (email or username) and sends an e-mail. The function I need is retrieve_password, but I don't know how to call that function and how to pass the user input.


Wordpress 3.1.2 Bug: add_theme_support() and video post format registering twice

Ive been experiencing a problem with the new WordPress 3.1.2 update. When i use `add_theme_support();` and register an array of post formats, it registers all of them fine, but when it comes to the video post format, it registers it twice, and gets called **post-format-video-2**. This is the way im writing out the code:               add_theme_support( 'post-formats', array( 'aside', 'gallery', 'image', 'link', 'video' ));      Ive tested this out both on my theme, and the twentyten theme. The problem is exclusive to the video post-format. Its really strange. Additionally when you declare a "posts" format as "video" upon publishing or updating, the post- format meta box adds a new radio button with a new post format without a slug/name. Illustration (where numbers are the radio buttons):   1. Aside   2. Gallery   3. Image   4. Link   5. Video   6.  Despite only showing 5 radio buttons, upon updating/publishing, a new radio button appears, and it gets selected (radio button 6) rather than the one I chose (radio button 5). Ive used the `add_action( 'after_setup_theme', 'foobar' );` on my theme with no luck. Of-course this comes standard with twentyten. Any ideas?


Static home page with "Blog" inside?

I'd like to have a static home page and also have a link called "Blog" that lists posts in the "blog" category in chronological order. Would the best way to do this just be to place code in archive.php and do a "switch case" on the category and do a loop on the posts? Just looking for some options before I decide on a strategy and code the solution.


WP_Query by date not working?

I'm using a function that returns posts using shortcode. My 'featured posts' are to be any category with the highest comments and only for the week. I have looked over the documents and even did a vardump and the variables are passing through, not sure why its getting old posts anyway. Please look at the var_dump() of the query here: http://pastebin.com/i51RRgTp The function I made is here: http://pastebin.com/821UDrsf I apologize that the tabbing did not paste properly into pastebin. The page that uses shortcode output is here:               [preview_posts title="Featured" weekly="true" orderby="comment_count"]     [inline-post id="5603" class="alert col-md-8 col-md-offset-2" anchor="contest-spotlight"]     [preview_posts title="New" orderby="date"]     [inline-ad]     [preview_posts title="Latest Questions" cat="104"]     [preview_posts title="Blast from the Past!" cat="84"]     [inline-ad]     [preview_posts title="New Installs" cat="87"]     [preview_posts title="Helpful Guides & Diagrams" cat="82"]     [inline-ad]     [preview_posts title="Memes"  cat="81"]     [preview_posts title="Videos" cat="99"]      The result of the page is here: www.hvac-hacks.com


Multiple orderby values in WP_Query

I'm trying to come up with a query to sort by multiple orderby values. Here's what I have so far:                   $dept_id=2;         $query=new WP_Query(array(                 'post_type'=>'wpcontactus',                 'nopaging'=>true,                 'post_status'=>array('publish', 'pending', 'future'),                 'meta_key'=>'wcu_dept',                 'meta_value'=>$dept_id,                 'orderby'=>'title',                 'order'=>'ASC'         ));      I'm trying to query a custom post type, and within that post type, query a meta value. Then, I'd like to first sort by `menu_order` ascending, then by a custom meta value `wcu_lastname` ascending. However, the orderby value didn't seem to be able to take an array. How can I order the query using multiple orderby values?


How to insert custom code into wp_nav_menu structure?

I was able to use `<?php wp_nav_menu( array( 'theme_location' => 'primary- menu', 'container' => false ) ); ?>` to create the menu within my theme. Messed around with 'items_wrap' but couldn't get it to display correctly. I need to add an image and container div into the sub menu ul before the li's. This is the structure I want:

Page
                 <img src="<?php bloginfo('template_directory'); ?>/images/nav_ul_tab.png" class="nav_ul_tab" />

Sub Page

Sub Page

Sub Page


How do I get WooCommerce to recreate the home page?

I was hoping the answer to the question (How do I get WooCommerce to automatically recreate pages?) would help but i could not recreate the home page. Im using mystile theme and when i go to customize i cant find the home page to set it as the front page.How can i recover the built in home page ?


Get active term on single (CPT) page

I know similar questions have been asked here but I feel my case is slightly different. I need to get the _active_ _current_ term (object) on a CPT single page. However, the single post can have multiple categories. This means _I can't just get all the post terms_ and array pop the first index (because this is not always the currently active term). Say for example I have an url like: mysite.com/my-cpt/my-custom-term/my-cpt- post Now on the my-cpt-post template I need to get the "my-custom-term" object. Thanx for the help.


How to display term description in empty terms archive?

I list all terms from a taxonomy, even the empty ones, but I found out that at least in 2010/2011 themes I got a 404-like message, the default seems to only display the term description when at least one post is using it # Filters seems the best thing but I can't find the right one. Thanks for any idea.


JQuery undefined and Stylesheet loads in bottom along with js files

I'm developing a theme for wordpress and I'm using this function to enqueue scripts and styles               function Joy_scripts() {          wp_enqueue_style( 'Joy-style');          wp_enqueue_script( 'Joy-scripts', get_template_directory_uri() . '/js/scripts.js', array( 'jquery' ), '1.0', true );          if ( is_singular() && wp_attachment_is_image() ) {     wp_enqueue_script( 'Joy-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );     }          if ( in_category('12') ) {     wp_enqueue_script( 'Joy-jquizzy-engine', get_template_directory_uri(). '/js/jquery.jquizzy.js', array( 'jquery'), '1.7' );     wp_enqueue_script( 'Joy-jquizzy-init', get_template_directory_uri(). '/js/init.js', array( 'jquery'), '1.7' );     wp_enqueue_script( 'Joy-jquizzy-script', get_template_directory_uri(). '/js/jquizzy-script.js', array( 'jquery'), '1.7' );      }     }     add_action( 'wp_enqueue_scripts', 'Joy_scripts');      This is the html output:               </footer>     </div><!-- #page -->          <script type='text/javascript' src='http://localhost:8888/theme/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>     <script type='text/javascript' src='http://localhost:8888/theme/wp-content/plugins/mailchimp-widget/js/mailchimp-widget-min.js?ver=3.5.2'></script>     <script type='text/javascript' src='http://localhost:8888/theme/wp-content/plugins/media-element-html5-video-and-audio-player/mediaelement/mediaelement-and-player.min.js?ver=2.1.3'>    </script>          <!-- some other scripts loaded here they're not important for this question purposes-->          <link rel='stylesheet' id='Joy-style-css'  href='http://localhost:8888/theme/wp-content/themes/Joy/style.css?ver=1.0' type='text/css' media='all' />      As you can see the theme stylesheet is loaded AFTER the scripts, and at the BOTTOM of the document. This is causing FOUC (I have added the stylesheet at the top using `<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="all" />` and the FOUC dissappeared) Also in the Chrome console I'm getting: `Uncaught ReferenceError: jQuery is not defined localhost/:111 Uncaught TypeError: Property '$' of object [object Object] is not a function` jQuery is loading properly and before the other scripts, so, I really did not understand what is happening here, am I doing something wrong? My theme is based in on Underscores Thanks for your help.


How do I get is_single() to return true when called internally from the_content()?

I have a custom page, _e.g._ `blog.php?post=42` that shows a GET-specified post like so:               <?php require('wordpress/wp-blog-header.php'); ?>                    <?php         global $post;         $post = get_post($_GET['post']);         setup_postdata( $post );     ?>

<?php the_title(); ?>

<?php the_content(); ?>
         <?php             global $withcomments;             $withcomments = 1;             comments_template();         ?>
                I have Jetpack sharing buttons enabled, however the buttons don't appear in `the_content()` as they should. I'm new to WordPress development, so my guess is that I'm doing something fundamentally or obviously wrong above. ## Details From my own debugging, it appears that `the_content()` leads to some Jetpack code in `sharing-service.php` where `is_singular()` is called to decide whether the sharing buttons should show, _i.e._               $sharer = new Sharing_Service();     $global = $sharer->get_global_options();          $show = false;     if ( !is_feed() ) {         if ( is_singular() && in_array( get_post_type(), $global['show'] ) ) {             $show = true;         } elseif ( in_array( 'index', $global['show'] ) && ( is_home() || is_archive() || is_search() || in_array( get_post_type(), $global['show'] ) ) ) {             $show = true;         }     }          // Pass through a filter for final say so     $show = apply_filters( 'sharing_show', $show, $post );      I'd like my post to be "detected" as `is_single()` and therefore `is_singular()` and route execution to the first branch, reprinted from above:                   if ( is_singular() && in_array( get_post_type(), $global['show'] ) ) {             $show = true;         } ...      I don't know what the second condition means, but I verified that it returns `true`. I also verified by hardcoding `$show` to `true` in the last line as such,               $show = apply_filters( 'sharing_show', true, $post );      that indeed this causes the sharing buttons to appear. How can I get a `get_post()`'ed object to be set up such that `is_single()` returns true? Or, am I simply doing things a way they should not be done?


Wordpress Wp_nav_menu How to create Columns in submenu

i have been trying to develop custom navigation in wordpress. i want to add columns in sub menu item. i want to add images in navigation as well as create Multi column Navigation. Please check this attached screenshot. i tried to develop using custom walker method. Need Help to create multi column menu here is my code: **Navigation code:**                     <?php wp_nav_menu( array( 'theme_location' => 'primary','container_class' => 'navbar-collapse collapse in','container_id' => 'defaultmenu', 'menu_class' => 'nav navbar-nav','depth' => 10,'walker' => new themeslug_walker_nav_menu ) ); ?>      **custom walker function in Function.php file:**                class themeslug_walker_nav_menu extends Walker_Nav_Menu {           // add classes to ul sub-menus       function start_lvl( &$output, $depth = 0, $args = array() ) {        // depth dependent classes         $indent = ( $depth > 0  ? str_repeat( "\t", $depth ) : '' ); // code indent        $display_depth = ( $depth + 1); // because it counts the first submenu as 0             $classes = array(         'sub-menu',         ( $display_depth % 2  ? 'menu-odd' : 'menu-even' ),         ( $display_depth >=2 ? 'sub-sub-menu' : '' ),         'menu-depth-' . $display_depth         );       $class_names = implode( ' ', $classes );             // build html        $output .= "\n" . $indent . '
' . "\n";       }               // add main/sub classes to li's and links         function start_el(  &$output, $item, $depth = 0, $args = array(), $id = 0 ) {        global $wp_query;       $indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' ); // code indent             // depth dependent classes         $depth_classes = array(         ( $depth == 0 ? 'main-menu-item' : 'sub-menu-item' ),         ( $depth >=2 ? 'sub-sub-menu-item' : '' ),         ( $depth % 2 ? 'menu-item-odd' : 'menu-item-even' ),         'menu-item-depth-' . $depth         );         $depth_class_names = esc_attr( implode( ' ', $depth_classes ) );              // passed classes         $classes = empty( $item->classes ) ? array() : (array) $item->classes;        $class_names = esc_attr( implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ) );           // build html       //print_r( $depth_class_names);                 $output .= $indent . '
ID . '" class="' . $depth_class_names . ' ' . $class_names . '">';                  // link attributes        $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';         $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';         $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';         $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';              $attributes .= ' class="menu-link ' . ( $depth > 0 ? 'sub-menu-link' : 'main-menu-link' ) . '"';               $item_output = sprintf( '%1$s%3$s%4$s%5$s%6$s',         $args->before,         $attributes,         $args->link_before,         apply_filters( 'the_title', $item->title, $item->ID ),         $args->link_after,         $args->after        );            // build html           $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );          }         }      ![enter image description here](http://i.stack.imgur.com/5qCTP.png)


How much resources are good enough for 3.9.2

I have the following specification:   * memory_limit(maximal 128 MB),   * max_execution_time(max 60 sec)    * same PHP-Prozesse(max 10) Is this good enough for wordpress? I am having a small site with around 100 visits a day, so nothing really large. Do you think I could host 2 other wordpress installations on the server? I appreciate your answer!


Align text left of image in this php script?

Ok so i am using this code, which allows me to upload photo's to a post and instead of inserting them myself, it calls all the photos attached to the post. Thus for placing all the photos in the post by itself. But what i did was made this page int a gallery where i use a jquery jcarousel where they can click the arrows to go to the next photo. here is the code                <?php          if ( 'photos' == get_post_type() ) { //condition to show gallery on post type - photos          if ( $attachments = get_children( array(         'post_type' => 'attachment',         'post_mime_type'=>'image',   //return all image attachment only         'numberposts' => -1,   //get all the attachments         'post_parent' => $post->ID     )));          foreach ($attachments as $attachment) {         // you can customize the oputput         echo '
';         echo wp_get_attachment_link( $attachment->ID, 'full' , false, false, '' );         echo ''.$attachment->post_excerpt.'';         echo '
';     }     }          ?>      But how do i get the post_excert part of the code which is the caption, to align left of the image, what do i add to the code and where, or is this something i do in css.


Stale $GLOBALS['post'] after custom WP_Query empty result set bothers my template, whose fault is this?

Story below looks to me like it's about a commercial Event Management plugin whose authors to me just don't seem very good at WordPress. But bear with me and let's see if there's also an issue in WP. This is on 3.5.2. Chain of events I'm looking into:   * custom taxonomy query is made in browser   * `$wp_the_query` gets all results (1 post total), WordPress sets `$GLOBALS['post']` to this post   * in "wp" action, commercial plugin builds new WP_Query (meta query, resulting in a correct EMPTY RESULT SET), then replaces global `$wp_query` with this empty result by bluntly doing `$wp_query = $this->_wp_query;`   * but nobody touches `$GLOBALS['post']`, so all subsequent `get_post()` calls see `$wp_query->post` not being there, fall back on `$GLOBALS['post']` and cause incorrect results (`post_class()` and friends, who think they have an `<article>` element to work with) If I manually hook into "wp" action after commercial plugin has finished its' query and do `$GLOBALS['post'] = null`, template will correctly reflect reality.   * we have even more fun when for example Yoast's SEO plugin does `wp_reset_query()` for its own magic in "wp_head" action, which will resurrect global `$post` variable from `$wp_the_query` after I've nulled it earlier in "wp" So this is some sort of an issue with empty result set custom queries. I have not see any guidelines so far to care for resetting global `$post` variable like this. While the plugin is just badly built, should there be something for this addressed in core?


Custom frontend post not working?

Hi I am creating a custom post front end submission. This is my code to submit the custom post details. Here the validation is not working as well as it will not submit the post. When i submit the post it will display the **no post found** page. Can any one suggest me what is wrong.               <?php function as_front_end() { ?>         <form id="custom-post-type" name="custom-post-type" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">              Post Title
              <input type="text" id="title" value="" tabindex="1" size="20" name="title" />         Post Description
         <?php  wp_editor( $value_to_return, 'textareaname', array( 'textareaname' => 'textareaname', 'teeny' => true ) ); ?>                       <?php echo wp_dropdown_categories('show_option_none=Select Category&show_count=0&orderby=name&echo=0&selected=6&hierarchical=1/True&show_option_all='); ?>
         <input type="submit" value="Publish" tabindex="6" id="submit" name="submit" />
         <input type="hidden" name="post-type" id="post-type" value="custom_posts" />         <input type="hidden" name="action" value="custom_posts" />         <?php wp_nonce_field( 'as_front_end','custom-post-type' ); ?>              </form>         <?php              if($_POST){             ty_save_post_data();         }         }          function ty_save_post_data() {              if ( empty($_POST) || !wp_verify_nonce($_POST['as_front_end'],'custom-post-type') ){             print 'Sorry, your nonce did not verify.';             exit;              }else{                  if (isset ($_POST['title'])) {                 $title =  $_POST['title'];             } else {                 echo 'Please enter a title';                 exit;             }             if (isset ($_POST['description'])) {                 $description = $_POST['description'];             } else {                 echo 'Please enter the content';                 exit;             }                  if(isset($_POST['post_tags'])){                 $tags = $_POST['post_tags'];             }else{                 $tags = "";             }                  $post = array(                 'post_title' => wp_strip_all_tags( $title ),                 'post_content' => $description,                 'post_category' => $_POST['cat'],                    'tags_input' => $tags,                 'post_status' => 'pending',                              'post_type' => $_POST['post-type']                );             wp_insert_post($post);                    $location = home_url();                    echo "<meta http-equiv='refresh' content='0;url=$location' />";              exit;         }            }            add_shortcode('custom-post','as_front_end');


Auto approve all comments (editor)

I **unchecked** both options in the `discussion` area _(so the one where they need a post to comment and administrator has to approve)_ , but still, my users can't put their comments without me approving it. Has someone a solution for this glitch? Why on earth can't they post a comment? And if they post one, the second one needs to be approved?


Similar to wp_editor but for the post title input field

What is the function that I can use to render the post title input field? I know wp_editor does that for the editor. I need to move the custom post title field (the default title that comes with the default post) inside a meta box I created. I can unset the default title and then re add it inside the custom meta box. Something similar to http://wordpress.org/support/topic/move-custom-meta-box- above-editor In the link above they did it for the editor. Thanks.


URLs getting appended with strange number string, resulting into 404s

> **Possible Duplicate:**   >  Massive 404 issue reported by Google Webmaster Tools on a WordPress Site I've been dealing with large number of 404 errors reported in the Google Webmaster Tools. I found that out of the 1000 "404" URLs reported in GWT majority of the reported 404s are regular URLs with a strange number string attached. Here are few sample URLs - http://www.domain.com/correct-url-ends-here **/1345601488000/1345993967000** http://www.domain.com/another-correct-url-ends-here **/1346198904000/1346893566000** The bolded number string is appended and GWT even reports several versions of each URL (each with its own number string). My doubts: 1. Is it because of the 'disqus' comments system? Or something else? I've switched over to the LiveFyre system for the time being. I can disable it totally, if required. 2\. What's the proper way to fix this?


Merge / Combine two php functions for Previous and Next Link with Thumbnail

I will wrap two merged php funtions in one div container - so i have only one php function and one link to the next post, regardless if someone clicks on the thumb or the text part. These are the two functions i use:               <?php previous_post_link( '%link', 'Previous Post
%title' ); ?>      and:               <?php $prevPost = get_previous_post(true); $prevThumbnail = get_the_post_thumbnail($prevPost->ID, 'thumbnail' ); echo $nextthumbnail; ?><?php previous_post_link( '%link', $prevThumbnail ); ?>      How can i merge the above two codes to one?


Add simple Nivo Slider to wordpress site

I have a wordpress website, on the front page i have an area below the main menu which takes a post and displays it along with an image, what i would like to do is swap this box for the nivo slider.               http://79.170.40.241/shaddersafrica.com/      The problem is, this area of the website isn't controlled through the admin area and although i have the simple-nivo-slider plugin installed, i don't know if it is possible to place it in place of the current post area and if so how i would do that. Thanks Lee


Combining two meta_values within one row with query

I've added two new meta_keys to the `wp_usermeta` table: `bid_user_lat` and `bid_user_lng` And I need to be able to get both of these values within a single row, along with the `user_id`. `ROW - (user_id) 220 | (bid_user_lat) 45.099080 | (bid_user_lng) -140.09099` Now comes the tricky part ... I then need to use these values within a calculated radius statement: `( 3959 * acos( cos( radians( @lat ) ) * cos( radians( **bid_user_lat.meta_value** ) ) * cos( radians( **bid_user_lng.meta_value** ) - radians( @lng ) ) + sin( radians( @lat ) ) * sin( radians( **bid_user_lat.meta_value** ) ) ) ) AS distance` In the end, I'm making sure that the user is within a certain radius, and if so, I will return it within the query. **But the most important part is being able to query the`wp_usermeta` the way I need to!**


Generate Wordpress salt

I am in need of a function that automatically generates and returns salts for Wordpress wp-config.php (Don't link me to their API, I'm looking for offline solution). Does Wordpress core has this function defined somewhere? If it doesn't, can these salts be generated randomly or are there any specific rules for creating them? Edit: **This is what I ended up with:**                   $keys = array('AUTH_KEY', 'SECURE_AUTH_KEY', 'LOGGED_IN_KEY',                   'NONCE_KEY', 'AUTH_SALT', 'SECURE_AUTH_SALT', 'LOGGED_IN_SALT', 'NONCE_SALT');         $salts = '';         foreach ($keys as $key) {             $salt = wp_generate_password(64, true, true);             $spaces = str_repeat(' ',16 - strlen($key));             $salts .= "define('{$key}',{$spaces}'{$salt}');\n";         }      And the output is string:               define('AUTH_KEY',        'f@5^8(OyZLS%+~LNQ6,w(Zpn`3X#A}o4t2LQuqc=x4vn+ b}xYM>TlSwB`|E;}PA');     define('SECURE_AUTH_KEY', 'vEEF@-c_`VO!d{s)_Nv^uS,)eg9{;60.$nU370/9E1z}O#iu)wkPrw8sh[TqGdC;');     define('LOGGED_IN_KEY',   '9:z95.y<_LhUnGlH>6%)/-szx8Dwj{z`#mz-C%taXoD:KK86k(?K-f{w]U5w(41v');     define('NONCE_KEY',       '?YP2djRHOn7[4n[p(KwmX#u.#^s3Fel%AKu@Ac,(L$1DM^@6NNk@x&B/w2/<an:@');     define('AUTH_SALT',       '$r>m{8@l?xDv<^uNz^.|<Am2}J3q(OMAS<dLB({66M)zy2ufOP8$x*{:US|7PL4x');     define('SECURE_AUTH_SALT','Nn4uU#rIe}7CaXw=Z?pk82Cqo8{ALC6McPHYq_G{><]_YWhHlEuk?`tJ6G[)D$)A');     define('LOGGED_IN_SALT',  'YLiGuP$DPKP-F3UGw(0#E0L1w;HO0L_Hkt6.(*92t*B6Mclq*`{OO[xM$3)]^9yi');     define('NONCE_SALT',      '{hh3bpLu$b:e8-uXiCx(3FaK3Q4[`/Mji}~<.cz8W#_a0[O!{h;Fm{^c]p>./RF{');


How can I alter the [gallery] markup?

I would like to change the markup created by [gallery] from what is it as standard (dl) to a unordered-list with a difference. Below is the desired markup:

       I want the main image source for the link & img, as I want to run the img src through a php cropper script. Is this possible? I'm sure we can crack it!


What does wp-list.js do?

Pretty straightforward question! What does wp-list.js do? It's listed in the wp_enqueue_script codex page as one of the WP included javascript libraries. Thanks!


MultiPostThumbnails for Custom Post Type

I have spent time and figured out how to add Multiple Thumbnails to a custom post type in the wordpress admin for the custom post type, code and question below:                   if (class_exists('MultiPostThumbnails')) { // imports to post_type pages                 new MultiPostThumbnails(array('label' => '2nd Feature Image', 'id' => 'feature-image-2', 'post_type' => 'page', 'post_type' => 'landing_pages')); /* 'post_type' => 'landing_pages' adds support for landing pages CPT */                 new MultiPostThumbnails(array('label' => '3rd Feature Image', 'id' => 'feature-image-3', 'post_type' => 'page', 'post_type' => 'landing_pages'));                 new MultiPostThumbnails(array('label' => '4th Feature Image', 'id' => 'feature-image-4', 'post_type' => 'page', 'post_type' => 'landing_pages'));                 new MultiPostThumbnails(array('label' => '5th Feature Image', 'id' => 'feature-image-5', 'post_type' => 'page', 'post_type' => 'landing_pages'));         };      _*_ Does anyone know if there is a way to write an array or condense the code below so you dont have to list the post type twice:                   new MultiPostThumbnails(array('label' => '2nd Feature Image', 'id' => 'feature-image-2', 'post_type' => 'page', 'post_type' => 'landing_pages'));      Thanks.


Retina for Wordpress Posts

I was checking one of the answers here, and it says: > Just create the copies of images with double size using wordpress native > media settings. And then add the following code in your templates.               <?php $normal = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail');     $retina = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' ); ?>          <img src="<?php echo $normal[0]; ?>" data-at2x="<?php echo $retina[0]; ?> alt="<?php the_title(); ?>" width="xxx" height="xxx"/>      > Here my thumbnail (normal) size is 300x300px and medium thumbnail (retina) > has 600x600px size. And also don't forget to load retina.js otherwise data- > at2x= will not work. Good luck!" \-- I'm using the Genesis Framework, and I'm wondering where you'd suggest adding the above code


Dynamic Sidebars On Multiple Subpages

I am building a site in WordPress. It has multiple subpages, many of which require different sidebars. So, I have a widgetized theme and I have also created a few sidebar widgets. I have written a conditional statement to show different sidebars on different pages. However, one widgetized sidebar displays on almost all pages despite the conditional statement. The sidebar that is appearing on the desired page can be seen here: http://www.africanhealthleadership.org/about/approach/ The subpage that should have a different sidebar is under Knowledge Resources>Research The code is as follows. I am a total PHP spazz, so I likely did something silly. I have tried single quotes around dynamic_sidebar(2) but that did not work. Thank you for any help.               <?php           if ( is_subpage('approach') ) {          if (!function_exists ( dynamic_sidebar(1) ) ) ;      }         elseif ( is_subpage('research')) {         if (!function_exists( dynamic_sidebar(2)) || !dynamic_sidebar( "Sidebar2") );         }     ?>


What are these variables and where are they documented?

This is in the twentyeleven theme. Can somebody tell me what this is?               Posted in %2$s', 'twentyeleven' )                  ^^^^                   ^^^^      My best googling tells me it's something to do with i18n, but I don't think that's the full story because some of them spit out things like author names and post titles, like this example:               %7$s                               ^^^^         ^^^^               ^^^^      At any rate, is this something I can/should be using? What's it actually called, and where is it documented? Sorry if this is a dumb question, but it's a hard thing to google! Thanks!


How to add filter in "Comments" at the admin panel?

I found so many information and most of the tutorials only talk about adding filter in post/custom post only. I want to do something similar to this tutorial in 'Comments' area in admin panel. Add filter menu to admin list of posts (of custom type) to filter posts by custom field values However, I'm not sure if the parse_query handle also handle the query in this area? Anyone might have suggestion on tutorial, plugin that might help?


How do I override the default number of items to be listed on an archive.php page?

> **Possible Duplicate:**   >  How To Modify The Loop in archives.php To Have 11 Posts Per Page and CSS > Styling I am using the following code on my archive.php template to list a few fields from a custom post type. It's an album review post type and this code pulls in the artist name, the album name and the album cover. Is there any way to alter this code to tell wordpress to display a certain number of results? The issue I have is that for all other archive pages the default (set to 10) is fine, but because I am only displaying a thumbnail and a name on the archive for reviews there's a lot of room to add more in.


Activate / Deactivate plugin

I'm working on my first plugin and am trying to use `register_activation_hook()` and `register_deactivation_hook()` ... I know I'm not doing this right:               /*====================================================*/     //  1.0 Actions to perform upon plugin activation     /*====================================================*/     register_activation_hook( __FILE__, 'construct_uploader_page' );     register_activation_hook( __FILE__, 'construct_terms_page' );     register_activation_hook( __FILE__, 'create_custom_user_role' );          // Construct Event Photo Uploader template page     function construct_uploader_page() {              $post_id = -1;              // Setup custom vars         $author_id = 1;         $slug = 'event-photo-uploader';         $title = 'Event Photo Uploader';              // Check if page exists... if not, create it             if ( null == get_page_by_title( $title )) {                  $uploader_page = array(                 'comment_status'    => 'closed',                 'ping_status'       => 'closed',                 'post_author'       => $author_id,                 'post_name'         => $slug,                 'post_title'        => $title,                 'post_status'       => 'publish',                 'post_type'         => 'page'             );                  $post_id = wp_insert_post( $uploader_page );                  if ( !$post_id ) {                 wp_die( 'Error creating template page' );                  } else {                 update_post_meta( $post_id, '_wp_page_template', 'custom-uploadr.php' );             }         }     } // end construct uploader page          // Add Event Photo Uploader page     add_action( 'template_include', 'uploadr_redirect' );          // Callback to add menu items     function uploadr_redirect( $template ) {         $plugindir = dirname( __FILE__ );              // A Specific Custom Post Type         if ( is_page_template( 'custom-uploadr.php' )) {             $template = $plugindir . '/templates/custom-uploadr.php';         }              return $template;        }          // Construct Terms and Usage template page     function construct_terms_page() {              $post_id = -1;              // Setup variables         $author_id = 1;         $slug = 'terms-and-usage';         $title = 'Terms and Usage';              // Check if page exists... if not, create it         if ( null == get_page_by_title( $title )) {             $uploader_page = array(                 'comment_status'    => 'closed',                 'ping_status'       => 'closed',                 'post_author'       => $author_id,                 'post_name'         => $slug,                 'post_title'        => $title,                 'post_status'       => 'publish',                 'post_type'         => 'page'             );                  $post_id = wp_insert_post( $uploader_page );                  if ( !$post_id ) {                 wp_die( 'Error creating template page' );             } else {                 update_post_meta( $post_id, '_wp_page_template', 'terms-and-use.php' );             }         }     } // end construct terms page          // Add Terms and Usage page     add_action( 'template_include', 'terms_redirect' );          // Callback to add menu items     function terms_redirect( $template ) {         $plugindir = dirname( __FILE__ );              // A Specific Custom Post Type         if ( is_page( 'Terms and Usage' )) {                  $template = $plugindir . '/templates/terms-and-use.php';         }              return $template;     }          // Create custom user-role for registration     function create_custom_user_role() {              $custom_role = get_role('subscriber');         $standard_user = add_role( 'register', 'Register User', $custom_role->capabilities  );     }     // End Activation function      I need to add these three things when the plugin is activated ( two pages and a custom role ) and then deactivate them when the plugin is, well, deactivated ... I need help; from everything I've seen there is only supposed to be one `activation_hook()` and one `deactivation_hook()`, but I have more than one function I need activated/deactivated. Thanks for any help!


The best way to collision check in WP

E.g. I have a random number generated by a PHP code `$random` And I need to make a check if this number doesn't exist in any of my posts in DB in my meta field called `unique_code` What is the preffered way in WP to check if this value(random number) exist or not?


Loading different stylesheet on Wordpress pages?

I have one stylesheet linked to my Wordpress page in header section:               <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/style.css" />      Now, I want to load different stylesheets on a few pages or sub-pages. What's the best/correct way of achieving this? I'm thinking about writing my own shortcode calling "wp_enqueue_style", is that a good idea?


Use an array of page template slugs and $hook

I'm using the function below to load some javascript that removes the checkbox in the User Profile that is used to toggle the Visual Editor:               //Remove Visual Editor option in User Profile     function remove_visual_editor_admin_script( $hook ){      if ('user-edit.php' != $hook) {             return;         }         wp_enqueue_script( 'remove_visual_script', get_stylesheet_directory_uri().'/js/remove-visual-editor.js', array('jquery') );     }     add_action('admin_enqueue_scripts','remove_visual_editor_admin_script');      It loads a simple jQuery function in `remove-visual-editor.js` that removes the HTML and CSS and hides the checkbox. Problem is, the Visual Editor checkbox appears on two admin pages: one is `user-edit.php` and the other is `profile.php`; I'm calling the jQuery script on `user-edit.php` above. So I tried an array of page templates, like this               if (array('user-edit.php', 'profile.php') != $hook) {      with no luck. _How to I add the`remove-visual-editor.js` to both 'user- edit.php`and`profile.php` pages?_ Is there another way to add an array or multiple pages to the `if` line?