harrisonca
Forum Replies Created
-
It does work, however we are missing a checking case. I don’t know the code too well, but it seems like before if let’s say it was looking for path like: /abc/def
This current dev version would check:
/abc/def
/abc/def/
abc/defThe currently released code checks:
/abc/def
abc/def
abc/def/But not the case /abc/def/
So i’m not sure whether it is necessary to keep the case to check for “abc/def/”.
This isn’t the cleanest of code, but it seems to have solved my issue, hopefully not introduced new ones.
Main problem was that get_post_by_custom_permalink function seemed to always remove trailing slash when trying to lookup custom permalinks. So it is no real wonder why trailing slash permalinks are never found.
/** * Fetch a single post based on the custom permalink value stored as custom * meta data. * * @param string $permalink */ function get_post_by_custom_permalink( $permalink, $exclude = false, $suffix = '' ) { $post = false; if ( $front = $this->front() ) { $permalink = str_replace( $front, '', $permalink ); } // Fetch all the public post types to lookup against... if ( $post_types = get_post_types( array( 'public' => true ), 'names' ) ) { if ( $posts = get_posts( array( 'post_type' => $post_types, 'meta_key' => '_' . $this->tag . $suffix, 'meta_value' => $permalink, 'posts_per_page' => 1, 'exclude' => $exclude ) ) ) { $post = array_shift( $posts ); } else if ( substr( $permalink, -1 ) != '/' ) { // Lookup with a slash appended, just in case... $post = $this->get_post_by_custom_permalink( trailingslashit( $permalink ), $exclude, $suffix ); } else if ( substr( $permalink, 0, 1 ) == '/' ) { // Lookup without a slash prefix, this is the ideal behaviour // however the above is required for backwards compatability. $post = $this->get_post_by_custom_permalink( ltrim( $permalink, '/' ), $exclude, $suffix ); } else if ( substr( $permalink, -1 ) != '/' ) { // Lookup with a slash appended, just in case... $post = $this->get_post_by_custom_permalink( trailingslashit( $permalink ), $exclude, $suffix ); } } return $post; }I don’t think it is a flushing issue with the cache. I tried saving the post as well as saving in the Settings->Permalinks page to force the flush. I also tried editing the index.php file with the fix mentioned above. None seem to work.
I seem to be facing the same/similar issue as well.
If my custom permalink contains a trailing slash, I get a 404 error no matter how i access the page.
If I remove the trailing slash from the custom permalink, then both URLS (with and without trailing slash) then work.
How do I set a custom permalink with a trailing slash but WITHOUT a file extensions like: /laws/CA/
I have a reproducible case on my development blog. Would be happy to give access to help figure this out.
Forum: Installing WordPress
In reply to: Install Step 2 Failing at populate_options();Found the solution!!! What a pain… a problem with php and sql apparently. One of the functions mysql_fetch_assoc was causing a crash.