Skip to:
Content
Pages
Categories
Search
Top
Bottom

custom post type rewrite rule not working with gpress

  • Avatar of obvio
    obvio
    Member

    @obvio

    hi,
    my set up is a bp site with gpress. I also have a couple of custom-post-types with the rewrite slug ‘turned-on’ in the register_post_type function as follows:
    ‘rewrite’ => array(‘slug’ => “resources”, ‘with_front’ => false)

    problem is that I always get a 404 trying to view these custom posts (i have a single.php and re-saved and flushed the permalinks structure after I added them), but when disabling gPress everything works back without any problems, can you have a look please at your rewrite rules?

    my code is here http://pastebin.com/ubUwrPG3

    thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Avatar of obvio
    obvio
    Member

    @obvio

    I think I found the problem in gpress-post-types.php line 93 flush_rewrite_rules(); you flush the rules on every page load.. so it looks to me not right not logic-wise nor server-efficient.
    looking forward to your thoughts on that.

    Avatar of Mark Smalley
    Mark Smalley
    Member

    @msmalley

    Assuming your problem is on the homepage, the first thing I would suggest you try is to switch off the “place query” from “gPress Options > Advanced Settings > :Loop Settings > Homepage Loop” by selecting “POSTS ONLY” as this will prevent gPress from trying to customize the query_vars and leave them untouched. this will allow us to confirm if it is the way we call the custom post types or the query before using them that is the problem…

    The reason we load the flush_rewrite_rules the way that we do is that we have found it is the only way to ensure that “places” gets properly registered and found it was a bug with the WordPress custom post type function itself and a valid fix as found in the forums and trac for ensuring that it works when in conjunction with other plugins and things that were otherwise getting in the way of properly propagating the custom taxonomies.

    Will be happy to work with you on finding out where the conflict lies, but need a bit more information. Where EXACTLY are you having the problem, and how EXACTLY are you using / calling out the new post types you have create yourself…?

    Avatar of obvio
    obvio
    Member

    @obvio

    hi,

    1. I declare and register a new post type on my functions.php file, the code for it is at http://pastebin.com/ubUwrPG3
    2. it happens on *every* page, post, archive etc. putting a ‘log’ function where you flush_rewrite_rules() is showing that this rule is being called on *any* page (i.e. document, moving between links, not Page Page-post-type) load.
    3. tried the method you suggested (homepage loop) without any success.

    question: why is it important to flush rules each time? if you don’t want the users to re-save the permastruct manually why not asking if (custom-post-type-places == does NOT exist) then flush_rewrite_rules().. ?

    my development is still local, let me know if I can help any other way.

    Avatar of Mark Smalley
    Mark Smalley
    Member

    @msmalley

    Are you confirming that with the removal of the flush re-writes, you are no-longer getting the 404 errors or are you now just looking at ways to best optimize gPress? Either way, I have added this issue to our priority list and will investigate further at the weekend – thanks again for your patience and feedback…

    Avatar of obvio
    obvio
    Member

    @obvio

    Mark,
    in my testing here it works fine without the flush_rewrite_rules(), I did re-save the permalinks after activating gpress.
    just note that my setting over here is not as full-on as you present on the demo site, I´m actually in need of the geo for users and not for places/posts but I’m trying to incorporate it with some custom post types.

    Avatar of Mark Smalley
    Mark Smalley
    Member

    @msmalley

    The flush_rewrite rules are presently initiated at the same time the custom post types themselves are, as this was a recommended solution from a leading developer in the forums for ensuring that custom post type taxonomies are registered at the correct time, for without this rule, some environments, depending on other active plugins and so forth prevent the custom taxonomies from working.

    This is why we have it set up like this and have not had the time to research whether 3.0.1 fixed this problem or not. That is why I need to check with you as to whether this is causing you any problems, or whether you are just concerned by how frequently it gets called…?

    Avatar of obvio
    obvio
    Member

    @obvio

    well.. both, but most important it flushes rules i have setup with other custom post types so flushing the rules from the plugins ‘deletes’ all of the rules that were in place.

    what i’m suggesting is probably declaring the gpress post types and taxonomies on plugin-init (not sure on the name: the hook which is called only *once* when you activate any plugin) and probably letting users know that they might need to save their permastruct again in the permalinks page.

    just to point that i’m not sure this will solve the problem but from what I saw around the web in tuts never actually suggested flushing rules on post-type registration with code (maybe since its only needed once).

    give me an email and i’ll let u access the dev-site i have setup with all of those things.

    Is this any better with gPress 0.2.5…?

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘custom post type rewrite rule not working with gpress’ is closed to new replies.