Public Ticket #1663551
Home page Main stream section bug


  • admin started the conversation

    I want to manage the MainStream section (the articles AFTER latest highlights). I want to show articles that are assigned to "Main Stream Articles" category.

    So, in Homepage builder -> Mainstream tab, I check every category except "Main Stream Articles" (So this should show any articles assigned to this category).

    However it doesn't show articles if the article is in two categories (ex:- In my case Article 1 is in "Main Stream Articles" category & "Be Inspired" category. So it doesn't pick this article to show in main stream. If the article is ONLY in the "Main Stream Article" category it works. This is a bug.

    Also please keep an option to set the maximum number of articles to show in main stream. So if it's empty it works as it is now. If not it shows only the specified amount.

  •  131
    Cuong replied

    Hi there,

    It's not a bug because that option was made for excluding categories not for including categories. If some categoy is checked then it's because people don't want it to be dispayed instead of displaying only the rest.

    For your case, because we don't have an "include" option, so please add this code to the end of fox/functions.php file then uncheck all categories in Homepage Builder > Main Stream, it's gonna work for you:

    add_action( 'pre_get_posts', 'wi_pre_get_post_include', 400 );
    function wi_pre_get_post_include( $query ) {
        if ( ! is_admin() && $query->is_home() && $query->is_main_query() ) {
            $cat = get_term_by( 'name', 'Main Stream Articles', 'category' );
            if ( $cat ) {
                $query->set( 'cat', $cat->ID );
        } }

    Hope this helps, Cuong Tran

    p/s: Keep in mind that if you change the category name, you have to change above code accordingly because "Main Stream Articles" appears in above code.

    WordPress lover. My Profile