• Hello,

    Is it possible to insert a shortcode underneath the Main Menu in the header? I would like to put an audio player there in hopes that it won’t refresh when I select a new page (as I’ve noticed the menu doesn’t appear to). If this will work, do I just insert the shortcode into the header.php file (child theme of course)?

    Where exactly should I put it in the header.php file, and how do I force the shortcake to execute when inserted in a template?

    Thanks for your help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Theme Author TT Themes

    (@tomastoman)

    Hi,

    please search for the following code in “header.php”:

    <?php wp_nav_menu( array( 'menu_id'=>'nav', 'theme_location'=>'main-navigation' ) ); ?>

    Just under it, place this code to display an audio player:

    <div style="float: left; margin: 10px 0 0; width: 100%;"><?php echo do_shortcode( '[audio src="https://url-of-your-audio-file.mp3"]' ); ?></div>

    If you would like to remove the default margin below the audio player, please use this custom CSS:

    .menu-box .wp-audio-shortcode {margin-bottom: 0;}

    Best regards,
    Tomas Toman

    Thread Starter LindsiKay

    (@lindsikay)

    Thank you so much for helping me!

    I inserted the code (as shown below), but nothing seems to be appearing below the menu still. Any idea why? I also tried inserting your code by only changing the File URL to a song in my media library. Nothing showed then either. I tried disabling a few plugins as well, which had no effect.

    <?php } ?>
    <?php wp_nav_menu( array( ‘menu_id’=>’nav’, ‘theme_location’=>’main-navigation’ ) ); ?>
    <div style=”float: left; margin: 10px 0 0; width: 100%;”><?php echo do_shortcode( ‘[playlist tracks="Love-WIll-Bring-Us-Back-Home1.mp3, Ascending-Into-Color.mp3, Gypsies.mp3", Space-For-Space-MSTR.mp3, Dangified-MSTR-01.mp3]‘ ); ?></div>
    <div class=”scroll-top”></div>
    </div>

    Thank you again! I really appreciate it!

    Lindsi

    Theme Author TT Themes

    (@tomastoman)

    Dear Lindsi,

    according to the Codex page, it seems that the “tracks” is not a valid parameter for the “playlist” shortcode. Instead of it, you should specify IDs of audio files out of the media library.
    Or, if you decide to use the “audio” shortcode instead of “playlist”, please try to specify the full URL address of an audio file instead of relative URL, for example:

    [audio src="https://wpthemetestdata.files.wordpress.com/2008/06/originaldixielandjazzbandwithalbernard-stlouisblues.mp3"]

    Best regards,
    Tomas Toman

    Theme Author TT Themes

    (@tomastoman)

    You can find the appropriate audio file’s ID in the media library, when you display the detail of an audio file (the ID is located in your browser’s address bar like this).

    Thread Starter LindsiKay

    (@lindsikay)

    Thank you so much Tomas!

    Theme Author TT Themes

    (@tomastoman)

    You are welcome!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘shortcode underneath main menu in the header’ is closed to new replies.