Support » Fixing WordPress » get_the_tags as variable not working with only one tag

  • Hi all

    am using a plugin (wp geo big map). If i put the following shortcode ( [big_map … lines=”0″ tag=”fast” cat=”2″]
    ) into a post or page it returns a map with all the posts that i specified.

    If I want to use the shortcode in my theme files, I use : <?php echo do_shortcode(‘[big_map … lines=”0″ tag=”fast” cat=”2″]’); ?>

    So far everything is oke.

    But in my Archives (archive.php)file I want the Shortcode to behave dynamically. I want the variables cat (category) and tag to change with the different archive pages. If I go to the tag page of the tag “slow” I want the posts containing the tag “slow” to be displayed on the map.

    to do this I created the following code:

    <?php

    $posttags = get_the_tags();
    if ($posttags) {
    foreach($posttags as $tag) {
    $tags=$tags. $tag->name . ‘+’; }
    $posttags=substr($tags,0,-1);
    }

    echo do_shortcode(‘[big_map … lines=”0″ tag=’.$posttags.’]’);

    ?>

    <?php

    This code gives a map of the posts containing all the archive page tags.

    The problem is that it only works with more than one tag.

    can someone help?

    [duplicate: http://wordpress.org/support/topic/making-shortcodes-more-dynamic?replies=2 – closed]

Viewing 1 replies (of 1 total)
  • Michael

    (@alchymyth)

    Forum Moderator

    If I go to the tag page of the tag “slow”

    you should be able to get the tag slug from the tag archive page by using:

    get_query_var('tag')

    similar for the category ID in a category archive:

    get_query_var('cat')

Viewing 1 replies (of 1 total)
  • The topic ‘get_the_tags as variable not working with only one tag’ is closed to new replies.