Forums

Weird behaviour with /post-type and /custom-page (17 posts)

  1. pmdci
    Member
    Posted 2 years ago #

    Hi there,

    I am quite puzzled about a WP behaviour with custom post types. I hope someone here might have an idea of what might be happening...

    Say I have three custom post types, which I use page templates for them:

    * Car - using page-cars.php for this post type
    * Hotel - using page-hotels.php for this post type
    * Partner - using page-partners.php for this post type

    So far, if browse to:

    /partners or /hotels or /partners, it shows the correct page, each page querying the correct post type.

    However, if I browse to /<post-type-name> (that is, the taxonomy name) rather than the custom page I created for them, WordPress redirects to the custom page that queries the post type. For example:

    /partner/ -> redirects to /partners/
    /car/ -> redirects to /cars/

    However, for ONE POST TYPE ONLY (say, hotel), it DOES NOT WORK:

    /hotel/ -> redirects to / (that is, the root directory).

    I am quite puzzled, since I there is almost no difference in these post types configuration (rewrite, query, etc).

    Moreover, the query code in the custom pages for these post types is pretty much the same, only that the post_type name changes. What really changes in these pages is some of the HTML and CSS.

    Any ideas of what might be wrong?

    Cheers,
    P.

  2. Anointed
    Member
    Posted 2 years ago #

    Not sure this will be the answer to all of your questions, but it may help.

    I use this code on my sites:
    http://somadesign.ca/projects/smarter-custom-post-types/

    It's a really clean class for post types and also handles the permalinks quite well. I've been able to expand on it a big to add 'paged' permalinks and a few other changes. For the most part it handles everything I need.

    Hope it helps

  3. pmdci
    Member
    Posted 2 years ago #

    Thanks anointed!

    I'll have a look...

    Cheers,
    P.

  4. pmdci
    Member
    Posted 2 years ago #

    Hi anointed.

    Just one question. Have you tried the gd-taxonomies-tools plug-in?

    Just wondering if this code you sent me wouldn't has been tested with this plugin, since I use it.

    Cheers,
    P.

  5. Anointed
    Member
    Posted 2 years ago #

    I tried gd-tax-tools some time ago. I remember back then that it was not taking care of the 'archive' permalinks and had other issues. The link I sent you seems to take care of all my permalinks issues perfectly for me. I was also able to extend it quite easily for 'paged=archive' situations for 'dual' archive setups.

    At least for me, I like to roll my own code into each theme that I put together vs. relying upon a plugin. It's simple that way, if someone else wants my theme, I can simply send it without having to tell the user to install plugins and set them up etc.

    Most of what I do is build the theme frameworks, and then use the same framework over and over again for all clients. I keep all of my taxonomies, and metaboxes in a separate include file within the theme.

    This way I do not have to recreate the wheel to have a completely different 'post-type' theme. I simply change my 'meta.php' file and whaalla the customer has all brand new custom post-types+meta+taxonomies already to use. simply refresh permalinks button and we're done, no plugins etc...

    Anyhow, I only mentioned it because it sounded like you were having a problem with pretty permalinks in archives. I don't have that problem with this class.

    Hope it helps.

  6. Anointed
    Member
    Posted 2 years ago #

    Pretty much my only 'missing piece' is the page that displays archives sorted via 'post_types + taxonomies' but that is not due to the class. It turns out it's not available in the core post.php yet. I'm working on trying to figure that one out still.

    Scenario:
    taxonomy 'genre' is applied to post-type 'movies & television'.

    How to display a tax->$tax_term page that is like 'only show movies in the genre Classic'.

    I filed a ticket on that one, but so far it's gotten no traction.

    Once I have a pretty permalink fix for that issue, then I'm 100% set.

  7. pmdci
    Member
    Posted 2 years ago #

    If I install this class, should I remove the gd-taxonomy-tools?

    I don't think that removing or deactivating it would remove my existing custom post types and taxonomies, right? Sicne they are already on th WP db...

  8. pmdci
    Member
    Posted 2 years ago #

    anointed,

    Don't know if I am missing the point here, but as per the previous posts, wouldn't creating a page to query these specific posts "movies & television" do the trick? Say I created a template page-movies-tv.php:

    /movies-tv/?genre=classic

    Now, /movies-tv/ is the permalink of page-movies-tv.php, which was created to query the posts of type "movies & tv"

    I am not sure I understood you correctly. Perhaps your issue is when you try to go to the archive permalink of the post type. Say:

    /movie-or-tv/casablanca
    /movie-or-tv/scarface

    Is that correct?

    I also have the same problem, but I thought that the class you proposed above would sort out this issue.

  9. Anointed
    Member
    Posted 2 years ago #

    @pmdci
    I'm not sure about what happens when gd-taxonomy tools is removed. No idea if the fields stay or not. Would have to test that out.

    As to the other questions:
    Yes, that is exactly what I am trying to work out. I create custom taxonomy pages that are supposed to sort out my permalinks. On a basic level this does work.

    Where I run into problems is that I have a taxonomy applied to 'movies & television', so when I create a custom taxonomy page there are issues.

    this ticket will explain it better:
    http://core.trac.wordpress.org/ticket/13582

    To summarize, yes the class I sent over does do exactly as advertised. You can create custom pretty permalinks such as /genre/classic/ and it will work.

    The issue comes into play when the /classic/ page has to sort multiple post-types, which is what is currently not possible.

    A url such as post_type = 'sermons' + custom taxonomy = 'series' plus term = term->slug is not supported.

    In the end, if you only have the taxonomy applied to one post-type, then the class is going to work perfectly for you.

    my sandbox demo site:
    http://deardaddy.org/sermons/
    --post-type sermons archive + multi-relational post-types 'podcasts, preachers, locations'

    http://deardaddy.org/series/the-anointing/
    --taxonomy 'series' --term 'the anointing'
    (note it displays all terms in the series, not just files from 'the anointing' term. this is the problem I am describing)

    Unless I am missing a fundamental option somewhere, wp is just plain not able to do this yet. The bad part is there is no 'real' way to sort post-types via taxonomy. The good part, is that is so important that it's going to have to be fixed soon. I'm even trying to do this myself, though I'm not that great a programmer yet.

  10. Anointed
    Member
    Posted 2 years ago #

    Ohh, I should mention 'moveis & television' are 2 separate post-types in the above example. I think that is where the confusion is coming from.

  11. pmdci
    Member
    Posted 2 years ago #

    I see,

    Well I managed to make something like: /cities/rome and cities/madrid work without any issues. But only with the default post type. For the custom post type "partner", I have to do /partners/?city=rome or /partners/?city=madrid

    note by the URL that I am loading a custom page template partners. If I tried something like /partner/city/rome it wouldn't work.

    --------

    Something that also doesn't work for me is to query a category from a custom taxonomy: /city/rome/?category=5-stars

    But the inverse, that is to query a custom taxonomy from a category, works: /category/5-stars/?city=rome

    As far as I understood, the class you mentioned on this post sorts this last issue?

  12. pmdci
    Member
    Posted 2 years ago #

    ah,

    I have a puzzler at this post: http://wordpress.org/support/topic/406038

    Perhaps you could give me a hand with it? It is way beyond my PHP skills... :(

    Cheers,
    P.

  13. Anointed
    Member
    Posted 2 years ago #

    Yes, I believe that so long as a taxonomy is only applied to a single post-type, then you are correct, it 'should' solve the problem. It's only when you get into sorting taxonomies that belong to multiple post-types where it's borked.

    answered your other post.. ur gonna love that plugin

  14. pmdci
    Member
    Posted 1 year ago #

    Hey anointed,

    A quick question. According to http://codex.wordpress.org/Theme_Development, I can add a template file called taxonomy.php (eg.: city.php). So if I do browse to /city/rome in my site, it would display the custom template.

    My question is, I created a custom taxonomy called city, which has various terms: Rome, Madrid, London, Barcelona, New York, etc.

    What I need is to ensure that I can have custom META keywords for their permalinks, such as: /city/rome, /city/madrid, etc.

    How do you think is the best way to accomlish this? Do I need yet more templates?

    What do you think?

    BTW, do you use any sort of instant messaging online? Would be cool to exchange ideas in a more fast and efficient way :)

    Cheers,
    P.

  15. Anointed
    Member
    Posted 1 year ago #

    was curious if you were able to figure out the pretty permalink issue. Been messing with it myself for a few days again, yet no further along.

    btw
    found your msn handle (from other forum). just added you

  16. pmdci
    Member
    Posted 1 year ago #

    @anointed,

    I gave up on some of the pretty permalink stuff. I think that what I got so far is enough for now.

    Are you sure you found me? I didn't get any request. Shame this forum system doesn't allow Private Messages...

    In the meantime I am picking my brains up with a quite odd request. Perhaps you have seen something like this being done before? Here is the link: http://wordpress.org/support/topic/411092

    Cheers,
    P.

  17. pmdci
    Member
    Posted 1 year ago #

    By the way, I moved the subject of this topic to http://wordpress.org/support/topic/404629 which I think is more to the point of what I was trying to do and shows the limitations of WP. I was hoping that this would attract people's attention to the issue and perhaps collaborate on how to find a solution for it, but I got no luck (which is often the case).

    Cheers,
    P.

Topic Closed

This topic has been closed to new replies.

About this Topic