-
AuthorPosts
-
November 19, 2013 at 3:12 am #190440
Hi,
I have a shortcode from a 3rd party plugin (form generator) that creates a pop-up contact form. I have been trying to put links to 2 popup forms into the top custom menu (enfold secondary menu) or in the header phone number/small info text area (under theme options>>header). Unfortunately, menu URLs won’t except shortcodes (I read I could use placeholders and add the shortcode to functions.php, but I’m slightly lost with it) and neither will the phone number/small info text box.
Is there an easy way for me to add this in? I also tried adding the code directly into header.php, but I can’t get the styling and positioning right. I am a PHP novice!
Shortcodes:
[contactformgen_popup id=5]Pet Owners Login[/contactformgen_popup]
[contactformgen_popup id=4]Vets Login[/contactformgen_popup]PHP for one of the popup forms:
<?php
if(function_exists(‘contactformgen_popup’)){
contactformgen_popup(5, ‘Pet Owners Login’);
}
?>The PHP I tried to add to the header (using the phone info class as I want it to appear there):
$cfclogin1 = contactformgen_popup(4, ‘Vets Login’);
$cfclogin2 = contactformgen_popup(5, ‘Pet Owners Login’);
echo “<div class=’phone-info {$phone_class}’><span>{$cfclogin1} | {$cfclogin2}</span></div>”;Any help would be greatly appreciated!
Thanks,
Matt
November 20, 2013 at 2:39 am #190795September 25, 2014 at 9:55 pm #325285Hi Josue,
I read with interest your recommendation of do_shortcode for the purpose of adding, in my case, short code for google translate into the secondary menu area of enfold (above header area).
Exactly how and where would I insert “[google-translator]” using the do_shortcode command?
Thanks!
Pelyon
September 26, 2014 at 9:52 am #325481Hey!
The code should look like this:
<?php echo do_shortcode('[google-translator]'); ?>
Regards,
IsmaelSeptember 26, 2014 at 9:44 pm #325772Hi Ismael,
Thank you. Now where does this code go exactly? Which php doc, or where in the theme backend?
Thanks again.
-PelyonSeptember 27, 2014 at 9:32 pm #326021Sorry. To be more specific, If I want to place some short code so that google translate ( or any other widget shortcode for that matter) can appear in the top secondary menu area, where do you suggest placing the “do_shortcode” code? functhions.php?
Thank you,
-Pelyon
September 30, 2014 at 4:23 am #326960Hey!
Thank you for the info.
Add this on functions.php file:
function add_custom_script_translator(){ echo "<div class='g-trans'>".do_shortcode('[google-translator]')."</div>"; } add_action('avia_meta_header', 'add_custom_script_translator', 10);
Use .g-trans selector to adjust the position of the container.
Best regards,
IsmaelSeptember 30, 2014 at 8:41 pm #327574Hi,
Thank you. This code appears to work only when I have a menu item included in the secondary menu. Without a menu item (which is what I want) the shortcode does not work. Any suggestions? Thank you!
October 1, 2014 at 10:09 am #327936 -
AuthorPosts
- The topic ‘Shortcodes in custom menu’ is closed to new replies.