Plugin/videos content visualization instead of the raw shortcode.

I have some plugins like GMaps installed. They gave me shortcodes on their output to, for example, show a map [gmap id=1] to show a google map for example. How can i make that the output on the posted customized post is shown as the map (for example), instead of the raw shortcode code? Same question for Youtube links, how can i embed the link directly in my customized post? Thanks a lot!

  • Ash

    Hello @Guido

    Welcome to WPMU community!

    I hope you are well today and thanks for asking the question.

    You can use same shortcode in same way for the custom post. Like [gmap id="1"] will work for custom post type too. Same for youtube links and all other shortcodes. The instruction is same. Just use the same shortcode in same way in custom post type :slight_smile:

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • Guido

    No, it did not worked. I've used a other post form here for the videos with this phpfunction:

    <?php
    								$video = do_shortcode('[ct id="ct_Video_2_text_ce90" property="value"]');
    								$parts = parse_url($video); //Break up the youtube url
    								if(empty($parts['query'])){
    									$vid = trim($parts['path'],'/ '); //No query string use the path to get the ID
    								} else {
    									parse_str($parts['query'], $vout); //Have a query string, use the v=ID
    									$vid = $vout['v'];
    								}
    								?>
    								<iframe width="400" height="300" src="http://www.youtube.com/embed/<?php echo $vid?>" frameborder="0" allowfullscreen></iframe>

    But i wasn't successfull on my try to adapt this function to the gmap.
    Att
    Guido

  • Vinod Dalvi

    Hi Guido,

    Thank you for your reply.

    Actually by default the shortcodes work in the post/page content because generally the theme used the function the_content to display its content and this function also executes the shortcode added in the content.

    If you are displaying the shortcode content by echoing it directly then you can use the function do_shortcode to execute the shortcode as following.

    echo do_shortcode( '[gmap id="1"] ' );

    You can embed the Youtube links and other videos in your customized post as described on the following pages.

    https://codex.wordpress.org/Embeds
    https://codex.wordpress.org/Video_Shortcode

    If the above information doesn't help you to achieve it then could you please tell me a bit more in detail what you are trying to achieve by sharing the screenshots of it if possible so that i can provide you the exact solution to achieve it?

    Regards,
    Vinod Dalvi