• verymum

    (@verymum)


    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter verymum

    (@verymum)

    Oh come on! Anyone?

    ladydelaluna

    (@ladydelaluna)

    Customized List with Excluded Categories

    Sets the list to not list all the Categories (based upon further parameters), sorts by ID in ascending order and in an unordered list (<ul><li>) without dates or post counts, does not hide empty Categories, uses Category “description” for the title in the links, does not show the children of the parent Categories, and excludes Categories 1 and 33:

    <?php list_cats(FALSE, '', 'ID',
    'asc', '', TRUE, FALSE,
    FALSE, FALSE, TRUE,
    FALSE, FALSE, '', FALSE,
    '', '', '1,33',
    TRUE); ?>

    http://codex.wordpress.org/Template_Tags/list_cats

    Thread Starter verymum

    (@verymum)

    I’m not wanting to hide it from a drop down list.

    I don’t want the posts in a particular category to show up on the main index page.

    Thread Starter verymum

    (@verymum)

    Well, I fixed the parse error by changing

    <?php }> to <?php } ?>

    But it still isn’t hiding the posts within that category from the index page. Anyone else? This has to be possible!

    Thread Starter verymum

    (@verymum)

    Anyone? I’ve driven myself mad reading everything in the “Loop” documentation. I’m just not skilled enough in php to understand how to accomplish what used to work in the older version.

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

The topic ‘Hiding category from front page – errors.’ is closed to new replies.