[Support request] Custom Post Types and Categories

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Custom Post Types and Categories

Tagged: ,

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #4296
    Michael
    Participant

    Hi Tom

    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?

    Many thanks

    Mike

    #4309
    Michael
    Participant

    Hey Tom

    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.

    Cheers

    Mike

    #4393
    Tom
    Keymaster

    Hi Mike,

    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?

    #4456
    Michael
    Participant

    Hi Tom

    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,

    Mike

    #4464
    Tom
    Keymaster

    Can you link me to the one of the pages possibly?

    #4470
    Michael
    Participant

    Hi Tom,

    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,

    Mike

    #4471
    Michael
    Participant

    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?

    Mike

    #4481
    Tom
    Keymaster

    What happens if you reset the query before each WPSP function?: https://codex.wordpress.org/Function_Reference/wp_reset_query

    #4490
    Michael
    Participant

    Hi Tom

    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.

    Mike

    #4497
    Tom
    Keymaster

    Hmm, tough one.

    Another idea is to do this instead, right above your WPSP function: https://codex.wordpress.org/wp_reset_postdata

    #4547
    Michael
    Participant

    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.

    Cheers

    Mike

    #4550
    Tom
    Keymaster

    A redirect would work, but isn’t ideal. I’ll play with this and will let you know if I come up with something 🙂

    #4552
    Michael
    Participant

    Thanks Tom, much appreciated.

    Mike

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.