Forums

How to remove category spoilers from the front page only?? (6 posts)

  1. Mandarke
    Member
    Posted 3 years ago #

    Hello, I'd like to remove the list of categories running down the sidebar on the front page of my site here - but keep them throughout the rest of my site. Any clues on how to do this or a simple nudge in the right direction greatly appreciated!

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    Here's an example of using a Conditional Tag for something like:

    <?php
    if ( ! is_front_page() ) {
    wp_list_categories();
    }
    ?>
  3. Mandarke
    Member
    Posted 3 years ago #

    Many thanks - that looks like just the ticket. The theme I'm using has a specific 'sidebar.php' - so would it make sense to put the conditional tag in there?

    <div id="sidebar">
    
    <?php 
    
    $showSpoilers = get_settings ( "cp_catSpoilers" );		
    
    if ( $showSpoilers != "no" ) {	
    
    $cp_categories = get_categories('hide_empty=0');
    $postcat = get_settings( "ar_spoilers" );
    
    if( ! is_array( $postcat ) ) {
    	foreach ( $cp_categories as $b ) {
    		$postcat[] = $b->cat_ID;
    	}
    }

    I'm guessing this is the right region, and I've experimented with inserting/replacing the conditional tag, however, I'm inexperienced with .php and I keep getting parse errors - any idea where I'm going wrong? Many thanks once again!

  4. MichaelH
    Volunteer
    Posted 3 years ago #

    Well at a minimum you would need these two things at the end of that

    } // if ( $showSpoilers != "no" )
    ?>
  5. Mandarke
    Member
    Posted 3 years ago #

    Please forgive me, I'm so much of a novice! - Where would I need to place this text? Would I need to replace something else with it? It would be a godsend if you (or anybody else) could suggest how the whole text above should look with the new edition implemented. Thank you SO much!

  6. MichaelH
    Volunteer
    Posted 3 years ago #

    Likely will go in your theme's index.php. The article, The Loop, has some info.

    Related:
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags