Info
- 3 posts
- 2 voices
- Started 6 months ago by benfrain
- Latest reply from benfrain
- This topic is not resolved
How to exclude forum post_type within functions.php?
-
- Posted 6 months ago #
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 stuffHowever, 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
-
- Posted 6 months ago #
I don't understand what the problem is that you're trying to fix. Can you explain the use-case and context?
-
- Posted 6 months ago #
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?
-
You must log in to post.