Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1311613
    smartrich19
    Participant

    Hi, I tried to display posts from certain categories so I added this code in function.php of child theme

    function my_home_category( $query ) {
     if ( $query->is_home() && $query->is_main_query() ) {
     $query->set( 'cat', '39,30,38,32,37,42');
     }
    }
    add_action( 'pre_get_posts', 'my_home_category' );

    but now I can’t see any post there.
    Can you tell me what’s wrong?

    #1311637
    Rupok
    Member

    Hi there,

    Thanks for writing in! It should work if your category IDs are correct. You can try a plugin as suggested on the post you are following – https://community.theme.co/forums/topic/only-show-post-from-specific-categories-on-blog-page/#post-115592

    Cheers!

    #1311689
    smartrich19
    Participant

    First, I tried to use that plugin but my top slider wasn’t displaying all the slides so I added the code. My slider is working but posts are not being shown.

    #1311709
    Thai
    Moderator

    Hi There,

    Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    Thanks.

    #1311716
    smartrich19
    Participant
    This reply has been marked as private.
    #1311719
    Thai
    Moderator

    Hi There,

    Please move your code from the style.css to functions.php file:

    function my_home_category( $query ) {
     if ( $query->is_home() && $query->is_main_query() ) {
     $query->set( 'cat', '39,30,38,32,37,42');
     }
    }
    add_action( 'pre_get_posts', 'my_home_category' );

    Regards!

    #1311725
    smartrich19
    Participant

    Oops! I didn’t noticed that I was in css file. I moved it but still posts are not showing.

    #1311747
    smartrich19
    Participant

    What’s wrong now. Any Idea?

    #1312031
    Rad
    Moderator

    Hi there,

    Your blog has used special feature specific to Ethos. It uses the custom query, which means you’ll have to do it directly to the custom query instead of adding that code. It’s called filterable index where you can manually add category at Admin > Appearance > Customizer > Ethos > BLOG OPTIONS > Category IDs then add 39,30,38,32,37,42.

    Thanks!

    #1312925
    smartrich19
    Participant

    Hi, Thanks for reply. It was my first attempt to achieve my goal. But that thing display one category at a time. But I want all those categories at the same time 10 posts per page.

    #1312926
    smartrich19
    Participant

    https://community.theme.co/forums/topic/ethos-filterable-index-shows-only-one-cat/

    I saw code here to display all the categories. But I want to display from specific ones.

    #1313645
    Christopher
    Moderator

    Hi there,

    Please add recent posts element, you can set category and offset options to display 10 posts from each category, please see : demo.theme.co/integrity-1/shortcodes/recent-posts

    Hope it helps.

    #1314499
    smartrich19
    Participant

    I’m not sure the question is understood.

    Ethos theme.

    This appears to be an issue that users have discussed for some time.

    You have a neat feature/function where you can choose to show only certainly categories when using the home page as a blog page.

    But the way it works is not intuitive or the way other wordpress blog pages work.

    If I choose to limit to 10 posts on the home page, and choose categories x, y and z, then I want the posts for all those categories to appear in chronological order …

    The user needs to be able to see the 10 latest posts, or move on to the next 10, without choosing a category. This is a serious usability issue. A user isn’t going to understand they have to select a category to read the latest posts. If they don’t see something that catches their attention, the whole idea of having posts on the home page is pointless. They “will not know” they have to click on a drop down menu to find what they may not even know they are looking for.

    Now, it’s nice they can select to read from only certain categories if they CHOOSE to do so.

    However, the word “ALL” doesn’t mean I want “ALL” of my posts on the home page. It should mean I want “ALL” of my posts from my chosen categories on the home page … up to the delimiter when they will overflow to the next page.

    ————————————————————————————–

    I think you’re theme is the best piece of work I have seen in many years of working with themes in WordPress and others (Like Joomla).

    However, this bug is a major flaw which needs to be addressed. My programmer and I are going nuts dealing with what seems to be a simple issue …

    Any help would be appreciated.

    Thank you.

    Rich

    #1315497
    Christian
    Moderator

    Hey Rich,

    Please add the code below in your Appearance > Customize > Custom > Global CSS

    .x-filterable-category-group {
        display: block;
        visibility: visible;
    }

    Thanks.

    #1315916
    smartrich19
    Participant

    Hi there,
    I did what you told me to, but nothing happened. Can you take a look yourself?

  • <script> jQuery(function($){ $("#no-reply-1311613 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>