June 20, 2016 at 22:11 UTC - Views: 2 #29177
Hi Weaver, thanks for your reply. One of the best things about this theme is that there’s someone to talk to.
Before you replied I played around a little more trying to get my shortcode plugin to work. I added wp_reset_postdata() just before return $output and for reasons which I don’t understand it’s now working – each custom post displaying as a formatted table row, but I’m worried about your warnings about “messing up instances of the loop used by page or post processing”, I still don’t understand why the loop inside the plugin should have any influence over loops elsewhere, but if you think this is a risk I’ll try and implement [show_posts] as you suggest.
Thanks for your help.
DavidJune 20, 2016 at 22:19 UTC - Views: 1 #29178
I don’t think he meant that the loop you would use in a specific page would influence other pages, but more it you use your loop in a page that already has one.
In any case, if it messes something you will see it. If your pages work fine, you should be OKJune 21, 2016 at 15:35 UTC - Views: 2 #29179
The WordPress loop is not designed to be recursive, to use the technical term. And whenever you display a page or a post, there is a top level instance of the loop. For one thing, once your are inside the loop, a bunch of values to the WP global $WP_Query are set. If you then try to create or use another instance of the loop, the top level “gets lost” – all the values are gone, so nothing works right.
If you do create a new instance of the loop, usingwp_reset_query();wp_reset_postdata();
at the end of your use of the loop, then the previous values of the loop are reset.
It is not exactly that simple, but mostly that works if your instance of the loop is simple, and the original loop isn’t inside displaying a bunch of posts. In other words, if the top level is a page, things are simpler. Nesting posts inside of posts can easily create additional issues – the paging of posts, for example.
Just FYI, it took us months or more to get [show_posts] to work right with most themes and other instances of the loop. Because of inherent limitations in the WP implementation of the loop, [show_posts] and the Page with Posts template will still not display things correctly if a post displayed with [show_posts] also uses [show_posts]. No recursion!June 21, 2016 at 15:56 UTC - Views: 1 #29180
Thanks so much Weaver for clarifying the situation and giving such a clear explanation, much appreciated, now finally I can move on.July 1, 2016 at 00:15 UTC - Views: 3 #29181
Tried your suggestion
“If the actual content of your custom post type is already
formatted as a table that would fit under you table header stuff, then
you might be able to use the Weaver Show Posts short code to display a
defined set of your custom posts. – put the header on a standard page,
and use [show_posts] to display your posts.“
The problem is if I put the table header on a standard page followed by [show-posts] the individual posts lose the table format (the td elements display vertically, not horizontally ) ’cause they’re missing the <table> header part
Or am I doing something wrong?
Thanks for your help
DavidJuly 1, 2016 at 01:16 UTC - Views: 1 #29182
provide the html you are using with a more detailed explanation of what you are trying to put together
You must be logged in to reply to this topic.