WordPress.org

Ready to get started?Download WordPress

Forums

Need featured slider to pull articles from category instead of tags (2 posts)

  1. nnyorker
    Member
    Posted 1 year ago #

    Hi - I am using a theme called Max Mag from http://themeforest.net/user/mvpthemes. The theme pulls articles for the featured slider and newsticker from tags and I need it to pull from categories. While the author will not customize the theme, he is gracious enough to tell me:
    'In order to change from tags to categories, you will have to edit the theme options setup, or you could directly edit the header.php file (to change the ticker code) and the index.php file (to edit the slider code) to pull in a specific category of your choice.'
    and point me here: http://codex.wordpress.org/Function_Reference/query_posts, but I'm not sure what to change.
    I think I've found the part of the code to edit, but I'm not sure what to replace it with. Is it as simple as replacing 'tags' with 'category ='

    <?php if(get_option('mm_slider_tags')) { ?>
    <div id="featured-container">
    <div class="flexslider">
    <ul class="slides">
    <?php $recent = new WP_Query(array( 'tag' => get_option('mm_slider_tags'), 'showposts' => get_option('mm_slider_num') )); while($recent->have_posts()) : $recent->the_post();?>

    url is questnny.com

    Thank you in advance for any support you can give.

  2. illuminatus7
    Member
    Posted 1 year ago #

    Yes. First simply try replacing 'tag' with 'category_name' which will make your entire code like the following

    <?php if(get_option('mm_slider_tags')) { ?>
    <div id="featured-container">
    <div class="flexslider">
    <ul class="slides">
    <?php $recent = new WP_Query(array( 'category_name' => get_option('mm_slider_tags'), 'showposts' => get_option('mm_slider_num') )); while($recent->have_posts()) : $recent->the_post();?>

    Else, you can directly add your category slug into the query like the following in place of 'my-category-name'

    <?php if(get_option('mm_slider_tags')) { ?>
    <div id="featured-container">
    <div class="flexslider">
    <ul class="slides">
    <?php $recent = new WP_Query(array( 'category_name' => 'my-category-name', 'showposts' => get_option('mm_slider_num') )); while($recent->have_posts()) : $recent->the_post();?>

    Also, please remember to put codes in the code tag from the future in the forum posts http://codex.wordpress.org/Forum_Welcome#Posting_Code

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.