• rosyteddy

    (@rosyteddy)


    Using p2, how do I list only the main or actual blog posts on the front page and not the “status updates”?

    Thanks for your help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • valuser

    (@valuser)

    One option COULD be to do it via a function in your functions.php file using $query->is_home

    So (say) to exclude from home page status updates and posts in category “nofront” but to include (the exceptions) on home page if they have a tag “okfront”

    or vary it to whatever!

    function exclude_category($query) {
        if ( $query->is_home ) {
    	$idObj = get_category_by_slug('nofront');
    	$catid = $idObj->term_id;
            $query->set('tax_query', array(
                'relation' => 'OR',
                array(
                    'taxonomy' => 'category',
                    'field' =>  'ID',
                    'terms' => array(1,$catid),
                    'operator' => 'NOT IN'
    
                ),
                array(
                    'taxonomy' => 'post_tag',
                    'field' => 'slug',
                    'terms' => 'okfront',
                    'operator' => 'IN'
                )
            ));
        }
        return $query;
    }
    add_filter('pre_get_posts', 'exclude_category');
    Thread Starter rosyteddy

    (@rosyteddy)

    Hi valuser, Thank you for the fast reply.

    When there are no categories or tags, but just different tabs of the p2 input has been used [ Status | Blog | Quotes | Link ] what are the terms to be used in the above code?

    Thanks again.

    BTW, does anyone from the p2 team visit these pages? I would like to suggest – Status | Blog | Quotes | Link – links in sidebar and option to set any one or any mix of these as Front page, available as options in the theme set-up to the site admin / site super admin.

    valuser

    (@valuser)

    i think they are post format types

    see also

    https://www.ads-software.com/support/topic/removing-post-format-types?replies=6

    AND

    I should have FIRST guided you to

    https://www.ads-software.com/support/topic/exclude-post-format-from-main-query?replies=3

    Forums appear to be well supported by moderators etc (just my take)

    though p2, i believe – and I could be incorrect- is kinda being gently let go and a new replacement theme is on the way

    Thread Starter rosyteddy

    (@rosyteddy)

    Hi Valuser Thanks again.
    https://www.ads-software.com/support/topic/exclude-post-format-from-main-query?replies=3 appears to be useful at a glance. I will test it.

    Its sad that they are retiring p2 but wordpress DEv blog runs on it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Using p2, how do I list only the main or actual blog posts on the front page’ is closed to new replies.