Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to exclude forum post_type within functions.php?

  • Hi,

    I’m trying to exclude all forum post types within my main WordPress theme’s functions.php file using this sort of syntax:

    $post_type != 'forum'

    However it doesn’t seem to work. Here is the full if statement I’m using:

    function single_post_nav() {
    if ( is_single() && !in_category(array('54', '55', '56', '57', '58')) && !is_category(array('54', '55', '56', '57', '58')) && $post_type != 'forum' ) { ?>

    Some stuff

    However, it is still displaying the content on forum pages. Does anyone know the correct way to exclude the forum posts within functions.php?

    Any help much appreciated.

    Cheers – Ben

Viewing 2 replies - 1 through 2 (of 2 total)

  • John James Jacoby
    Keymaster

    @johnjamesjacoby

    I don’t understand what the problem is that you’re trying to fix. Can you explain the use-case and context?

    Sure, I have a custom theme and this sits in the functions.php and loads in a block of HTML for single posts that aren’t in certain categories. However, since installing bbPress, this block of HTML is also showing on the forums (it shouldn’t) so I need to exclude it. Someone offered some help on another forum so I now have:

    if ( 'forum' != get_post_type() && !in_category(array('54', '55', '56', '57', '58')) && !is_category(array('54', '55', '56', '57', '58')) ) { ?>

    Which means my forums now show but this chunk of HTML is now showing on pages too (it shouldn’t show there either) so I need to now exclude pages as well! Any idea how I might do that?

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.