Title: [Plugin: Random Post Link] Add specific Category
Last modified: August 19, 2016

---

# [Plugin: Random Post Link] Add specific Category

 *  [blpinferno](https://wordpress.org/support/users/blpinferno/)
 * (@blpinferno)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/plugin-random-post-link-add-specific-category/)
 * Hi,
 * I would love to be able to limit the results to a specific category. Is this 
   possible with this plug in?
 * Thank you in advance!!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/plugin-random-post-link-add-specific-category/#post-1492379)
 * Sure. Just add this to your theme’s functions.php:
 *     ```
       function my_random_post_args($args) {
           $args['category_name'] = 'my-category-slug';
   
           return $args;
       }
       add_filter('random_post_args', 'my_random_post_args');
       ```
   
 * Of course, replace `'my-category-slug'` with your category slug.
 *  [doodleface](https://wordpress.org/support/users/doodleface/)
 * (@doodleface)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/plugin-random-post-link-add-specific-category/#post-1492628)
 * hey,
 * any chance of specifying the category for each random link? basically i have ‘
   music’ and ‘videos’ as categories and it would be great if i could have a separate
   random post link for each cat :/
 *  [ishotr](https://wordpress.org/support/users/ishotr/)
 * (@ishotr)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-random-post-link-add-specific-category/#post-1492656)
 * [@scribu](https://wordpress.org/support/users/scribu/) I tried posting in the
   code into the functions.php. However, it ended up disabling my blog b/c it caused
   an error in the functions file. Do you replace the “my-category-slug” only? Or
   do you change anything else? I think I may be implementing this code incorrectly
   in my functions.php file.
 * this is my code:
 *     ```
       <?php
       if ( 
   
       function_exists('register_sidebar') ) {
           register_sidebar(array(
       		'name' => 'Wide Sidebar',
       		'before_widget' => '<div class="block %1$s %2$s">',
       		'after_widget' => '</div>',
       		'before_title' => '<h3 class="boxedin">',
       		'after_title' => '</h3>',
           ));
           register_sidebar(array(
       		'name' => 'Left Sidebar',
       		'before_widget' => '<div class="block %1$s %2$s">',
       		'after_widget' => '</div>',
       		'before_title' => '<h3 class="boxedin">',
       		'after_title' => '</h3>',
           ));
           register_sidebar(array(
       		'name' => 'Right Sidebar',
       		'before_widget' => '<div class="block %1$s %2$s">',
       		'after_widget' => '</div>',
       		'before_title' => '<h3 class="boxedin">',
       		'after_title' => '</h3>',
           ));
           register_sidebar(array(
       		'name' => 'Left Footbar',
       		'before_widget' => '<div class="block %1$s %2$s">',
       		'after_widget' => '</div>',
       		'before_title' => '<h3 class="boxedin">',
       		'after_title' => '</h3>',
           ));
           register_sidebar(array(
       		'name' => 'Mid Footbar',
       		'before_widget' => '<div class="block %1$s %2$s">',
       		'after_widget' => '</div>',
       		'before_title' => '<h3 class="boxedin">',
       		'after_title' => '</h3>',
           ));
           register_sidebar(array(
       		'name' => 'Right Footbar',
       		'before_widget' => '<div class="block %1$s %2$s">',
       		'after_widget' => '</div>',
       		'before_title' => '<h3 class="boxedin">',
       		'after_title' => '</h3>',
           ));
       }
       ?>
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[Plugin: Random Post Link] Add specific Category’ is closed to new replies.

 * 3 replies
 * 4 participants
 * Last reply from: [ishotr](https://wordpress.org/support/users/ishotr/)
 * Last activity: [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-random-post-link-add-specific-category/#post-1492656)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
