Hiding category from front page – errors.
-
Prior to WP 2.0 I utilized the following code to hide posts in one of my categories from the front page:
// If we're on the index page we don't want to show posts from the "Sugar Chronicles" category.
if (!$QUERY_STRING) {
$var_cat = get_the_category();
foreach($var_cat as $var_cat_val) $var_actual_cat = $var_cat_val->cat_name;
if(stristr($var_actual_cat, ‘Sugar Chronicles’)) continue;
}
?>
After upgrading, this no longer worked. I located the How do I hide a category from the front page index.php? section on this page: http://codex.wordpress.org/FAQ_Layout_and_Design#Is_there_a_tool_to_encode_HTML_entities_and_tags_so_I_can_display_code_on_my_weblog.3F
and changed my above code to:
<?php if ( !(in_category('Sugar Chronicles')) || !is_home() ) { ?>
<!-- Output the post here -->
<?php }>
I replaced the number “4” example with the actual name of my category.
This returned the following error:
Parse error: parse error, unexpected ‘>’ in /home/verymom/public_html/wp-content/themes/ohsovery/index.php on line 14
So I removed the category name and put in the category number
<?php if ( !(in_category('27')) || !is_home() ) { ?>
<!-- Output the post here -->
<?php }>
This resulted in the same parse error.
I am placing the code beneath the
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
on my index.php page. Am I missing something else or is this not up to date with the most recent WP version?
Thank you.
The topic ‘Hiding category from front page – errors.’ is closed to new replies.