WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to add a conditional to this code? (2 posts)

  1. photocurio
    Member
    Posted 3 years ago #

    add_action('below_header', 'flexx_feature_top', 11);
    	function flexx_feature_top() {
    		global $feature_top;
    
    		if ( ! empty( $feature_top ) && ( 'none' !== $feature_top ) )
    			get_template_file( 'feature-top.php' );
    	}

    This function adds a div with some widget areas to my theme: i.e. get-template_file( 'feature-top.php' ). Feature-top.php is the template file for the div.

    I want to add a conditional line that says "If this is a single post, don't add the div". But I don't know the correct syntax.

  2. photocurio
    Member
    Posted 3 years ago #

    I got this:

    add_action('below_header', 'flexx_feature_top', 11);
    	function flexx_feature_top() {
    		global $feature_top;
    
    		if (( ! empty( $feature_top ) && ( 'none' !== $feature_top )) && ( is_front_page ))
    			get_template_file( 'feature-top.php' );
    	}

    My code puts the widget area on the front page only, instead of not putting it on single pages.

Topic Closed

This topic has been closed to new replies.

About this Topic