Support » Plugin: CPT-onomies: Using Custom Post Types as Taxonomies » [Plugin: CPT-onomies: Using Custom Post Types as Taxonomies] Comics and stories

  • Resolved Li-An


    I’m looking at your plugin because I try to put into a regular blog a comics section.
    I created with your plugin (very easy to use, thanks !) two custom posts:
    1. comics: each post will be a comics page (sorry not a WP page !)
    2. stories: each post is a story and I did CPT-onomy it and attach to comics

    To navigate between pages, there is no problem (I can use plugin). I hope I will manage to navigate between stories with your plugin – a problem I cannot manage with classic custom taxonomies as there is not “go to first post in next category”.
    So, if I am in post 3 in story C, can I make a link to post 1 in story B or D (previous and next stories). Have you some idea how to get this ?

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Rachel Cherry


    Hi again =)

    So basically you would like to use the previous_post_link() and next_post_link() functions with your cpt-onomy instead of the default taxonomy “category”?

    Yes, something like this. There is no possibility to get “next/previous category” (I did not find) but, as with your plugin “categories” are “posts” too, I was hoping it could be possible.

    Plugin Author Rachel Cherry


    It’s not possible right now but I’ll add it for the next version.

    Thanks for pointing it out!

    Well, thank you for such a positive answer 🙂 I will wait for it.

    Plugin Author Rachel Cherry


    Just wanted to let you know version 1.0.2 is now available AND includes support for previous_post_link(), next_post_link(), prev_post_rel_link() and next_post_rel_link().

    global $cpt_onomy;
    $cpt_onomy->previous_post_link( $format, $link, $in_same_cpt_onomy, $excluded_term_ids, 'comics' );
    global $cpt_onomy;
    $cpt_onomy->next_post_link( $format, $link, $in_same_cpt_onomy, $excluded_term_ids, 'comics' );

    These CPT-onomy functions work exactly like the WordPress functions and take an extra parameter that allows you to designate which CPT-onomy to use for $in_same_cpt_onomy.

    I’m still working on adding these functions to the CPT-onomies documentation but they should be available within the next day or 2.

    I hope this is what you were looking for. Let me know if you come across any problems. Thanks!

    Thank you, I will take a look at it.

    well I’m a little lost – sorry I’m not a developper.
    You can see here what I managed to do

    But I don’t know how to insert a link to next and previous story in the page… If it’s possible !

    Plugin Author Rachel Cherry


    Are you using the previous_post_link() and next_post_link() functions within The Loop?

    They are template tags and must be used in The Loop.

    Yes I did use them in the loop… and outside. It gives the same result aka the next and previous post in same custom post. But not the next or previous story.

    I use

    <?php next_post_link( '<strong>< %link</strong>' ); ?> ||
    <?php previous_post_link( '<strong>%link ></strong>' ); ?>

    It seems logic for me but it’s not what I want 🙂

    Plugin Author Rachel Cherry


    If you’re wanting the link for the next post that’s in the CPT-onomy ‘stories’, you have to use the CPT-onomy function: $cpt_onomy->next_post_link().

    If you just wanted the next post link, you could use next_post_link() but, because defining a CPT-onomy to overwrite the default taxonomy ‘category’ is a custom feature that’s not available in the core WordPress function next_post_link(), I created a custom previous_post_link() and next_post_link() just for CPT-onomies.

    These CPT-onomy functions do mirror the WordPress functions, however, and accept the same parameters with the exception of an additional parameter that lets you define with CPT-onomy you want to use:

    global $cpt_onomy;
    $cpt_onomy->previous_post_link( '<strong>< %link</strong>', '', true, '', 'stories' );
    $cpt_onomy->next_post_link( '<strong>< %link</strong>', '', true, '', 'stories' );

    I’ve added previous_next_link() and next_post_link() to the CPT-onomies documentation if you need more information.

    Thank you for the time you give me !
    I have seen the documentation and now understand much better the function.
    But it does not want to work correctly 🙁
    I inserted

    <?php global $cpt_onomy;
    $cpt_onomy->next_post_link( '<strong>...%link</strong>', '', true, '', 'stories' ); ?>||
    <?php global $cpt_onomy;
    $cpt_onomy->previous_post_link( '<strong>%link...</strong>', '', true, '', 'stories' ); ?>

    after checking stories is my name for the taxonomy. The link does not show. Looking at the source I’ve got:

    <strong>< <a href="" rel="next">SF</a></strong> ||
    <strong><a href="" rel="prev">Dark (2)</a> ></strong><br>
    <strong><a href="" rel="prev"></a>...</strong>

    The two first links are the regular “next_post_link” and previous.
    The next_post_link does not seem to produce anything and the previous_post_link gives the same result for the link but no text.

    If you want I can give you the url of my test blog.

    Plugin Author Rachel Cherry


    It’s no problem. Yea, send me the URL for your test blog.

    FYI: You don’t have to do global $cpt_onomy twice. Once, at the beginning, will do the trick =)

    Plugin Author Rachel Cherry


    Ok. I figured out the problem. It seems that you have to define both of the first 2 parameters, $format and $link, of the $cpt_onomy->previous_post_link() and $cpt_onomy->next_post_link() functions for the link to print correctly. The functions were finding the previous and next post information but because $link was ”, the printed link was empty.

    The easy fix: define $link (just put the default which is ‘%title’).

    I apologize for this oddity. I just copied and pastied the WordPress previous_post_link() and next_post_link() to create $cpt_onomy->previous_post_link() and $cpt_onomy->next_post_link() and this weirdness never crossed my mind.

    I have updated the documentation to point out this issue and will “fix” this little bug for the next version.

    I hope this fixes everything. Let me know if it doesn’t. Thanks!

    Plugin Author Rachel Cherry


    Of course, now that I think about it some more, it makes sense that by defining $link as ” (which is empty), the printed link text would be empty (the function still prints the wrapper).

    AND, as strange as it sounds, I can imagine instances where you might not want the link text so I’ll leave the setup as it is for now and update the documentation to make the $link parameter be required, unless you want the printed link text to be blank.

    Thanks for your help in finding this little gem =)

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘[Plugin: CPT-onomies: Using Custom Post Types as Taxonomies] Comics and stories’ is closed to new replies.