• Resolved cogdog

    (@cogdog)


    I am using the plugin merely to echo the total number of posts on a site just using [sbs_posts] both in the body text of the front page and in a footer widget.

    On the front of the site, it reflects the current current count (28 posts), but the footer widget on a single post shows one higher, 29. Is this a loop issue or something else?

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jeff Starr

    (@specialk)

    It could be a conflict with your theme, or with another plugin. What happens is that plugins and themes call/output a set of posts using a custom loop. If/when the developer forgets to properly “reset” the loop, it can cause problems for any other loops executed thereafter. So in the footer that would make sense as it comes after any/all other loops on the page.

    Thread Starter cogdog

    (@cogdog)

    Thanks for the quick response. It’s my child theme, so I should be able to do a loop reset.

    Plugin Author Jeff Starr

    (@specialk)

    Here is a guide with some different ways to reset the loop.

    Also before changing any code, you could test the theory by switching to one of the default WP themes. They all are good at resetting any custom loops, so the shortcode should work fine in that case.

    Plugin Author Jeff Starr

    (@specialk)

    Hi @cogdog, just wanted to follow up with this. It’s been awhile with no reply, so I hope the issue is resolved? Or if there is anything I can do to help, please let me know. Thank you.

    Thread Starter cogdog

    (@cogdog)

    Thanks for the follow-up, Jeff, you are a valuable exception here on providing quick and responsive help.

    No I had no luck adding any of the query reset commands after my main loop. Since this is my own child theme I found an easier solution to roll my own simple shortcode:

    // ----- short code for number of things in this splot
    add_shortcode('splotcount', 'splot_count_splots');
    
    function splot_count_splots() {
    	return wp_count_posts()->publish;
    }
    
    Thread Starter cogdog

    (@cogdog)

    Yup resolved.

    Plugin Author Jeff Starr

    (@specialk)

    Great news, glad you found a solution @cogdog.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Count One Higher on Footer Widget in Post’ is closed to new replies.