Tagged: Advanced Customization
- AuthorPosts
- April 9, 2021 at 11:26 am #35900Javier TrevizoGuest
Hello. I am trying to place shortcode in the header. I’ve gone to the westview header.php file and pasted the shortcode after this line <div class=’col-md-6 header-7′><?php do_action( ‘boldgrid-theme-location’, ‘header’, ‘7’ ); ?></div>
My issue comes that the shortcode is below the header slightly. It is not in line with the menu. If i place it before the line then it is also not aligned. I’m unsure as how to place it in line with the other menu items in the header.
April 9, 2021 at 12:01 pm #35916Jesse OwensKeymasterHi Javier-
Thanks for reaching out, and thanks for using the Westview WordPress theme.
I took a look at your site, and I’m assuming that you’re trying to move your GTranslate language switcher into the menu. If my assumption is right, there’s a much easier way to accomplish this, but please correct me if I’m wrong about my assumption.
The GTranslate plugin makes this very easy by providing a setting to put the switcher into a menu. Navigate to Settings > GTranslate and look for the Show in menu setting:
If you’re trying to accomplish this with a different shortcode, you might consider the free Shortcode in Menus Plugin.
If you really do want to put it in the template, you’ll need to modify the template a little bit. I see that you’re already using a Child Theme, which is great. Copy the
head.php
file into your Child Theme, and modify it to something similar to this:<div class='col-md-3'><?php do_shortcode('gtranslate'); ?></div> <div class=’col-md-3 header-7′><?php do_action( ‘boldgrid-theme-location’, ‘header’, ‘7’ ); ?></div>
April 12, 2021 at 2:12 pm #35958Javier TrevizoGuestThank you for your timely response.
You are correct there is a drop down menu in the Gtranslate settings, but the only option available is -None-.
I will try the shortcode plugin. Thank you for your advice.
April 12, 2021 at 2:12 pm #35970Javier TrevizoGuestThank you for your timely response.
You are correct there is a drop down menu in the Gtranslate settings, but the only option available is -None-.
I attempted to use the short code in menu plugin, but I was unable to use the shortcode option when adding to a menu. It would not show up even though the appropriate shortcode option was checked. The shortcode menu item would not appear on the list when adding items. When I attempted to edit menus in admin mode it said “Your theme does not support navigation menus or widgets.”
I tried adding the code to the head.php, but the head.php only has the following code.
<head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <?php wp_head(); ?> </head>
I had originally added the shortcode to header.php, but when I add `<div class=’col-md-3′><?php do_shortcode(‘gtranslate’); ?></div>
<div class=’col-md-3 header-7′><?php do_action( ‘boldgrid-theme-location’, ‘header’, ‘7’ ); ?></div>` to header.php the language select tool does not show up.I also changed the class to col-md-6 to align with what is in my current template, but that results in the same thing where the language select tool is missing entirely.
April 12, 2021 at 3:01 pm #36012Jesse OwensKeymasterHi Javier-
Thanks for the reply, sorry that you’re still having trouble! I did make a couple of mistakes-
I tried adding the code to the head.php […] I had originally added the shortcode to header.php [… but] the language select tool does not show up.
You’re right, I meant to say
header.php
, and I also made a mistake in the code. It should bedo_shortcode('[gtranslate]');
(I forgot the brackets in the shortcode).“Your theme does not support navigation menus or widgets.”
This sounds like there may be a technical issue going on with your Child Theme configuration. Double-check the sample files in this tutorial to make sure that the parent Westview theme is being enqueued correctly. If you’re still seeing that message, let us know what you have in your
style.css
and yourfunctions.php
files.April 12, 2021 at 6:25 pm #36028Javier TrevizoGuestI added the code and it did put the language select tool in line with the menu. I found the issue for the menu option in Gtranslate. The Westview theme had not been updated. Once I updated the theme Gtranslate showed options to set the language select tool into the primary menu and it worked well.
Thank you for your help.
- AuthorPosts
- The topic ‘Placing Short Code in the Header Even with Menu’ is closed to new replies.