• Resolved yanwhite

    (@yanwhite)


    Hi,

    I am using this plugin with Custom Post Types UI and Site Origin Page Builder (and parent theme).

    There are, I think, a few separate issues.
    Firstly I can get this shortcode to display in SO textwidget:
    [related_posts_by_tax]

    This one is not rendered at all:
    [related_posts_by_tax format=”thumbnails” image_size=”medium”]
    which I think may be an issue with Page Builder.

    So, I switched tack and tried adding a couple of things in functions.php:

    // Return posts with post thumbnails for the thumbnail_excerpt format.
    add_filter( 'related_posts_by_taxonomy_shortcode_atts', 'rpbt_thumbnail_exerpt_args' ); // shortcode
    add_filter( 'related_posts_by_taxonomy_widget_args', 'rpbt_thumbnail_exerpt_args' ); // widget
     
    function rpbt_thumbnail_exerpt_args( $args ) {
        if (  'thumbnail_excerpt' === $args['format'] ) {
            $args['post_thumbnail'] = true;
        }
     
        return $args;
    }

    or

    add_filter( 'the_content', 'add_related_posts_after_post_content' );
    function add_related_posts_after_post_content( $content ) {
     
        //check if it's a single post page.
        if ( is_single() ) {
     
            // check if we're inside the main loop
            if ( in_the_loop() && is_main_query() ) {
     
                // add your own attributes here (between the brackets [ ... ])
                $shortcode = '[related_posts_by_tax format="thumbnails" image_size="medium"]';
     
                // add the shortcode after the content
                $content = $content . $shortcode;
            }
        }
     
        return $content;
    }

    neither of which returned anything.
    My custom post type has its own categories defined, which worked fine with the simpler shortcode.

    Do you have any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author keesiemeijer

    (@keesiemeijer)

    Hi yanwhite,

    So, it works, but not with the format thumbnails? Are you sure there are related posts (with the same terms) that have a post thumbnail assigned?

    Thread Starter yanwhite

    (@yanwhite)

    Ah, thank you!
    I had expected since the simpler shortcode worked that the one with thumbnails would also, even without featured images set.
    Got ahead of myself there.. once featured images set everything works.

    Plugin Author keesiemeijer

    (@keesiemeijer)

    You’re welcome.

    Good to know you’ve solved your issue ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Cannot get plugin to work yet..’ is closed to new replies.