• Resolved seeekr

    (@seeekr)


    Hi plugin devs,

    I’m working on a client’s site where we had the Shariff plugin not properly ignoring custom post types and therefore slowing performance (generating more http request to backend).

    I investigated and found that for us the “should shariff insert itself after this post?” logic did not seem to be working. So I fixed it. Sending you the patch here so you can investigate for yourselves and hopefully incorporate a fix for everyone.

    https://gist.github.com/seeekr/558d0d81154d24851abb

    (I’m not super experienced in WP development, so I might be misunderstanding something going on here, and if so, please let me know and/or adjust the patch.)

    Site where you can see the bug live in action:
    https://www.testboks.com/vebu/

    If you open the network tab in the dev console and filter for “shariff” you’ll see a number of shariff backend requests being sent off for a number of testimonial custom post items on the page. We have definitely disabled shariff for that post type through shariff’s settings.
    (The patch I’ve linked to is not live yet on that site, but only in my private dev env.)

    Cheers,
    Denis

    https://wordpress.org/plugins/shariff/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Jan-Peter

    (@starguide)

    Hi seeekr,

    thank you for your efforts. Currently I’m still trying to understand, what happens and why your fix works. is_singular( ‘post’ ) is under normal circumstances a) not true on a blog overview page and b) not for custom post types. So the main question for me right now is, why it is considered true in your widget.

    Are you using any plugin for your testimonials_widget? If not and you programmed it yourself, how are you fetching the content?

    JP

    Thread Starter seeekr

    (@seeekr)

    Hey JP,

    it is self-programmed, though not by me personally:

    public function widget( $args, $instance ) {
            echo $args['before_widget'];
            $qargs = array(
                    'posts_per_page' => 3,
                    'post_type' => 'testimonial'
                );
                $ttm_query = new WP_Query( $qargs );
                if ( $ttm_query->have_posts() ) : ?>
                <div id="testimonials_wrapper">
                    <?php while ( $ttm_query->have_posts() ) : $ttm_query->the_post(); ?>
                        <div class="testimonial_item row">
                          <div class="medium-4 column">
                            <?php the_post_thumbnail('thumbnail'); ?>
                          </div>
                          <div class="medium-7 column">
                            <h3><?php the_title(); ?></h3>
                            <div class="entry"><?php the_content(); ?></div>
                          </div>
                        </div>
                    <?php endwhile; ?>
                </div>
                <?php wp_reset_postdata(); endif; ?>
            <?php echo $args['after_widget'];
        }

    Does that answer your question? Let me know if I can provide any further assistance 🙂

    – Denis

    Plugin Author Jan-Peter

    (@starguide)

    Hi Denis,

    just a quick note: I haven’t forgotten about you, I’m just a bit busy this week at work. I’ll get back to you as soon as I can.

    JP

    Thread Starter seeekr

    (@seeekr)

    Hey JP,

    thanks, appreciated!

    – Denis

    Plugin Author Jan-Peter

    (@starguide)

    Hi Denis,

    in Version 4.0 I adopted your fix partially. It did not work out for pages and caused some trouble with a few major page builders. Let me know if 4.0 works out of the box for you or if we have to revisit this topic.

    Thanks!

    JP

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

The topic ‘Custom post types: Settings are not properly respected (with patch!)’ is closed to new replies.