Archived topic
Adding PHP in Menu
7 replies · Started by Mark on July 25, 2017
Howdy!
I have a quick question about adding a PHP to the main menu.
<?php $values = get_post_custom_values("Phone"); if ( !empty($values) ) {echo '' . $values[0]. ' ';} else {echo '01 485 11 45';} ?>
How this works is if I i want a specific phone number to show on a specific page on my site I can use Custom Fields.
But currently on my site http://www.bushirecork.ie I have the number showing in the main menu. If there a way of showing that within the main menu on generate press?
Thanks
Hi Mark,
It's not possible to add PHP to menu items but Tom provided an alternative solution here: https://generatepress.com/forums/topic/add-php-code-to-menu-item/#post-293154
Hi Leo, thanks for that but them plugins dont seem to work. Just show up blank. Must be the PHP?
Shortcodes in Menus doesn't work? What shows up blank?
I installed the recommended plugins to insert php into the menu and added my php and nothing shows up.
The plugin inserts shortcodes into menu so you would have to turn the php into shortcode first then insert it with the plugin.
Oh sorry yeah, thats what I meant
Sorry so you did that but it's not working? What are you seeing?