• Hi everyone, I added a function for my own shortcodes:

    function events_list( $atts , $content = null ) {
        global $post;
        ...
    }
    add_shortcode('eventlist', 'events_list' );

    On pages and categories it works without any problems.
    But when I add the shortcode on a “tag” page, I just get the output of the shortcode: [eventlist] or [eventlist tagid=””]

    Anyone an idea how to solve this issue?
    Couldn’t find something helpfull about this topic on google.

    Thank you so much!

    • This topic was modified 4 years, 8 months ago by t-p. Reason: Moved to Fixing WordPress from Everything else WordPress

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • is there a tag.php in your theme?
    if yes, is that different from category.php or archive.php?

    does it use the_content() in its loop?

    is the shortcpde from a plugin or selfmade?
    can you share the full code of the shortcode function, via pastebin?

    PS: could it be you are trying to use the shortcode in the tag description or somehow in the page header of the tag page, not within a post?

    PPS:
    read https://wordpress.stackexchange.com/questions/139584/is-it-possible-to-add-short-code-and-html-tag-in-category-description

    possibly try to add this to functions.php of your theme:

    add_filter( 'term_description', 'shortcode_unautop');
    add_filter( 'term_description', 'do_shortcode' );

    or possibly (untested):

    add_filter( 'get_the_archive_description', 'do_shortcode' );

    Thread Starter flaschenzug22

    (@flaschenzug22)

    Thanks for your reply(s) Michael.

    There is not tag.php in my Theme folder.

    I try to add the shortcode in the tag description, yes. (not in a post)
    But in the category description it works without problems.

    Is the shortcpde from a plugin or selfmade?
    can you share the full code of the shortcode function, via pastebin?

    It is selfmade. Added in the function.php in the child theme
    https://pastebin.com/azNiPCXj

    Thread Starter flaschenzug22

    (@flaschenzug22)

    No ideas or experiences? Would be amazing to solve this problem.
    Thanks ??

    what is the code in archive.php (or index.php) of your theme to show the tag description / archive description?

    have you tried to add the suggested filter functions to functions.php of your theme?

    what parent theme is your theme based on?
    if you are not the creator of the theme, have you contacted the developer of the theme for help?

    Thread Starter flaschenzug22

    (@flaschenzug22)

    Here is the archive.php:

    <header class="page-header">
    				<?php
                    echo "<h1>".single_cat_title( '', false )."</h1>";
    				the_archive_description( '<div class="archive-description">', '</div>' );
    				?>
    			</header><!-- .page-header -->

    and then just the normal content:

    if (have_posts()) :
                    while ( have_posts() ) :
                        the_post();
    
                        /*
                         * Include the Post-Type-specific template for the content.
                         * If you want to override this in a child theme, then include a file
                         * called content-___.php (where ___ is the Post Type name) and that will be used instead.
                         */
                        get_template_part( 'template-parts/content', get_post_type() );
                    endwhile;
    
    			    the_posts_navigation();
    			endif;
    Thread Starter flaschenzug22

    (@flaschenzug22)

    You are a genius.
    I think i just tested the first two “add_filter” ideas you had.

    Now I tried to add:
    add_filter( ‘get_the_archive_description’, ‘do_shortcode’ );

    And tada, it is working!
    Thank you so much for your fast and precise support!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Shortcode not working in tags’ is closed to new replies.