April 24, 2018 at 3:58 am #4296
I’m having trouble with displaying a ‘show posts’ function in a template file… the problem is that the returned result doesn’t stay within the selected CPT – although it does keep the desired category.
Weirdly I can insert the provided short code into any random page/post edit screen and it will return the desired display of CPT and category, however, when using the function (and dropping into a template file) it only seems to stick with the selected category and gives up trying to keep within the CPT (mixes with all the CPT I have).
Any idea what the issue might be?
MikeApril 25, 2018 at 3:22 am #4309
Still trying to resolve at my end, thinking it’s something to do with the way that I’m adding the code to my category-slug template. Using any random hook area to test the snippet (by the way am using generate press) I do return an accurate result/display.
Grateful for any help you could give me… essentially I’m trying to add the generated WPSP function in favour of using the returned category result and am doing so to separate out the category into its constituent CPT parts (in this case news, events, resources). So it’s really three different <?php if ( function_exists( ‘wpsp_display’ ) ) wpsp_display( *** ); ?> to be added consecutively.
Thanks in advance for your input.
MikeMay 4, 2018 at 4:17 pm #4393
Sorry for not getting back to you sooner.
So when you add the function to the template, posts from every custom post type are displaying even though you have it set to one specific post type?May 8, 2018 at 8:41 am #4456
No worries, think I missed your reply over the weekend, too.
Yes, sorry for not being clearer, posts from every CPT are displaying even though it’s set to one type.
Thanks for any help and ideas,
MikeMay 8, 2018 at 9:15 pm #4464
Can you link me to the one of the pages possibly?May 9, 2018 at 8:03 am #4470
Thanks, yes. It’s currently on a test site http://k8t.2be.myftpupload.com/asylum/ – you’ll see that there’s just a replication of each ‘show post’.
On the home page I’ve just put the short codes in – good result this time.
Thanks again for looking into this,
MikeMay 9, 2018 at 8:23 am #4471
In addition, I’ve added the two different php lines to the after content hook on the page http://k8t.2be.myftpupload.com/about/ and both ‘show posts’ produce the correct result – indicates it’s specifically a category/category template problem?
MikeMay 9, 2018 at 9:11 pm #4481
What happens if you reset the query before each WPSP function?: https://codex.wordpress.org/Function_Reference/wp_reset_queryMay 10, 2018 at 4:51 am #4490
Unfortunately I couldn’t get that to work either…
Also, have noticed that it’s not that there are two wpsp functions, as even with just one, the display isn’t accurate (changed http://k8t.2be.myftpupload.com/asylum/ to show this – apologies that the content doesn’t clearly indicate, but the urls of each item should). I’m stumped (with my limited knowledge).
So probably a category-slug issue given I can get it to work in archive.php, archive-slug.php and page.php?
A potential fudge is to create a page to redirect to, but wanted to try and do things in a more ordered way.
Thanks for your continued support, is much appreciated.
MikeMay 10, 2018 at 9:12 pm #4497
Hmm, tough one.
Another idea is to do this instead, right above your WPSP function: https://codex.wordpress.org/wp_reset_postdataMay 14, 2018 at 11:09 am #4547
Still no luck Tom, I think I might try to fudge it in the way I mentioned above unless you’ve got any other ideas?
Thanks for your help again and time spent thinking on this.
MikeMay 14, 2018 at 9:10 pm #4550
A redirect would work, but isn’t ideal. I’ll play with this and will let you know if I come up with something 🙂May 15, 2018 at 1:06 am #4552
Thanks Tom, much appreciated.
- You must be logged in to reply to this topic.