• Resolved kaio cesar

    (@kaio-cesar)


    Hello,

    I need some help.
    I try to do some things, but don’t work so well.

    Let me try explant…

    I have three main categories, and I need to put the three separately in the index. With Featured(sliders) and the posts for the same category.

    Thanks guys.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi kaio. Welcome to the Hueman forum.

    To set the slider category, go to Theme Options > Blog > Featured Category.

    To set the same category for the home page posts, add this to your child theme functions.php file:

    add_action( 'pre_get_posts', 'my_home_category' );
    function my_home_category( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'cat', ot_get_option('featured-category') );
        }
    }

    References for the function above:
    https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts#Show_Only_One_Category_on_Home_Page
    https://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters

    If you don’t yet have a child theme:
    1. In Theme Options click the Help tab in the upper righthand corner.
    2. One of the options in the list is to download a sample child theme. This downloads the theme zip file to your local computer.
    3. Install the new theme in your Admin panel by selecting Add New > Upload Theme > Choose File, then select the zip file you downloaded.
    4. Activate the child theme.
    You’ll now have a pre-configured child theme with a style.css file and functions.php file to which you can add customizations.

    Thread Starter kaio cesar

    (@kaio-cesar)

    Hi bdbrown. Thanks.

    Alright!! looking great.

    But now i’ll make the ‘same’ question…

    I need 3.. 1 slider and the other posts.

    look this image for you understand what i’m trying to explain:

    http://pt-br.tinypic.com/view.php?pic=20hkapx&s=8#.Vgr1RPlVhBc

    If you’re looking for three different “groups”, each of which contains a slider and a list of posts based on category, that’s not doable with the default theme configuration. You’d be looking at significant customizations to the index.php file and running multiple queries on the same page. My recommendation would be to use plugins and shortcodes to build a static page to use as your Home page. I haven’t tested this but in theory I don’t see any reason why it wouldn’t work.

    You might look at the following:

    Here is a slider that displays posts based on category.

    Here is a link to a google search of plugins that display posts by category.

    Both options use shortcodes so it should be fairly easy to configure the page. You may have to work up some custom css to style the posts the way you want them.

    Thread Starter kaio cesar

    (@kaio-cesar)

    Hello, bdbrown.

    I try your recommendation, but not work for what i need..

    So.

    I’ll ask you if i can’t have One Slider and the post for the same category.
    And after that i have mini posts for the others categories.

    Like this:

    http://tinypic.com/view.php?pic=wtx7yd&s=8#.Vg1RS3pVhBc

    Thank you for the help.

    That’s not much different than your original request; it just doesn’t have multiple sliders. If you don’t want to, or can’t, use plugins then, as I said above, you’re looking at significant customizations to the index.php file and running multiple queries on the same page. Instead of a single featured post slider and a single loop, your index.php page would need code to do the following:

    category 1 title
    featured posts category 1
    post loop category 1
    category 2 title
    featured posts category 2
    post loop category 2
    category 3 title
    featured posts category 3
    post loop category 3

    Each of those would have a hard-coded category id/name which would need to be changed manually if you ever wanted different categories. You’d also need to control the number of posts per category manually. And, since you’re running multiple queries, you’ll need to track the number of posts to know when to start a new page since WP won’t track that between loops. You would also need to use the “rewind_posts()” function between loops as discussed in this article.

    The basic code blocks for the slider and loop are in the theme and you could use those as a starting point. But the theme isn’t designed to do this; it’s all custom coding. It will take some amount of time and knowledge of PHP/HTML/CSS to make it work. That’s why I suggested the plugins. Or, you could look for another theme that has this capability built-in.

    Thread Starter kaio cesar

    (@kaio-cesar)

    Thx bdbrown.

    I’ll make the changes and post here.
    Thank you for the support.

    Thread Starter kaio cesar

    (@kaio-cesar)

    i solved.
    Thx for the help.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Make more featured for differents categories’ is closed to new replies.