• Hello everyone,

    Got my WP website running a few days ago and currently working out a few last tweaks. Searched for about 3 hours now and decided to come for help here.

    So.. What am I trying to do?

    I have a button which is currently linked to a YouTube page. I wish for that youtube page to open up on my website kind of like a popup window.(I want the background dimmed and video put in the middle of my site and autoplay upon click of that button)

    I have found a Plug in and created a shortcode (Youtube Fancy Box).

    By inspecting the code element of a button I wish to replace the reference with a shortcode.

    Original code on the page:

    <div class="bottom_tagline_button">
      <a href="https://www.youtube.com/watch?v=xxxxxxxx">Click ME</a>
        </div>

    This is what I tried replacing it with but it didn’t work…

    <div class="bottom_tagline_button">
    <?php echo do_shortcode('[youtube videoid="3we5z1xzSAE" height="0" width="0"]'); ?>
    </div>

    Could anyone help me out or at least consult me on this matter?
    Highly appreciate your help!
    Thanks all in advance!!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Hi azubets21

    Can you provide a link to the Youtube Fancy Box plugin.

    Did it come with a shortcode you can use or are you trying to create your own shortcode?

    http://codex.wordpress.org/Shortcode_API

    Thread Starter azubets21

    (@azubets21)

    YFancy Box plugin – https://wordpress.org/plugins/youtubefancybox/

    I am trying to create my own shortcode. By inputting all the definitions within the plugin it generates a shortcode for me –
    ([youtube videoid=”3we5z1xzSAE” height=”0″ width=”0″]) exactly which i am trying to run.

    Moderator keesiemeijer

    (@keesiemeijer)

    So if I understand it correctly your shortcode wraps the fancy box plugin inside the .bottom_tagline_button” div.

    Can you show us the shortcode callback function you have now?

    Maybe the problem is that you echo the do_shortcode() function in your shortcode. See the output section of the API:
    http://codex.wordpress.org/Shortcode_API#Output

    Thread Starter azubets21

    (@azubets21)

    Pardon me but I do not understand what you mean by callback function.

    All I want to change is to run a shortcode (plugin) instead of having people redirected to another site (as is happening with original code).

    Moderator keesiemeijer

    (@keesiemeijer)

    Ah, I see.

    Where are you using this?

    <div class="bottom_tagline_button">
    <?php echo do_shortcode('[youtube videoid="3we5z1xzSAE" height="0" width="0"]'); ?>
    </div>

    In a theme template?

    Thread Starter azubets21

    (@azubets21)

    Yes. It’s a premade button in a theme. (Believe it’s called roadwarrior or smth.)

    Moderator keesiemeijer

    (@keesiemeijer)

    What happens if you don’t use the width and height attributes:

    <div class="bottom_tagline_button">
    <?php echo do_shortcode('[youtube videoid="3we5z1xzSAE"]'); ?>
    </div>

    You can also set the default width and height in the settings page for the plugin:
    https://wordpress.org/plugins/youtubefancybox/faq/

    Thread Starter azubets21

    (@azubets21)

    No, it doesn’t work and I am starting to think that the shortcode isn’t working at all.. This is possibly due to plugin bug..

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Replacing HTML Link with a Shortcode.’ is closed to new replies.