xw48hf
xw48hf

Reputation: 447

How To Hide WordPress widget from homepage only ? But Need To Show on Post and Pages

I am trying to hide a WordPress widget from homepage but need to show on post and page. I am using this:

if ( is_active_sidebar( 'sidebar-2' ) && !(is_home) : ?>

But this is showing an error:

Parse error: syntax error, unexpected ':' in C:\xampp\htdocs\wordpress\wp-content\themes\Features\sidebar-main.php on line 11

Upvotes: 0

Views: 675

Answers (3)

Jeffrey Carandang
Jeffrey Carandang

Reputation: 408

You are using the incorrect conditions. You have to use

if ( is_active_sidebar( 'sidebar-2' ) && !is_home() ){}

You can also use Widget Options to hide WordPress widgets without editing the code and available on the repository for free. The options will be visible on each widgets. Feel free to check.

enter image description here

Upvotes: -1

Tobias Roland
Tobias Roland

Reputation: 1223

Is_home is a function - so you need a couple of parentheses at the end of it - like so: is_home(). You also appear to be missing a bracket at the end of the line; your if-statement should read like this:

if ( is_active_sidebar( 'sidebar-2' ) && !is_home() )

Upvotes: 2

n1te
n1te

Reputation: 945

you are missing a closing bracket, try this:

if ( is_active_sidebar( 'sidebar-2' ) && !(is_home)) : ?>

Upvotes: 2

Related Questions