• Resolved Matt Blank

    (@mattblank)


    Hi,

    I used this within my theme to generate the sites menu:

    <? wp_nav_menu(); ?>

    I want to have this now here in the shortcode, something like this:

    <?php echo do_shortcode('[expand title="Menu"]<? wp_nav_menu(); ?>[/expand]');?>

    That breaks the PHP though. Can anybody help me to tell me how this is done?

    Thanks!
    Matt

    • This topic was modified 7 years, 9 months ago by Matt Blank.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author twinpictures

    (@twinpictures)

    Hello.

    Try:

    <?php echo do_shortcode('[expand title="Menu"]'.wp_nav_menu().'[/expand]'); ?>
    

    It sounds like you are trying to add the collapse function to your navigation menus. Normally this is a default feature of your theme. However, if you want to include the collapse-o-matic expand elements as part of your wp_nav_menu, you will want to look into creating a nav walker. This is quite advanced, and beyond the scope of our plugin. But we’ll help point you where you need to go.

    One other tip, check out the roll-your-own method, as using the do_shortcode function instead of the nav_walker class will probably not perform as expected.

    Best of luck!

    • This reply was modified 7 years, 9 months ago by twinpictures.
    Thread Starter Matt Blank

    (@mattblank)

    That works, but for some reason it’s always expanded, never collapsed. I’m using this for mobile only, which is the need to use this. So the whole thing is within a hidden div, which only shows when the viewport is of a certain size.

    I have it working fine if I actually put text in there. But the moment I put PHP code in, it breaks.

    Matt

    Plugin Author twinpictures

    (@twinpictures)

    What you are doing is a bit advanced. you might consider upgrading to collapse-pro-matic for the very high level of personal support it comes with: We would even resolve this issue for you.

    If you want to forge forward on your own, you will have to be more detailed. Post an example of both the code that works compared to what does not work.

    Also, post a link to what works but is always expanded.

    We’ll do what we can to help, but if you go pro, you won’t be disappointed.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show wp_nav_menu(); in shortcode?’ is closed to new replies.