Localize variable for multiple Shortcodes

I have this code for flexslider Shortcode               add_shortcode('flexslider', function($atts){     global $post;     $ids = explode(',', $atts[ids]);          $uniqid = uniqid();     wp_enqueue_script( 'shortcode_flexslider');     wp_localize_script( 'shortcode_flexslider', 'slider', array('id' => $uniqid));           foreach( $ids as $id ) {         $imgLinks       = wp_get_attachment_image_src($id, large);         $imgThumb       = wp_get_attachment_image_src($id, thumbnail);              $slider     .= '
'.$imgCaptionContent.'
';         $carousel   .= '

';      }     $structure ='

'                 .$slider.                 '

'.                      '

'                 .$carousel.                 '

';        });      I put `uniqid` for slider and carousel ids to can put more one flexslider Shortcode in the same post and I localize the `uniqid` to shortcode_flexslider JS file to find slider and carousel ids               $('#carousel'+slider.id).flexslider({       //        asNavFor: '#slider'+slider.id       //     });          $('#slider'+slider.id).flexslider({      //       sync: '#carousel'+slider.id     //     });      The problem is when I put more one flexslider Shortcode in the same post the localized variable slider.id get the last flexslider Shortcode uniqid , so the last flexslider Shortcode is only that works ,how i can pass all flexslider Shortcode `uniqid` not just the last one?


Hide a menu on posts

Is it possible to not have a menu on post pages. I think it would be something like "if page show menu, if post don't show menu" but I'm not sure how to put that into PHP. Thanks


Understanding the theme details in style.css

I'm developing a theme for a friend, and I'm not sure what to put for the author, author uri, etc. Here is the Twenty Ten code:               /*     Theme Name: Twenty Ten     Theme URI: http://wordpress.org/     Description: The 2010 default theme for WordPress.     Author: wordpressdotorg     Author URI: http://wordpress.org/     Version: 1.0     Tags: black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style, custom-menu (optional)          License:     License URI:          General comments (optional).     */        * For Author, is that the blog owner, or the theme creator?   * Author URI, is that the blog owner's personal website, or the creator's?   * License & License URI, these are not open source. How do I specify that?


WordPress Role Capability Restriction

I am working on a travelling site and planning to add following feature to the portal.   1. User Registration capability.   2. Let user manage there profile   3. Let user submit there travel story for approval.   4. Let them edit/modify their posts   5. Provide some other theme/color to the user in dashboard. I have already gone through WordPress Roles_and_Capabilities and seems like it will be able to do most of the work for me. Additionally it seems that `Contributor` role will help me to achieve all of the above mentioned goals except mentioned at level 5. I tested `Contributor` role, but finding one issue with it, logged in user able to see all posts in dashboard (Though can not modify them except his/her own). I only want to show current user the posts he has submitted if he/she has been assigned Role as `Contributor`. I am aware that i can use `remove_cap('capability to remove')` and `add_cap('');` mehods to remove/add capabilities. Is there any way to `extend` the `Contributor` role and add capability to show only user created posts. Additionally is it possible to change dashboard theme for all users who have role below `admin` or `editor`? as a side note, I am not developing any plugin.


Import a very old WordPress Version into new WordPress

Here is my problem: I have been blogging for about six years now at Blogsome.com. I've had no problems with it whatsoever, until a few days ago, when they suddenly announced that they were going to close down on a very short notice. So at the moment I'm looking for a new blog. At the moment I'm thinking of going for a cheap hosted server. My problem is that I want to import all my old posts in the latest version of WordPress. This is problematic because:   * The SQL dump I got out of their backup page is really big (about   30MB). Will this safely import into a new WordPress site?   * Blogsome never updated their WordPress version, so it has been stuck at WordPress Version 1.5.1 for more than half a decade now. How can this SQL dump be safely imported into a new version of WordPress? It's unfortunately the only way I managed to export my blog's database. Blogsome does offer a WRX-file backup option, but that one unfortunately is broken. So what would be the smartest way to handle this?


Stylizing Threaded/Nested Comments

I'm creating my own theme to WordPress. I got problem with nested comments. I don't wanna limit the levels to reply, but I would like them to stay in that format: ![Levels](http://i.stack.imgur.com/OlXPy.png) This is the code I'm using:               <ol class="commentlist">     <?php wp_list_comments('avatar_size=48'); ?>     </ol>      How can I style the class "commentlist"?


using admin functions on frontend

I'm updating my plugin to rely on internal functions of WordPress. I'm about to use `wp_generate_attachment_metadata`, but this function seems to be only available in the admin section. Is there an easy was to enable it on the frontend as well?


How to differentiate the homepage structure from the category page structure in WordPress template?

I am very news in WordPress world and I am finding some difficulties with creation of a personal template. I want implement a blog like this one (that is using WordPress): http://viralpatel.net/blogs/ My blog have to be simplest and there must be only two columns: one for the last posts and one for the most visited posts. I started from an existing template (named Coogee) and have divided the content area (the index.php file) into two columns: the first one shows the new posts and the second one shows the most read posts. I have implement this features with some lines of code that I have put in my columns as show here: http://bacsoftwareconsulting.com/blog/index.php/wordpress-cat/how-to-display- most-viewed-posts-in-wordpress-without-a-plugin/ Ok, now the homepage look good for my intents but I am having some problem in the categories page. For example if you click on the "generic" link on Category menu in the side bar you obtain this page: http://scorejava.com/wordpress351/?cat=2 In theory this page should show ONLY the articles that have the "generic" category but this is not true. In fact, in the left column are correctly showed the articles having "generic" category but in the right column still remain the last 5 posted articles... And now I have a question...seems that WordPress use this `index.php` file as template of the content area of all page (except the one that displays a single article that uses `single.php` file) This is not good for me because I want that a category page show only one big column with the last articles of the current category, as here: http://viralpatel.net/blogs/category/spring/spring3-mvc-framework/ As you can see in this blog there is more columns in the homepage but only one column for the category page Is there a way to define an other structure (different from the index.php file used for the homepage articles content) for the categories page? If I can't use an other structure for the categories page and consequently I have to use the same `index.php` file also per the categories content page....there is a way to show the second column only if the visitor is in the homepage and don't show it if he is in a category page (do not show it if the visitor is in a pge like: http://scorejava.com/wordpress351/?cat=2


Inserting shortcode is blanking excerpt - any ideas?

I wrapped a shortcode around my post content and I have noticed it is making the excerpt blank on archive pages instead of auto generating one from the_content/post. At a loss as to what is causing it or what to try. Its not even outputting the shortcode in `the_excerpt` its just blank. I would have thought if there was going to be a problem it would have been the shortcode appearing as part of `the_excerpt` but its just blank full stop. All my predefined shortcode does is wrap some complex HTML5 tags around the content which an author would make mistakes doing on a regular basis for consistency in certain situations so its not a complex shortcode. My post is outputting perfectly with `the_content`. As soon as I remove the shortcode it works again. If I put the shortcodes back in and set a manual excerpt it works so its only when it has to auto generate `the_excerpt` from a post wrapped in this shortcode. Appreciate any ideas if anyone else has experienced something similar as I am at a loss to explain it or how to resolve. Many thanks. In simple/stripped back terms im wrapping for example this:               add_shortcode( 'ARTICLE_SECTION', 'trg_shortcode_article_section');     function trg_shortcode_article_section_run( $content ) {       global $shortcode_tags;            // Backup current registered shortcodes and clear them all out       $orig_shortcode_tags = $shortcode_tags;       remove_all_shortcodes();            add_shortcode( 'ARTICLE_SECTION', 'trg_shortcode_article_section' );            // Do the shortcode (only the one above is registered)       $content = do_shortcode( $content );            // Put the original shortcodes back       $shortcode_tags = $orig_shortcode_tags;            return $content;     }     // actual shortcode function     function trg_shortcode_article_section( $atts, $content = null ) {              $atts = array();              $output = '
';         $output .= $content . '
';         return $output;     }     add_filter( 'the_content', 'trg_shortcode_article_section_run', 7 );      In partial loop:
<?=trg_excerpt_article()?>
      Ive put in to debug early right at start before anything else just:               function trg_excerpt_article(){       echo '';     }      That returns blank as well.


Users with custom roles not showing in post author select box

I am using a function to create new user roles and delete some defaults. However, they are not showing up in the post author box! Only the admin shows up because they are selected as an admin. Any user with a custom role does not show up. Any idea why this would be happening? Here is my function:               // Add New User Roles     function add_new_roles() {              // New Roles To Be Added         $new_roles = array(             array(                 'role'      => 'senior_pastor',                 'display'   => 'Senior Pastor'             ),             array(                 'role'      => 'exec_pastor',                 'display'   => 'Executive Pastor'             ),             array(                 'role'      => 'assoc_pastor',                 'display'   => 'Associate Pastor'             ),             array(                 'role'      => 'elder',                 'display'   => 'Elder'             ),             array(                 'role'      => 'ministry_leader',                 'display'   => 'Ministry Leader'             )         );              foreach($new_roles as $role){             add_role($role['role'], $role['display'], array(                 'edit_published_posts' => true,                 'upload_files' => true,                 'create_product' => true,                 'publish_posts' => true,                 'delete_published_posts' => true,                 'edit_posts' => true,                 'delete_posts' => true,                 'read' => true             ));         }              // Old Roles To Be Removed         $old_roles = array(             'subscriber',             'contributor',             'author'             'editor'         );              foreach($old_roles as $role){             remove_role( $role );         }     }     add_action('after_switch_theme', 'add_new_roles');


How include the "text/visual" tabs in your own wp_editor instance?

I've made some meta boxes which use the `wp_editor` to create the textareas. When someone is on _any_ page in the admin interface and moves from "visual" tab to "text" tab, all my wp_editor boxes show only a textarea and have no toolbar. Also, when someone switches to "text", it means I can no longer call the `getContent` function (it throws an error). How can I detect this and call a different thing to get the value?


How to use "menu_order" field for posts?

I have a special case where I'd like to order posts in a custom order and it would be great to use the "menu_order" field that is normally only used for pages. What would be the best way to expose that in the WordPress admin UI?


How to setup a permalink structure for a custom post type

I would like to know the correct way to setup the permalink structure for a custom post type. Is there any attribute I am to set when I run a register_post_type() ? e.g.               custom post type: product     expected permalink structure: /product/<slug>


Creating a nav menu

I am not very familiar with WordPress so my knowledge with this is limited. I am working on a travel website where I need to show navigation menu and I am not sure how I can achieve the desired behavior. Here is my case: I need to show destination based drop-down menu and another as category based. Like               Destinations       -Delhi           -Destination1           -Destination2           -More Destinations       -Mumbai            -Destination1           -Destination2           -More Destinations        More      For categories I need to show them as               Category       -Adventure       -Hills       -Romantic       -More      For category part I can create a parent category with child categories and can assign categories to posts as applicable but now sure how to achieve hierarchical menu structure for destination part. Is there anything like hierarchical tags in Wordpress or what are the possible ways to achieve this? Thanks in advance


Custom Post Type Permalink For Parent/Child, 404 Page Not Found Error

Here we have a snippet from a functions.php file...               add_action('init', 'create_recipes');     function create_recipes() {        $recipes_args = array(            ...some properies...,            'hierarchical' => false,            'rewrite' => array('slug' => 'recipes')            ...maybe more properties...        }        register_post_type('recipes',$recipes_args);     }          add_action( 'init', 'recipes_rewrites_init' );     function recipes_rewrites_init(){         global $wp_rewrite;         $gallery_structure = 'recipes/%post_id%/%recipe%';         $wp_rewrite->add_rewrite_tag("%recipe%", '([^/]+)', "recipe=");         $wp_rewrite->add_permastruct('recipe', $gallery_structure, false);     }      This registers a custom post type 'recipes' and sets up the permalink structure so that we can achieve, for example:               (1) example.com/recipes/394/lunch/      On the 'lunch' page I'll extol the virtues of a good lunch. So far, so good. However, what if I want to sub-categorise 'lunch' into 'sandwich', 'burger', 'salad' (e.g. on the 'sandwich' page I will talk about lunch - specifically sandwiches). First I create these extra pages under the 'recipe' custom post type section, and choose the 'lunch' page as their parent. Now I _might hope/presume_ the following will work, for example:               (2) example.com/recipes/513/lunch/sandwich/      Oh dear, this does not work as _presumed_ \- we receive a 404 error. Ok, how do we get to the 'sandwich' page? Let's see...               (3) example.com/recipes/513/sandwich/      Great, that works - but I wanted the 'sandwich' page parent slug ('lunch') to precede it in the URL ( **see (2)** ). How to solve this? Let's start somewhere... **Step 1** What I do know is that if I change `'hierarchical' => false` to `'hierarchical' => true` then the `the_permalink()` function will (as is desired) construct the permalink as in (2). Great, but this will result in a 404 error with **(2)**. I'm guessing I've either made a mistake in the `create_recipes` function, or perhaps I haven't done enough in the `recipes_rewrites_init` function. **Step 2** I suppose I could (in theory) hook into the WP permalink functionality to intercept the request/permalink, retrieve the post's parent slug (if it has one), and drop it in just before the post's slug. However, that presumably only modifies the resulting permalink, which I've already done in Step 1. What I really need is to ensure the request is routed correctly. **Questions** How do I go about doing this? Is there a known WP way (i.e. existing functionality/options in the initial custom type setup)? **Other thoughts** I'm also aware that Custom Taxonomies can be used (at least in part) to solve the problem of categorising posts - and that there exists a plugin(s) to help. However, I would like to initially stick with Custom Post Types if possible. Thanks. * * * **Update 1** I'm now aware of a plugin called "Posts 2 Posts" which, among other things, enables connections between custom post types - specifically, between different custom post types. However, for my example I am using just one custom post type, and trying to have a natural parent-child hierarchy (which seems like a fairly standard WP thing) rather than forcing a relationship between disparate custom post types. * * * **Update 2** Some further information and a solution of sorts. Here are two important things:   1. Adding custom permalink structures to custom post types can be **_tricky_**.   2. Adding custom permalink structures to custom post types may be **_unnecessary_**. I realised I was fighting Wordpress's excellent out-of-the-box permalink functionality by creating an [unnecessary] custom permalink structure (e.g. `example.com/recipes/513/lunch/sandwich/`) which in retrospect is convoluted; my reasoning was that the post ID should be present in the URL for performance reasons (as opposed to just slugs, which might be slower for WP to match). I imagined this might be possible, but may not be worth the trouble. Instead, I ripped out my custom permalink stuff and just let WP resolve, for example, `example.com/recipes/lunch/sandwich/` \- which now works exactly as expected. Remember to set `'hierarchical' => true`, and the world is your permalink. **Conclusion** If you insist on doing what I was trying to do, it may be possible but will require properly setting up a custom permalink structure to avoid the 404 errors (my original problem). For now I'm going to stick with the standard WP hierarchical permalink functionality.


Jetpack: what happens to email subscribers if I access admin on a subdomain?

I am currently running my site via http on a url like `domain.com`. In order to continue to make use of CloudFlare's free tier of service, I want to put my admin on a subdomain like `secure.domain.com` and access it over SSL (I would set up `secure.domain.com` to bypass CloudFlare). Having just recovered from a scary episode of losing all of my blog's Jetpack email subscribers as a result of testing this scheme on a test server with a totally different domain name, I am a little nervous about what the effect will be of changing the URL of access to the admin. Does anyone have experience in doing this kind of thing and/or can anyone explain how Jetpack associates email subscribers with a given blog URL and what to expect when changing the URL for the admin to a subdomain?


How to add orderby parameter for sorting on category.php

I'm on a Category.php page which does the loop like this:               <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>      I usually do a custom loop like this:               <?php //Define the Loop         $temp = $wp_query;         $wp_query= null;         $wp_query = new WP_Query();         $wp_query->query('posts_per_page=2&orderby='.$orderBy.'&paged='.$paged);         ?>      I want to add the orderby variable to the first loop (the one on category.php) but can't figure out how to implement it.


Can I call a custom plugin with a direct URL

Suppose I have written a `hello world` plugin, the main function is just print out a sting `hello world`. I want to print out `hello world` when I access the URL likes `http://example.com?plugin=helloworld` Is it possible to make the `hello world` plugin functional when I access a specific URL?


Login after "Read More" then return to article

When a user clicks on an article to "read more" and is then prompted to log in with user name and password, We would like the user to be returned to the article directly instead of being returned to the home page. We are using the soap-authentication plugin: http://matthewkellett.co.uk/portfolio/soap-auth.php Using the redirect_to on the loginform's action doesn't work at all. **Adding code** wp-content/plugins/soap-authentication/soap_auth.php               function login_redirect($redirect_to, $request, $user)     {         $opts = Soap_Auth::getOptions();              //is there a user to check?         if(is_array($user->roles))         {             //check for admins             if(in_array("administrator", $user->roles))                      return home_url("/wp-admin/");             else             {                 return $opts['auth_url'];             }         }     }      replaced else by                       else             {                 if ($redirect_to =='')                 {                     return $opts['auth_url'];                 }                 return $redirect_to;             }


Category and Sub category

![wordpress](http://i.stack.imgur.com/Kif5Y.png) There are two main categories such as Job by Education and State wise jobs, if a Job related post is posted how the post can be listed in both the two main categories and sub categories,


Perform database function in target URL using jQuery.post

I have a popup which gets the users input (name and email) and sends it to a process.php so I can send an email. I pretty much have that done. But I need to add a functionality wherein it will also the users input to the database (I already have the table for this). My process.php is this:               <?php         $to      = 'myemail@gmail.com';         $subject = 'Join '.$_POST['title'].' Event';         $message = '                                                                     Name: '.$_POST['participant'].'
                 Email Address: '.$_POST['email'].'
                 Message: '.$_POST['message'].'                                       ';         $headers  = 'MIME-Version: 1.0' . "\r\n";         $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";         $headers .= 'From: '.$_POST['email']. '\r\n';              mail($to, $subject, $message, $headers);              echo "You have successfully signup up for this event";     ?>      I tried adding this:               global $wpdb;     $table = 'wp_mytable';     $name = $_POST['participant'];     $email = $_POST['email'];     $event = $_POST['title'];          $wpdb->insert(         $table,         array(             'id' => '',             'name' => $name,             'email' => $email,             'event' => $event,         ),         array(             '%d',             '%s',             '%s',             '%s',         )     );      But I get a fatal error. I also tried adding `require_once(../wp-load.php)` But still no good. Thanks in advance!


Ajax call activate after submit in edit-tags.php page

Is there a proper way to activate a ajax call in wordpress in the edit category page after the submit is pressed?


Problem with quotes

I have a strange problem with the latest version of Wordpress: Some writers, when they write a story, you see the quote character `'`, replaced with `/`, something that does not happen to me. Is there any special settings in the CMS that could cause this annoying problem?


Can I protect a type of content site-wide with a single password?

I am developing a theme for a client who has a catalog of products. Each product has a spec sheet that he wants to make available to logged-in users. It's not a real security issue, just a means to simplify the page for casual visitors. Right now he emails clients a password and keeps track of logins based on which password he gave out. He'd like to continue doing that. So I'd like to come up with a way of:   * logging a user in with a single field   * using `is_user_logged_in()` and related inquiries to check whether to display links to the protected content   * denying such visitors access to the Admin side completely Is this out of the scope of WP user roles? If not, any suggestions on how I could achieve this?


Open wordpress media library in 3.9.1 version

I can not speak English....I hope you understand my question. I have this code that opens the media library, but it only works in wordpress 3.6.1 and lower version               <script>     var file_frame;           // "mca_tray_button" is the ID of my button that opens the Media window      jQuery('#mca_tray_button').live('click', function( event ){          event.preventDefault();            if ( file_frame ) {           file_frame.open();            return;        }             file_frame = wp.media.frames.file_frame =   wp.media({            title: jQuery( this ).data( 'uploader_title' ),            button: {                text: jQuery( this ).data(  'uploader_button_text' ),            },            multiple: false          });             file_frame.on( 'select', function() {              attachment =        file_frame.state().get('selection').first().toJSON( );              // "mca_features_tray" is the ID of my text. field that will receive the image            // I'm getting the ID rather than the URL:                jQuery("#mca_features_tray").val(attachment.id);                 // but you could get the URL instead by doing something like this:               jQuery("#mca_features_tray").val(attachment.sizes.thumbnail.url);                 // and you can change "thumbnail" to get other image sizes              });             file_frame.open();             });      </script>          <button id="mca_tray_button">Open Media</button>      Now I want a code (for 3.9.1 version) that opens media library and user can select a file then return the file's url in a input.


Check and dequeue if multiple stylesheets exists using wp_style_is?

I need to dequeue styes for 3 plugins that load the same font stylesheet so i come up with the following function that of course not working:               add_action('wp_enqueue_scripts', 'dequeue_by_handles', 999);     function dequeue_by_handles() {         $handle = array(             'fontawesome',             'font-awesome',             'font-awesome-style'             );              if( wp_style_is( $handle, $list = 'enqueued' ) ) {             wp_dequeue_style( $handle );         }     }      Please note that firstly I need to check if a stylesheet handle exist then dequeue it. Thank you.


Is it possible to make grandchild themes?

If I use one of the popular frameworks such as Genesis, is it possible to create grandchild themes? As an example, I want to use Genesis as the backbone of all my sites. Genesis is called a framework but is actually a parent theme. Then I select one of the Genesis child themes for sale at StudioPress, and want to continue customising it for each of my sites. Would I be creating a grandchild theme for all of my sites, and how would I go about it?


get the post thumbnail returns the full size

The function `get_the_post_thumbnail($post->ID, 'thumbnail');` not always returns the thumb size of the image (which is 100x100) for some posts it does but for most of them it doesn't. Even though the actual file exists (say for image `myImg.jpg` there is a thumb image under the name `myImg-100x100.jpg`) but still the function returns the full size. any thought on troubleshooting this? Update, I just noticed that the images that are returning the full size are named in Arabic characters, could this cause the issue?


Custom Post Type link not showing content

I have created 2 custom post types. One called artist and one called work. When I create a post in artist and view it the link is fine and I can view the content. However in work when I add a new post and go to view it it says that it cannot find the content and the page is missing. Here is my functions.php code.               add_action( 'init', 'create_post_type' );     function create_post_type() {     register_post_type( 'artist',         array(             'labels' => array(                 'name' => __( 'Talent' ),                 'singular_name' => __( 'talent' )             ),         'public' => true,         'has_archive' => true,         'supports' => array( 'thumbnail' ),         'supports' => array('thumbnail', 'title', 'editor'),         'rewrite' => array('slug' => 'talent'),              )     );          register_post_type( 'work',         array(             'labels' => array(                 'name' => __( 'Content' ),                 'singular_name' => __( 'content' )             ),         'public' => true,         'has_archive' => true,         'supports' => array( 'thumbnail' ),         'supports' => array('thumbnail', 'title', 'editor'),         'rewrite' => array('slug' => 'content'),              )     );     }


Do I need to resize an image to fit the post?

I'm going to post an image in a blog post, first uploading the image to my server, and using its url. If the image is bigger than the maximum width of my blog-post, will it take longer to download, or will WordPress squish the image for the space it has to fit? If I need to make the image the right size to fit, what size? My blog is at http://wordfruit.com/blog Thanks,


How can I highlight admin comments?

Basically what I want is to have all comments posted by admins with different background color than the rest, so they're easily distinguishable. I wasn't able to find any plugin that would do this though, and hacking it into the theme doesn't look very clean. Any suggestions?


Several loops in sidebar issues

I've created sidebar tabs that display the most recent, popular and random posts. In other words I'm creating several loops in my sidebar. This seems to cause some problems, though. Do I have to reset something or just use a complete different code overall? The code for the sidebar tabs looks like this:

 Popular

Recent

Random

          <?php     $pc = new WP_Query('orderby=comment_count&posts_per_page=5'); ?>          <?php while ($pc->have_posts()) : $pc->the_post(); ?>
     <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(array(50,50)); ?>     <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>  <?php comments_popup_link('(0)', '(1)', '(%)'); ?>
Posted on <?php the_time('F jS, Y') ?>
     <?php echo excerpt(8); ?>

          <?php endwhile; ?>     <?php wp_reset_query(); ?>

     <?php     $rp = new WP_Query('orderby=date&posts_per_page=5'); ?>          <?php while ($rp->have_posts()) : $rp->the_post(); ?>
     <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(array(50,50)); ?>     <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>  <?php comments_popup_link('(0)', '(1)', '(%)'); ?>
Posted on <?php the_time('F jS, Y') ?>
     <?php echo excerpt(8); ?>

          <?php endwhile; ?>     <?php wp_reset_query(); ?>

     <?php     $ranp = new WP_Query('orderby=rand&posts_per_page=5'); ?>          <?php while ($ranp->have_posts()) : $ranp->the_post(); ?>
     <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(array(50,50)); ?>     <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>  <?php comments_popup_link('(0)', '(1)', '(%)'); ?>
Posted on <?php the_time('F jS, Y') ?>
     <?php echo excerpt(8); ?>

          <?php endwhile; ?>     <?php wp_reset_query(); ?>

      The current issue is that the first tab "Popular" displays 5 posts as it should, but the other 2 tabs display 6 posts, although I've clearly coded it so that only 5 should be displayed!!!! My website is here for reference (if you use IE - and I hope you don't - please don't be shocked that apart from the tab above none other is working - there are a lot of issues in IE suddenly (since yesterday) possibly caused by CSS, maybe some HTML error - am working on it currently). Thanks a lot in advance!


BBCode & BBPress 2.0?

I've been trying to get bbcode working in BBPress content, using various plugins. I'm running WP (3.2.1), BuddyPress Plugin (1.2.10) and BBPress 2.0-rc-5. I've got bbcode working in wp posts and comments via some modifications of this plugin http://wordpress.org/extend/plugins/bbcomments/ All I've done is add a few more add_action lines:               add_action('the_content', 'render_comment', 1);     add_action('the_content', 'render_comment_code', -1);      Though making the BB code work inside BBPress topics and replies is proving tricky, I've tried adding:               add_action('bbp-reply-content', 'render_comment', 1);     add_action('bbp-reply-content', 'render_comment_code', -1);     add_action('bbp_topic_content', 'render_comment', 1);     add_action('bbp_topic_content', 'render_comment_code', -1);      But no dice. I also tried calling the plugin function and the actions inside bbp-common-functions.php. My PHP knowledge is pretty limited, so any advice on where to look next would be appredciated.


Public posts - preventing duplicate form submissions

I'm creating a public form on a page that allows non-registered (public) visitors to create posts of a custom post type. I'm using nonces, which I naiveley thought would expire once they were used. This doesn't appear to be the case. This post seems to address the issue by creating a meta field and verifying that it doesn't exist before creating the post. Is there a best practice that prevents double-form submissions (that doesn't require writing a meta field?) T


Add option to "Gallery Settings" section

I want to add a option to the "Gallery settings" (when you insert a gallery into a post). I once found some code on how to do this, but unfortunately I can't find it anymore. I can't even remenber if it was a hook, but I think it was some hackish stuff ;-) Thx


How safe / sanitized is wp_insert_posts()?

Looking at the Codex for wp_insert_post() it states that this function "...sanitizes variables, does some checks, fills in missing variables like date/time, etc. " (EDIT: I updated the Codex entry to include a more robust example that includes security as well as post meta and category assignment) Just wondering whether I need to do any further sanitization to prevent XSS hacks and the like or whether enough is being done through the function. To be honest, I've checked through the function in core and haven't found any wp_kses() or other sanitization on post_content for example, so I'm a little concerned. All I can see that it does is stripslashes_deep() on the data. So should I be running wp_kses() or anything else when I build my arguments to wp_insert_post()? What's the best practice here? The Codex is pretty cavalier about security in its example. Thanks


Adding function directly vs using hook in function.php

We can use functions like `register_nav_menu()` directly in `function.php` and it works and we can also use a function to put `register_nav_menu()` inside of it and attach that function using a `hook` like init and it works as well. Why do we need to use a `hook` in that particular situation?


Custom Post Type title not populating

I am attempting to get the title displayed for a function. I am sending myself an email to see if I can get this to work for different titles. Currently the only way I can get it to work is via hard coded number inside the get_the_title. my example below works.               $tweetingthing = get_the_title(1067);                 $to      = 'myemail@email.com';         $subject = 'Hi!';         $body    =  'Hi,' . chr(10) . chr(10) . 'Hi title= ' .  $tweetingthing . ' page id is   ' . $this_page_id;                   if( wp_mail($to, $subject, $body ) ) {             echo('
Message successfully sent!
');         } else {             echo('
Message delivery failed...
');         }      I obviously want more than just that one title, I'd like each title to be sent via email. I have tried this:               global $post;     //$thePostID = $post->ID;     $wp_query->post;     $this_page_id = $post->ID;     echo $this_page_id ;     $tweetingthing = get_the_title($this_page_id);              $to      = 'mh@gmail.com';         $subject = 'Hi!';         $body    =  'Hi,' . chr(10) . chr(10) . 'Hi title= ' . $tweetingthing . ' Post id is   ' . $this_page_id;                   if( wp_mail($to, $subject, $body ) ) {             echo('
Message successfully sent!
');         } else {             echo('
Message delivery failed...
');         }      This provides null for $tweetingthing and $this_page_id (I know it's a post id I'm trying to get I simply used the variable giving in the example hope that doesn't confuse anyone). I also tried               $tweetingthing = get_the_title($post_id);      also tried $tweet_post_id = the_ID(); $tweetingthing = get_the_title($tweet_post_id); no luck               $page_object = get_queried_object();     $tweetingthing = get_queried_object_id();      results in a post title of 0 Addition info: I'm using a status transition action to make the function fire. When it goes to publish and matches the custom post type it performs. I'm using a custom post type How can I get Custom Post Title? full source code :               function intercept_all_status_changes( $new_status, $old_status, $post ) {      if ( $new_status == 'publish' && get_post_type( $post ) == 'tweet' ) {          // Post status changed          twitter_run_when_published ();      }     }       add_action( 'transition_post_status', 'intercept_all_status_changes', 10, 3 );               function twitter_run_when_published () {     //     //email the stuffuff     //           global $post;      global $wp_query;      //$thePostID = $post->ID;      $wp_query->post;      $this_page_id = $post->ID;      echo $this_page_id ;              $to      = 'meanderingmonarch@gmail.com';         $subject = 'Hi!';         $body    =  'Hi,' . chr(10) . chr(10) . 'Hi title= ' . $tweetingthing . ' Post id is   ' . $this_page_id;                    if( wp_mail($to, $subject, $body ) ) {              echo('
Message successfully sent!
');          } else {              echo('
Message delivery failed...
');          }     }      So after @nickyoung mentioned this was weird I thought I'd try a if status changes at all send an email. It sent me 4 messages. The first: title was not there (post status not there) The second: title was not their (post status not there) The third: title WAS there (and post status was draft) The fourth: no title and post status was not there edit: just cleaned up some jibberish sentences edit2: Added full source code to see if anything may help edit3: Added extra info about post status transitions


How to assign the default file at "Appearance > Editor"?

My theme has a custom.css file that I use to allow designer's to customize the it to their liking. However, when clicking on "Appearance > Editor", the style.css file is loaded there by default. Since I don't want custom edits done on this file, I'd like to minimize the chances that someone edits it by placing custom.css there instead. Is this possible? Perhaps with the shiny new 3.2 codebase?


Showing all post from all post type in admin backstage

I try to create an admin page where to display all posts from all custom post type. It is something like in edit.php, but instead of displaying single post type,I would like to display all posts in one page from multiple custom post type. I follow the tutorial at here to create the table. Everything is fine, but there is somethings that I can't solve. Actually the problem mostly in php rather than WP itself. Here is where I trying to do : query the posts from the desired custom post types,and from the object return store it in array for further use. Here is my codes :               function getallposts() {         global $current_user; // i need to show the posts depends on the user id.         get_currentuserinfo();                    if(!current_user_can('administrator') && current_user_can('edit_posts') ) {              $userid = $current_user->ID;              } elseif(current_user_can('administrator')) {$userid='1';} // administrator can view all the posts, but the users only view their own posts             $args = array(        'numberposts'     => -1,        'offset'          => 0,        'orderby'         => 'post_date',        'order'           => 'DESC',        'post_type'       => array('cpt1','cpt2'),//post types that i need to query        'author'          => $userid,//this is refer by the user login info above        'post_status'     => 'publish' );         $myposts = get_posts( $args );//here using get_posts to query the post.              $myitems =array();//declare the the array.         foreach ($myposts as $post) {         $metavalue = get_post_meta($post->ID, 'rating', true);//get the meta value for the post              $myitems =array (         'post_title' => $post->post_title,         'ID'=>$post->ID,          'post_author'=> $post->post_author,         'post_date' => $post->post_date,         'rating' =>$metavalue         ); // i want to store it in an array for further use.don't know if I am doing right.          }return $myitems;//here is i don't get the idea to return the array from $myitems above}      If the code above is too complicated, in a nutshell here is what I trying to do:               function getallposts { //get the posts query in a function               $args = array ();                $allpost = get_posts($args);//here is to get the posts by argument form $args             foreach ($allpost as $post){              $post_title = $post->post_title...               .....  //define some of the  object that needed for further use.              $value = array($post_title.....);//the defined object is store in an array for further use.             }                  return $value //return the value//here is I don't know how to return the value.          }      My intention is to sort the $value in this way:               $example_data = array(       array('ID' => 1,'booktitle' => 'Quarter Share', 'author' => 'Nathan Lowell',         'isbn' => '978-0982514542'),       array('ID' => 2, 'booktitle' => '7th Son: Descent','author' => 'J. C. Hutchins',         'isbn' => '0312384378'),       array('ID' => 3, 'booktitle' => 'Shadowmagic', 'author' => 'John Lenahan',         'isbn' => '978-1905548927'),       array('ID' => 4, 'booktitle' => 'The Crown Conspiracy', 'author' => 'Michael J. Sullivan',         'isbn' => '978-0979621130'),       array('ID' => 5, 'booktitle'     => 'Max Quick: The Pocket and the Pendant', 'author'    => 'Mark Jeffrey',         'isbn' => '978-0061988929'),       array('ID' => 6, 'booktitle' => 'Jack Wakes Up: A Novel', 'author' => 'Seth Harwood',         'isbn' => '978-0307454355')     );      Thanks


How to check if upload window came from the featured image link?

I need to verify if the media-upload screen came from a click on the "feature image link" on the admin screen. How can i do it? I've already change the way the uploader works , but I need to check this because there is a special flow for the featured image upload.


Translate custom taxonomy terms

I got one problem about translating taxonomy terms. Situation: I have multisite instalation with many sites in different languages. I am using broadcast plugin that broadcast some post types and taxonomies through all sites from main site. I use poedit to translate strings in that different sites for different languages. Problem is that every time I sync taxonomies they refresh to default name. Is it possible to translate broadcasted taxonomy terms in poedit with .po and .mo file on particular site. When I sync data terms I use same taxonomy but different label on diffrent site. Thank you very much, Best regards!


Custom Taxonomy tree view not showing correctly in backend

I'm using a Custom Post Type **product** with the Custom Taxonomy **product_category**. When editing a product in WordPress, there is a problem with displaying the product categories tree view right. When an item is checked, it will move to the top of the list. When this item is a top level category, the child categories stay in the same spot in the list and therefore aren't shown correctly. When an subcategory is selected, it will also move to the top of the list. It isn't shown in the tree view anymore. An example:               Before selecting:     O - A     O   - A.1     O   - A.2     O   - A.3     O - B     O   - B.1     O   - B.2     O   - B.3          After selecting:     X - A.2     X - B     O - A     O   - A.1     O   - A.3     O - B.1     O - B.2     O - B.3          O = unchecked     X = checked      I thinks it's a WordPress bug but I can't find the problem in the WordPress core files. Does anyone know a solution?


Use reserved subdirectory for multisite

Whenever we try to go to domain.com/blog, we are redirected to primary- domain.com. How can I set it so that domain.com/blog stays its page. Our setup is a WordPress multisite install with subdirectories. We have sites which use multiple domains. Our primary site is at primary-domain.com, which is not viewable by anyone outside of our intranet. For example our sites include primary-domain.com/ <\--not viewable by public.   domain.com/subdirectory <\--works   different-domain.com/different-subdirectory <\--works   domain.com/blog <\--redirects to primary-domain.com   I've already filtered "blog" from the reserved subdirectory and tried filtering permalinks and rewrite rules. I've also tried going into the database to remove references to "blog/" in the permalink fields and the rewrite fields in the wp_1_options table. I've also tried various methods to remove the "blog" slug from the main site but the domain.com/blog site always redirects to primary-domain.com. At this point if someone can just point me in the correct direction, it would be a big help.


Best function/method to access wp-config?

I have a developer who is accessing the wp-config file directly to get database information. I would think that WP has a better way to do this. What do you think community?


How do I get the top-level terms in a custom taxonomy?

I have a custom hierarchical taxonomy setup for a conference website. The top- level terms in this taxonomy are Dates, which have child terms representing session slots on that date. I'm trying to figure out how to get a list of the top-level terms within the taxonomy, that is I only want the terms that are Dates, not the terms that are sessions. Is this possible using `get_terms()`?


Creating custom shortcode

I'm trying to create some custom shortcode - I want to be able to have names and numbers of people I want to display on my website, but as a shortcode, so it doesn't have to be typed in again and again. So for instance to have [joe] relate to 'Joe Bloggs - 01925 265646' I'm currently using the Ultimate Tables plugin and would want to put the shortcode into this, and then for it to come up with the longer information. I've been playing around for a few hours and still struggling - I've tried putting it directly into functions.php and have tried using the 'Shortcodes Pro' plugin but I can't figure out how to make it work (sorry, I'm not a massively advanced Wordpress user!). This is the code I put into the functions.php section of the theme:               // Add Shortcode     function joe() {     }     add_shortcode( 'Joe Bloggs - 01925 265646', 'joe' );      Pretty much, my aim is to avoid having to manually enter phone numbers because on our old website this led to the phone numbers being entered incorrectly sometimes, as they are entered about dozens of times. Thanks so much for your help in advance.


Admin moderates ALL comments (including post author)

I have comments enabled on my custom post type page, which works well but I need the admin to moderate all comments before they are published. At the moment the post author whose level is 'contributor' is able to post comments without being moderated. I can't find any way to do this currently, nor can I find any plugins. Any help would be much appreciated!


Changing the header image using WPML

I've got an issue with changing a header image based on language and the file path to the image. Have tried relative and absolute paths but still end up with a broken/missing file icon. In my functions I have:               function header_image_switcher() {         switch( ICL_LANGUAGE_CODE ) {                  case 'en':                 $link_to_image = '/images/top-header-en.png';                 break;                  case 'fi':                 $link_to_image = '/images/top-header-fi.png';                 break;                  case 'sv':                 $link_to_image = '/images/top-header-sv.png';                 break;                  return $link_to_image;         }     }      and the template contains               echo "<img src=" . header_image_switcher() . " />";      My images folder is outside of the theme and in the same folder as my install but the images still won't load. Any obvious mistakes I'm making?


Show last 5 posts from specific category

I'm trying to show the last 5 posts from a specific category, which will be linked to a function so i can insert the shortcode in a Wordpress page. The code i have is as below, it does everything i need (although i want to add featured image too) except it does not show posts from a specific category. I've tried numerous things, but cannot find a working fix.               function Last5posts()     {     $args = array( "showposts" => 5, "category" => 3 );                       query_posts($args);          $content = "";          if( have_posts() ) :               while( have_posts() ) :                  the_post();             $link = get_permalink();             $title = get_the_title();             $date = get_the_date();                                                $content .= "
";             $content .= "
$title / $datehave_posts()) : $catquery->the_post();       Any help would be greatly appreciated.


Display custom post data in sidebar w/ dropdown

I'm trying to set up a sidebar area that'll do two things:   1. Display a drop-down of posts in a given custom post types.   2. Display post metadata (content and custom fields) if selected post The thing that's getting me is two-fold:   1. Having the selected post metadata display in the sidebar once selected via the dropdown   2. Having the content refresh via ajax or jquery so it doesn't refresh the entire page


Is there any way to draft a revision of a published page or post? What workarounds have you used?

Say I've already published a page or post. I now want to make changes, but I want a colleague to check them over before they go live. Is there any way of doing this? **Edit: I do realise this isn't currently possible as such and it's creative workarounds I'm interested in.** On the site I'm currently working on, I also have a separate password protected 'staging' site for drafting major content changes/additions, and once approved I copy and paste to the live site. I'm wondering if anyone's used a similar method, but perhaps automated the 'push' to the live site? I'm aware of this question: Database synchronization between dev/staging and production, but that's more about wholesale synchonization of entire databases rather than individual pages or posts. **Now offering a bounty in order to try and drive out some additional ideas for workarounds.**


I want to take out reviews tab from single product page?

I want to take out the reviews tab from single product page in woocommerce. I mean i want to display reviews tab below the product description tab in single product page. Please help me out.


adding a text message beside the comment submit button

What is the cleanest way to display a text message beside the submit button like this in screen shot: ![example of what I am talking about](http://i.stack.imgur.com/ybV6Y.png) I am currently doing it by editing the file `wp-includes/comment-template` line `1577` (wordpress 3.5) before:               <input name="submit" type="submit" id="<?php echo esc_attr( $args['id_submit'] ); ?>"      value="<?php echo esc_attr( $args['label_submit'] ); ?>" />       after:               <input name="submit" type="submit" id="<?php echo esc_attr( $args['id_submit'] ); ?>"      value="<?php echo esc_attr( $args['label_submit'] ); ?>" />      (your message will only be visible after moderation)      I understand this is not the optimal way to do it, but what is the way to do it. I prefer as a plugin, but editing a theme would be fine.


query_posts exclude a meta key

<?php query_posts(array('showposts' => 1000, 'post_parent' => $post->ID, 'post_type' => 'page', 'orderby' => 'title', 'order' => 'ASC', 'meta_key' => featured_product, 'meta_value' => 1)); ?>               <?php query_posts(array('showposts' => 1000, 'post_parent' => $post->ID, 'post_type' => 'page', 'orderby' => 'title', 'order' => 'ASC')); ?>      I have 2 queries, first to show meta key with featured_product eq 1. So I want to exclude all the featured products on the second query. How can i do that please? Thanks!


Under Theme folder, what's sequence of action for index.php, page.php, single.php?

INdex.php, page.php and single.php all three files under the theme folder have the Loop to check for posts. Which one get execute first, and the next? What's sequence for Wordpress to read those files?


Get video from the post on homepage

I have embedded videos in the post (from youtube and other websites). Is it possible to get only the embedded video from the post and display on the homepage? There is some text before the video in the post, I do not want to display the text or anything else from the post, but only want to get the video. How that can be done? Thanks.


Display content from a specific category

I'm trying to get my news page to display content from one category only (number 3) but I cant seem to get it to work. Instead of just displaying posts from category 3 it displays posts from all category's. Here is my code:               <?php get_header(); ?>

Latest News
                                      <?php $args = array(                                 'post_type' => 'post' ,                                 'orderby' => 'date' ,                                 'order' => 'DESC' ,                                 'posts_per_page' => 6,                                 'category'         => '3',                                 'paged' => get_query_var('paged'),                                 'post_parent' => $parent                            ); ?>                            <?php query_posts($args); ?>                                                <?php if ( have_posts() ) : ?>                                 <?php while ( have_posts() ) : the_post(); ?>

                                         <a href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?>                                              <a href="<?php the_permalink() ?>">
<?php the_title(); ?>
                                         <?php the_excerpt(); ?>
<a href="<?php the_permalink() ?>" class="readmore_news">Read more

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

          <?php get_footer(); ?>


How to customize the wp-signup.php for a multisite network?

I googled about customizing `wp-signup.php` but found no luck. Here's what I need:   1. User will register.   2. During registration process, user will pay first (like paypal or credit card).   3. Create subdomain when user successfully paid. My problem is: How can I add a payment field in `wp-signup.php`? I am really new to wordpress. Any guide or link is a big help to me. Registration form something like this:   * username   * email address   * gimme a site   * payment   * …   * register button


Changing the pagination URL format

Currently when I use the `next_posts_link` and `previous_posts_link` functions I get a URL returned such as `/posts/page/2`. However, is it possible to make Wordpress work with a pagination URL format such as `/posts?page=2` instead?


Is it bad to store many files in a single folder?

I upload thousands of images and it stored in a single folder. Is it bad if too many images are in a single folder? would that slow down the loading of the image even though you're viewing an attachment image which has a path defined?


Bridging TinyMCE js and Wordpress PHP?

I'm updating my wordpress plugin to use a custom TinyMCE button. From inside the TinyMCE button javascript, I'd like to interact with wordpress data--ie set custom post options inside the plugin setting page, then access those values inside the TinyMCE js script. Can I invoke my php plugin functions from inside the TinyMCE button handler code (which is javascript)? Is there a bridge I can use? For Clarification: As part of my plugin installation process, users are instructed to go to the Plugin settings page, and input some data. This data is normally stored and read using Wordpress Plugin API hooks: `get_option` and `set_option` This is part of my original plugin and works fine. I am now adding a TinyMCE button, and when I click it, an HTML page is shown, that has an html `textarea`. This part also works fine. However, I'd like to Fill the `textarea` with data via the `get_option` Wordpress Plugin call, but I can't figure out how to access the API. Another acceptable solution would be to pass that data into the TinyMCE script, and injest it that way. Or to have the TinyMCE button script invoke a method in my PHP plugin script that reads and returns that data back into the TinyMCE button script.


change precedence of permalink for post_types?

I have a series of pages with the heirarchy: ` /albums /name1 /name2 /name3   ` ie. all these pages have a parent page with the slug 'albums'. If I have a permalink /name2 it shows the page /albums/name2. I didn't need to fully express the link as /albums/album2 I also have a post_type called 'songs' which is not hidden, but would be far less often visited. ` /songs/name1 /songs/name2 /songs/name3 ` So there are Pages and 'Songs' with the same slug. In the past, simply typing mysite.com/name2 would bring up the -Page- (ie. /albums/name2), not the Song. This has changed. Now, if I type: mysite.com/name2 into the browser, /songs/name2 appears. So the precedence of 'Songs' appears now to be higher in the redirection 'hierarchy'. How can I change it back to the way it was... ie. when a visitor types: mysite.com/name2 into the browser, the -Page- /albums/name2 appears? I have experimented with all number of values for the Rewrite array to no avail for the simple reason that it's not the permalink that is the issue, it is the fact that in the WP_Rewrite Rules, the 'Songs' post_type is processed -first- for some reason, so if there are two posts with the same slug, one 'Page' and the other 'Song', the Song will be rendered. I have been working around this by simply setting the Public property for 'Songs' to false, but that's no long term solution. Help!


Save post_parent in a custom post type

I'm using the save_post action to save some meta data in a custom post type:               function my_save_post($post_id) {         // is autosave?         if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {             return $post_id;         }              // verify nonce         if ( !wp_verify_nonce( $_POST['metabox_nonce'], basename(__FILE__) )) {             return $post_id;         }              if ('book' == $_POST['post_type']) {             $post_parent = intval($_POST['post_parent']);             $author = $_POST['author'];             $price = intval($_POST['price']);             update_post_meta($post_id, 'author', $author);             update_post_meta($post_id, 'price', $price);                  //TODO: add function to update the post_parent field         }     }      My question is, how can I modify the custom post type's post_parent field? As I understand, I can't use the update_post_meta() function because the post_parent field is not a meta field. Am I right? Any help would be appreciated


How to display custom taxonomies with links in filter menu?

Since two days I am trying to solve a problem with custom taxonomies (categories). I have a Custom Post Type called 'Portfolio' and it works as expected but a problem is with my hierarchical taxonomy that I have registered. I gave it a name: 'galleries'. Instead of displaying custom taxonomies it simply shows default categories from my blog. I found some similar problems on here but I realy don't know how to adopt other's solutions into my case. I am quite new to wordpress unfortunately. Can someone help me? This is the code from my loop.php which is the template of my custom post type (this is my home page):
     Filter

All
         <?php $args=array('orderby' => 'name');         $galleries=get_categories($args);         foreach($galleries as $gallery){ ?>
<a href="#<?php echo $gallery->gallery_nicename; ?>" class="<?php echo $gallery->gallery_nicename; ?>"><?php echo $gallery->name; ?>
         <?php } ?>

      Here is the code from my function.php:               add_action('init', 'portfolio_register');     function portfolio_register() {          $labels = array(             'name' => _x('My Portfolio', 'post type general name'),             'singular_name' => _x('Portfolio Item', 'post type singular name'),             'add_new' => _x('Add New', 'portfolio item'),             'add_new_item' => __('Add New Portfolio Item'),             'edit_item' => __('Edit Portfolio Item'),             'new_item' => __('New Portfolio Item'),             'view_item' => __('View Portfolio Item'),             'search_items' => __('Search Portfolio'),             'not_found' =>  __('Nothing found'),             'not_found_in_trash' => __('Nothing found in Trash'),             'parent_item_colon' => ''         );         $args = array(             'labels' => $labels,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,             'query_var' => true,             'menu_icon' => get_stylesheet_directory_uri() . '/images/portfolio-icon.png',             'rewrite' => true,             'capability_type' => 'post',             'hierarchical' => false,             'menu_position' => null,             'supports' => array('title','editor','author','thumbnail','comments')           );          register_post_type( 'portfolio' , $args );         flush_rewrite_rules();     }     // Custom taxonomy for Portfolio Categories (Galleries)     register_taxonomy('galleries', array('portfolio'), array('hierarchical' => true, 'label' => 'Galleries', 'singular_label' => 'Gallery', 'rewrite' => true, 'public' => true ));      Thanks in advance!


Using permalinks, category slugs, and tag slugs

I'm trying to set up some permalinks for my site. Right now all the posts are under sitename.com/blog/, which is fine. But the category pages and tag pages show as 'sitename.com/blog/category/catname' and 'sitename.com/blog/tag/tagname'. Is there a way to just skip the 'category' and 'tag' parts of the URL? As in: 'sitename.com/blog/catname' 'sitename.com/blog/tagname' I tried leaving the optional settings (Settings --> Permalinks --> Optional) as blank for 'Category base' and 'Tag base', but they default to 'category' and 'tag', which brings me back to my previous problem. I then tried putting 'blog' instead. It works for the categories and tags, but it then makes all the posts redirect to a 404 page. It's as if it searches for a category/tag with the name of [postname] and on failing to find one, 404s me. Anyone having this trouble / found a workaround for this?


How to set Media Box form elements default value?

I am developing a plugin to customize wordpress administration. Creating / Editing an article, when i user insert an image from media library or uploading it, i want to clear the image title, as default is set as image file name, and i want to set Big as image size. I am looking for the hook to work on it, i tried by using jquery but i guess the view button load the content in ajax.               add_action('admin_head-media-upload-popup','set_form_fields');          function set_form_fields() {         echo"<script type=\"text/javascript\">         jQuery(document).ready( function($) {             alert('ciao');             jQuery('tr.post-title td.field input').attr('value','');         });         </script>";     }      i am looking for how to set image post title='' and big radio button to "checked"


Front-end editing with custom fields?

I use the custom field plugin http://www.advancedcustomfields.com Is it possible to create and edit custom posts via the front end? I'd need to be able to see all the custom fields and allow those to be edited as well. Users should only be allowed to edit their own posts if they are logged in.


Add Class to Specific Paragraph of the_content()

Let's say I want to give the first paragraph bold text by adding a body class to the first paragraph. Is there a way to filter the output of               the_content();      or any other paragraph? First paragraph? Last paragraph? I know I can do this using Javascript or CSS (:firstchild), but is there a native WordPress way? Thanks. J


WordPress custom URL Rewrites redirecting not masking

I have the following code that exists in a plugin that is meant to take a request to the url `/stores/directory/foorbar/` and pass `foobar` as a GET variable:               function pcrr_rewrite_rules($a) {         $k = array('stores/directory/([^/]+)/?$' => 'index.php?pagename=directory&pod_store_id=$matches[1]');         return $k + $a;     }     add_filter('rewrite_rules_array', 'pcrr_rewrite_rules');          # Flush existing rules and rewrite     function pcrr_activate() {         global $wp_rewrite;         $wp_rewrite->flush_rules();     }     register_activation_hook(__FILE__, 'pcrr_activate');      The expected behaviour would be any requests to `/stores/directory/foobar/` would instead load `index.php?...`, however, whilst requests are being handled, they are redirecting to the URL, instead of masking it. For example, a request to `/stores/directory/foobar/` is redirected to `/stores/directory/`. Any ideas on how I can correct this behaviour? Cheers!


Is it possible to override the result of get_template_part()?

I'm working on a child theme, I strongly prefer not to override the main template files in order to maintain simplicity of the child theme as well as minimize the amount of code and maintenance over time. In the loop, the index.php template in parent theme uses: `get_template_part( 'content' );` which will bring in _content.php_ , I'm looking to have it behave more like `get_template_part( 'content', get_post_format() );` or similar in order to bring in different templates such as _content-aside.php_ , etc, without creating an _index.php_ in the child theme to overwrite the parent for a single line change. `get_template_part()` consists of:               function get_template_part( $slug, $name = null ) {              do_action( "get_template_part_{$slug}", $slug, $name );         $templates = array();         $name = (string) $name;         if ( '' !== $name )             $templates[] = "{$slug}-{$name}.php";              $templates[] = "{$slug}.php";         locate_template($templates, true, false);     }      So there's an action available, in my case called `get_template_part_content` I can hook onto the action with something like:               add_action( 'get_template_part_content', 'child_post_styles', 10, 2 );          function child_post_styles ( $slug, $name ) {         if( false == $name ){             $name = get_post_format();             $templates = array();             if ( '' !== $name )                 $templates[] = "{$slug}-{$name}.php";                  $templates[] = "{$slug}.php";             locate_template($templates, true, false);         }     }      This obviously results in post duplication, one from my hooked function, which can display the desired template, and the other from the normal `locate_template` call in `get_template_part()` I'm having trouble finding a way to accomplish this without duplication, or without ending page render right after serving my template part by doing something stupid such as a `break` or `exit`


how to ask if in two categorys inside if

I'm new two wordpress so sorry in advance if this question might be very basic. Depending on which category a post is, I do some script things and I ask inside the loop in this way:               <?php if (has_category('category_1')):?>        // do some stuff     <? endif; ?>      this works pretty fine. But how can I ask for if post has two specific categories like:               <?php if (has_category('category_1') && has_category('category_2'):?>       // do some stuff     <? endif; ?>      this does not seem to work. What am I doing wrong?


How do I prevent the wp_editor from loading outside container?

I'm trying to load the wp_editor on a settings page:               <?php                                      //$content = $value->playerBio;                                 $editor_id = 'listingIntro';                                 $textareaname = "listingIntro";                                 $settings = array("textarea_name" => $textareaname);                                      wp_editor( $content, $editor_id, $settings);                                  ?>      the editor is loading outside the table. Can I force it to load inside the table?


Multiple Websites that share some content types and not others

I need to know if Wordpress can handle multiple sites. **And between these sites, it should share some content types while restricting others**. If the answer is yes, then I need to know:   1. does it do it out of the box   2. what plugins will i need   3. do i need to build my own plugins   4. do i need to modify the core code (and hence, break forwards upgrade/compatibility) So here's what I need: I need to create several websites for one company that has multiple offices around the world. Each website will have their own domain name like http://toronto.website.com, http://newyork.website.com, http://dubai.website.com etc.. These sites will all be in English. I will only have 1 set of html css files that all these websites will use. The difference between all these sites will be content. Some content-types will be shared between these sites, while others will not. For simplicity sake, there are 2 content-types: **Page** \- A page is your traditional wordpress page or post. They will be used to create Home Page, About Us, History, Contact Us, Terms of Service etc... Pages **ARE NOT SHARED** between the different websites. So if http://toronto.website.com has a History page, that doesn't mean http://newyork.website.com must have a history page...and even if they do, it can be completely different content. **Projects** \- A project will have fields like title, description, author, film director, camera man, location etc... Projects **ARE SHARED** between different sites. So a person on the http://toronto.website.com website can see the same set of project information as http://newyork.website.com. So to re-iterate, my biggest concern is the ability to share project content- types between sites while not sharing page content-types.


Keeps on redirecting on my development copy

I'm working on some edits for a client's site. So I downloaded the site's files and exported the database. I need to make some big changes on a development machine first so I won't mess with the live site. Then I imported the database to my development machine and setup the files as well. But whenever I go to http://localhost it redirects me to the client's site: https://theclientsite.com So since it redirects me to a https address I'm thinking it probably has something to do with that. I did a global search on the code for the client's domain, but I don't see anything that redirects. What could be the source of the redirecting? If the site doesn't stop redirecting, I can't work.


A Post is saved twice or more during add_action(save_post)

I have added a custom meta box for advanced information for a specific post category, to my create new post page. Now I recognize, that if I save the post, it writes 2 entries in the db with 2 post_ids.               add_action( 'add_meta_boxes', 'my-plugin_add_custom_box' );     add_action( 'save_post', 'my-plugin_save_postdata' );          my-plugin     function my-plugin_add_custom_box() {         add_meta_box(              'my-plugin_sectionid',             __( 'my-plugin', 'my-plugin_textdomain' ),             'my-plugin_inner_custom_box',             'post'          );     }          /* When the post is saved, saves our custom data */     function my-plugin_save_postdata( $post_id ) {       // verify if this is an auto save routine.        // If it is our form has not been submitted, so we dont want to do anything       if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )            return;            // verify this came from the our screen and with proper authorization,       // because save_post can be triggered at other times            if ( !wp_verify_nonce( $_POST['my-plugin_noncename'], plugin_basename( __FILE__ ) ) )           return;                 // Check permissions       if ( 'page' == $_POST['post_type'] ) //is this the correct post_type?       {         if ( !current_user_can( 'edit_page', $post_id ) )             return;       }       else       {         if ( !current_user_can( 'edit_post', $post_id ) )             return;       }            // OK, we're authenticated: we need to find and save the data              //$mydata = $_REQUEST['sports'];         print($post_id); //prints two post ids e.g. 831 & 832         //print($mydata); //prints two times content of $mydata     }      Why are two records in the tables `wp_posts` are created? And when I update the post, a new record is created with `post_name` post_id-revision (843-revision). What are the advantages for creating a new post type, like _sports_ for such kind of posts? My advanced information like `$_REQUEST['sports'];` are planned to be stored in a separate db with a ref to wp_posts. Thanks in advance & BR, mybecks


Filter wp_nav_menu()

I try to split my navigation into 3 single navigation bars (level 1, level 2 and level3+). Three because they're separated over the site and they should only appear depending on the current page.               -0-------1--------2-------3+- level/depth     Home      |      |\___ Lobby      |      |\___ Projects      |       |\___ Project A      |       |       |\___ Review      |       |       |\___ Comments      |       |       \____ Download      |       \____ Project B      |               |\___ Review      |               |\___ Comments      |               \____ Download      |\___ Blog      |      \____ About              |\___ Legal              \____ Contact      The first navbar containing the level 1 is always visible. The second navbar (level 2) only when im currently on the corresponding parent page. The same goes for the third navbar (level 3+, plus because this navbar will also contain sub pages and subsub pages ... of level 3). In short: I want to display all the parent menus in their navbars and only the direct children of the current page. What I tried:               function my_nav_menu( $args = array() )     {         $echo = isset( $args['echo'] ) ? (bool)( $args['echo'] ) : true;         $args['echo'] = false;              add_filter( 'wp_get_nav_menu_items' , 'my_nav_menu_filter' , 666 , 3 );              $menu = wp_nav_menu( $args );              remove_filter( 'wp_nav_menu_objects' , 'my_nav_menu_filter' , 666 );              if( $echo )             echo $menu;         else             return $menu;     }          function my_nav_menu_filter( $items , $menu , $args )     {         //var_dump( $args );              $navLevel = isset( $args['navlevel'] ) ? (int)( $args['navlevel'] ) : 0;              //echo 'navlevel = ' . $args['navlevel'] . ' | ' . $navLevel;              if( $navLevel == 1 )         {             foreach( $items as $key => $item )             {                 if( $item->menu_item_parent != 0 )                     unset( $items[$key] );             }         }         else if( $navLevel == 2 )         {             foreach( $items as $key => $item )             {                 if( $item->menu_item_parent != 0 )                 {                     $page = get_page( $item->menu_item_parent );                          if( $page->menu_item_parent == 0 )                         continue;                 }                      unset( $items[$key] );             }         }         else if( $navLevel == 3 )         {             foreach( $items as $key => $item )             {                 if( $item->menu_item_parent != 0 )                 {                     $page = get_page( $item->menu_item_parent );                          if( $page->menu_item_parent != 0 )                         continue;                 }                      unset( $items[$key] );             }         }         else         {             //var_dump( $items );         }              return $items;     }      Calling this in my header.php: `<?php my_nav_menu( array( 'echo' => false , 'navlevel' => 1 ) ); ?>` However `$args` is set to the default values and my custom entry `navlevel` isnt shown in the filter. How can I split my navbar as described? How do I set my custom `$args`-entry?


add span to wp_nav_menu widget

Am using the custom menu widget to add a menu in the footer and i want to add a in the menu how can i do this ? like so...
menu1
       if done it for the main nav using the link before below but as this is a widget am not sure where to add this               'link_before' => '',     'link_after' => ''      any one know ?


WPML - how to translate user profile fields with icl_t()?

Existing code somewhere in a template or shortcode handler, display user profile biography:               <?php if ( $user ) : $bio = get_the_author_meta( 'description',  $user->ID ); ?>
         <?php echo $bio; ?>
      How do I get these biographies to show up in WPML String Translation. This is not making it happen:               $bio = icl_t( 'theme', 'bio-' . $nimi, get_the_author_meta( 'description',  $user->ID ) );      This help page isn't particularly helpful to me, at least I cannot figure out how to apply it to this situation. This problem-specific thread is also quite vague on how exactly icl_t() is supposed to be used.


How to modify wp_ajax function?

I want to modify wp_ajax_find_posts function. It receives search string from find-posts form and delivers search results by ajax. Part of the function looks like this:               function wp_ajax_find_posts() {         global $wpdb;         check_ajax_referer( 'find-posts' );              // ........         $search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')";         $posts = $wpdb->get_results( "SELECT ID, post_title, post_status, post_date FROM $wpdb->posts WHERE post_type = '$what' AND post_status IN ('draft', 'publish') AND ($search) ORDER BY post_date_gmt DESC LIMIT 50" );              $html = //......              $x = new WP_Ajax_Response();         $x->add( array(             'what' => $what,             'data' => $html         ));         $x->send();     }     add_action( 'wp_ajax_find_posts', 'wp_ajax_find_posts,1)      I want to modify the line $post to add post_author to the querry in order to limit the results within current loggin user. I would like to learn how to hook up with this wp_ajax_find_post function to let it accept my modified $post. Do I have to do remove_action and add_action to make completely rewrite of the above funtion?


WordPress Widgets no drop down

i gave my editor role an access to my Widget settings. But i wonder why it is different when an admin access it. It has no drop down. see the attachment: http://i.stack.imgur.com/Rv3g3.png Thanks Ivan


Nested calls the the_content filter

I'm writing a plugin that adds some custom content near the end of a post (or page). So I've added a filter for 'the_content', and the plugin adds its content there. Mostly, it works. However, some sites show the entire content of several posts on the homepage (rather than just excerpts). On those sites, my filter is being called once for every post that is displayed. So the custom content shows up more than once. Is there some way for me to detect when my filter is a nested call? I.e. that it is being called for the content of a post which is being displayed on the homepage. I could then add my custom content only when it is a "top level" call. I also considered attaching my filter to the footer instead of the content, but I've run across themes that don't have a footer. Thanks! Ken


What's the most efficient database method to add and query usermeta?

What's the most efficient way - concerning the database - to add and query extra usermeta fields to a profile? I need to add four additional fields of numeric and text data to a user profile and then query that to compile the data for display in a template. And there are potentially thousands of users. There are lots of examples to store the data in usermeta. But should this amount of data be stored in the usermeta table? Or should I store it all in a new database table? And if so, how do I initialize a new table and then write to it?


How to organise post by category and date

I'll try to be as clear as possible. I'm working on a project that requires posts organised by category and date. I need something like this: First step: Annual listing of archive 2014: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 2013 2012 2011 2010... Second step: by clicking on a year link, you are directed to another page where the category and subcategories for the related month are listed. Music (January 2014) Rock “The History of AC/DC” Hip Hop “What Ever Happened to Bell Biv Devoe?” Pop Bruce Springsteen – High Hopes Pharrell Williams   Other David Bowie's The Next Day U2 The subcategories can be use each month or new one can be created and used only once. The main category (Music) will have no post. I can have (second step) post from categories and subcategories work using the code on this page http://www.cssreflex.com/snippets/list-wordpress-posts- category/ But it's not limited to a specific month or year. Thank you for helping me or ponting me to the right direction to solve my issue.


Can we validate user email changes?

I am having difficulty understanding why user security and validation is so vague in WP (4.0).. Surely email verification should come as default? Anyway I have been trying to find a solution to user security. All I can seem to find are plugins that send email validation links on registration. This is great, however a user can the log in and just change the email to foo@par.com no questions asked. Either a) I now have an unverified user; or b) Someone has just hijacked the account. Surely I am missing something here, these features predate WordPress so there must be a solution?


add text to the top of category page

I want to add the text to top of each category page. I am using a plugin **http://wordpress.org/extend/plugins/categorycustomfields/** . With the help of this plugin, i am able to add extra field to my categories, but how can i display that. eg :- if i want to display category description, i used `<?php echo category_description(); ?>` similarly, how can i display custom field value.


Multisite: Redirect to appropriate domain if subdomain doesn't exist

I have a multisite with domains: site1.com, site2.com, site3.com, etc. where site.com is the "home domain" of the multisite. As of now there is two issues I am trying to solve at the same time. If I try example.site2.com (a subdomain that does not exist) it will redirect to site1.com/wp-signup.php (and i have registration disabled). I tried to fix this with http://wordpress.stackexchange.com/a/85530/35677, with mine being:               function prevent_multisite_signup()      {         wp_redirect(site_url(), 301);         exit;     }     add_action('signup_header', 'prevent_multisite_signup');      Of course this does do partially what I want which is to redirect to the homepage with a 301, however it is site1.com and not site2.com. Is there a way to adjust this code to always direct to its parent domain? I even tried getting the blog_id first, then get that url and pass it, but by the time this function is called the blog id is for site1.com. The ideal answer would be in code versus something like .htaccess.


Stop WordPress automatically adding <br> tags to post content

Is there a way to stop WordPress from automatically inserting `<br>` tags when adding returns in the WordPress text editor. I would like for it to behave more like a code editor where I can structure the code how I like and make it easy to read. The code I am using in the editor is:               [one_third][team_member image_url="team_member.jpg" name="Laser vision" role="WordPress Designer"][custom_button url="#"]For more information[/custom_button][/team_member][/one_third][one_third][team_member image_url="team_member.jpg" name="Laser vision" role="WordPress Designer"][custom_button url="#"]For more information[/custom_button][/team_member][/one_third][one_third][team_member image_url="team_member.jpg" name="Laser vision" role="WordPress Designer"][custom_button url="#"]For more information[/custom_button][/team_member][/one_third]      I would like to structure it like this so it is easier to read and edit:               [one_third]     [team_member image_url="team_member.jpg" name="Laser vision" role="WordPress Designer"]     [custom_button url="#"]For more information[/custom_button]     [/team_member]     [/one_third]          [one_third]     [team_member image_url="team_member.jpg" name="Laser vision" role="WordPress Designer"]     [custom_button url="#"]For more information[/custom_button]     [/team_member]     [/one_third]          [one_third]     [team_member image_url="team_member.jpg" name="Laser vision" role="WordPress Designer"]     [custom_button url="#"]For more information[/custom_button]     [/team_member]     [/one_third]      However, when do this there will be invisible `<br>` tags added to the post content which will mess up the layout of my page.


terms_description and admin problem

Hey hi, I am using a piece of code, where with help of it I can display the description of the term to my archives page. My idea of doing this is simple, I have MBA website and I have 3 custom-taxonomies with 1000's of terms in each, for-eg:- I have a term mba-in-accounts, so its description will be displayed on the archive page of mba-in-accounts, But now the main problem is, this description comes well, but it is just displayed to logged in users I want to make it display to all users who visits my website, I am using this code to display                <?php                      if ( is_tax( 'location' ) ) {                         echo term_description();                     }                     elseif (is_tax('mba_courses')){                         echo term_description();                     }                     elseif (is_tax('duration')){                         echo term_description();                     }                          ?>      How can I make it display to all users, and I am also using allow-html-in- category-descriptions plugin to enable HTML in description box


Plugin Needed (User Register - have own profile)

I am looking for a wordpress plugin where when the user registers it creates their own profile where the user will have their own personal area. Can anyone point to any? Thanks Update: OK, I've try to explain further. I am writting a web application which I need to plug into wordpress. Visitors who are not logged in can use the app ... then if the user likes the application and what he/she has created, then they can register and save it and pay a monthly fee for using it. Hope this helps.


Using get_terms() as shortcode attribute

Hop you pepople would be fine. I'm creating a shortcode with the following code.               $categories = get_terms( 'project-type' );          foreach ($categories as $category) {              $portfolio_terms[$category->slug] = $category->name;          }          $ABdevDND_shortcodes['portfolio_DD'] = array(         'attributes' => array(             'category' => array(                 'default' => 'all',                 'type' => 'select',                 'values' => $portfolio_terms,                 'description' => __('Category', 'dnd-shortcodes'),             ),                   'style' => array(                 'default' => 'classic_gallery',                 'type' => 'select',                 'values' => array(                      'classic_gallery' => 'Classic Style',                     'alternative_gallery' => 'Alternative Style',                 ),                 'description' => __('Style', 'dnd-shortcodes'),             ),              ),         'description' => __('Portfolio', 'dnd-shortcodes' )     );     function ABdevDND_portfolio_DD_shortcode( $attributes, $content = null ) {         extract(shortcode_atts(ABdevDND_extract_attributes('portfolio_DD'), $attributes));              ob_start();           get_template_part( 'lib/blocks/portfolio', 'index' );           $return = ob_get_contents();           ob_end_clean();           return $return;               }      shortcode is working just fine, but the only issue is i'm unable to populate taxonomy array values from $portfolio_terms variable. It outputs nothing. The question is, how i populate category attribute with all avaiable terms of 'project-type' with slug as key and name as value?


Removing the TinyMCE editor for a given page template

I was looking for a way to remove the TinyMCE Editor for a specific page template in a theme (in my case it's page-home.php). I found the following code, which works, however, I was wondering if this could be accomplished in a better/neater way, perhaps using some of WordPress' built-in functions for finding the ID of the page...               function hide_editor() {         $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;         if( !isset( $post_id ) ) return;         $template_file = get_post_meta($post_id, '_wp_page_template', true);         if($template_file == 'page-home.php'){ // template name here             remove_post_type_support('page', 'editor');         }     }     add_action( 'admin_init', 'hide_editor' );


Trying to create a custom column for a custom post type

I'm trying to create a custom column for my custom post type and I'm having no luck. Below is the code I'm using, I have a similar code that pulls the featured thumbnail and that works for all post types, but this column will only show up on the custom post type. Any help would be appreciated.               add_filter("manage_Featured_columns", "edit_Featured_columns" );     add_action("manage_Featured_column", "custom_Featured_columns");     function custom_Featured_columns($Featured_column) {         global $post;         switch ($Featured_column) {             case "redirect_url":                     if(get_post_meta($post->ID, 'redirect_url', true) !='') {                         echo get_post_meta($post->ID, 'redirect_url', true);                     } else { echo '-'; }          } }      That is the code I have so far, but it's not showing up on the Featured custom post type. The name I'm using in my custom post type is: register_post_type( 'Featured', Thanks


Next Page Link shows same posts on custom template

I have a Page, with Custom Page Template to display 6 "Posts" with a specific category on that page. The Code that i have used can be found here: http://pastebin.com/E52u0TTi Also, i have tried: But Both show same posts and not other posts, however the URL changes to page/1/ page/2 and so on. What do i intend to have: I want to have Next link to be displayed on the template and when it is clicked, the next set of Posts with same Category should load. I tried to google for a solution can stumbled upon this post: http://blog.deconcept.com/2005/02/07/wordpress-next-previous-post-links/ the solution used here is deprecated. Kindly help.


Permalink of a page that has already been deleted

I had a page.. and I by mistake added another one, so the permalink got appended by "-2" at the end. I had to delete one of the pages, so I happened to delete the one without the -2 attached. Now I'm trying to change the slug of the page so that it becomes "pagetitle/" rather than "pagetitle-2" but everytime I edit the permalink it reverts back to "pagetitle-2" any ideas?


Programmatically Add Font-Awesome Icons to Category Widget

I use the Categories widget on my sidebar(s) and I would like to display a Font Awesome icon next to each category listed in the widget. The icon would be the same for all categories, for now, but I would like to give each category it's own unique icon in the future. I would like to modify the Categories widget using code in my **functions.php** file to add the icon by inserting markup like `<i class="fa fa-chevron-right"></i>` into category's link/anchor element _after_ the category's title. I could accomplish this via CSS, but in doing so I lose the ability to programmatically determine which icon to display, along with the flexibility for other improvements/changes that I may wish to make in the future.    Basically, I wish to achieve this effect:               Cat 1          >          Cat 2          >          Cat 3          > **(The greater-than symbol '>' represents the icon placement relative to the category title)**    I have Font Awesome enqueued in the _functions.php_ file using the `wp_enqueue_scripts` hook as follows, and it loads and displays the icons perfectly. Note that I do not use any Font Awesome plugin built for WordPress.               /* Enqueue Scripts     -----------------------------------------------------------------*/     add_action( 'wp_enqueue_scripts', 'essentials_enqueue_scripts' );     function essentials_enqueue_scripts() {         /* jQuery */         wp_enqueue_script('jquery');         wp_enqueue_script( 'jquery_ui', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jqueryui/2.0.3/jquery-ui.min.js", false, null);         wp_enqueue_script( 'waypoints', get_template_directory_uri() . '/js/waypoints.min.js');         wp_enqueue_script( 'essentials_main', get_template_directory_uri() . '/js/essentials_main.js', array(), '1.0.0', true );         wp_enqueue_script( 'essentials_show_stuff', get_template_directory_uri() . '/js/essentials_show_stuff.js', array(), '1.0.0', true );         /* Google Fonts */         wp_register_style('GoogleFonts','http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Bad+Script');         wp_enqueue_style( 'GoogleFonts');         /* Font Awesome Fonts */         wp_register_style('Font Awesome','//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css');         wp_enqueue_style( 'Font Awesome');      }      Despite my best research efforts, I was unable to find a solution to modify the categories widget.