WordPress.org

Ready to get started?Download WordPress

Forums

If Menu
How to get the conditional statement for particular categories? (5 posts)

  1. imobagg
    Member
    Posted 1 year ago #

    This is a great plugin btw ... great work. Hope more features are added soon. Here's one I was wondering that how do I add conditional for a particular category ..

    $conditions[] = array(
    		'name'		=>	__( 'Nation', 'if-menu' ),
    		'condition'	=>	'is_category(166)'
    	);

    I tried using above category for category id 166 .. but it gave an error. I could see 'Nation' listed in the drop down on the menu page as conditional but when activated it didn't work. I'm sure I'm missing some code. Could you please help??

    http://wordpress.org/extend/plugins/if-menu/

  2. Andrei
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    Thanks for using the plugin.

    The is_category function with params can't be passed as a string, this should work.

    $conditions[] = array(
    	'name'		=>	__( 'Nation', 'if-menu' ),
    	'condition'	=>	'is_custom_category'
    );
    
    function is_custom_category() {
    	return is_category(166);
    }
  3. kriskl
    Member
    Posted 1 year ago #

    Hi Andrei
    this is a great plugin,
    well done! like the poster above, I hope there will be new features added

    I hope it will be possible to control sub navigation/second menu based on the category/slug
    at the moment, only menu items have "conditions"

    it would be great if the second menu had conditional logic also,

    I understand from your reply above it should be possible, but which file do I edit to try it out? sorry newbie here ;)

  4. dhewlette
    Member
    Posted 12 months ago #

    This is exactly what I needed. Thanks Andrel!

  5. JonLandon
    Member
    Posted 9 months ago #

    Help...I need to create a simple new condition...to turn the menu off if a certain page is displayed... sort of like this
    body.page-id-804 #menu1 {display: none;}

    I'm inexperienced so please be clear...I know how to find the page number.

    Thanks

    jonlandon53@gmail.com

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic