How to add a custom URL placeholder to author archives?

Option 1 I assume custom post type generate a URL something like this domain.com/%custom-post-type%/%list% So you could write it so it looks as… since the main URL doesn’t have author before custom type you would have to do this via a function since authors are dynamic RewriteRule ^members/%author%/(.*)$ domain.com/%custom-post-type%/$1 This doesn’t specifically modify the custom … Read more

Removing hierarchical pages in the permalink

I’d be curious if someone can find a better solution to this. Here’s what I came up with: function wpse_91821_flatten_page_paths( $wp ) { if ( false !== strpos( $wp->matched_query, ‘pagename=” ) && isset( $wp->query_vars[“pagename’] ) && $wp->query_vars[‘pagename’] && false === strpos( $wp->query_vars[‘pagename’], “https://wordpress.stackexchange.com/” ) ) { if ( !get_page_by_path( $wp->query_vars[‘pagename’] ) ) { $page = … Read more

Regex in add_rewrite_tag not accepting OR operators?

I don’t know what’s wrong but I can suggest: Use Rewrite Rules Inspector or similar to see where your %psubject% rule is and if its pattern ((option1|option2|option3)) has been added correctly. Test http://example.com/somecategory/option1/this-is-the-post-title with the Inspector to see which rule matches. Open http://example.com/somecategory/option1/this-is-the-post-title (when it shows home.php) with the Debug Bar plugin and look at … Read more

Archive permalinks

The really easy way: Change your permalink structure to include a “front” part. Eg. /news/%postname% The slightly more complicated and inflexible way: WordPress holds it’s data permastruct in a property of the global WP_Rewrite object stored in $wp_rewrite. You can hook in sometime early-ish (around init) and change this. <?php add_action(‘init’, ‘wpse39274_change_date’); function wpse39274_change_date() { … Read more

Date based URLs for custom posts and pagination

Calling $GLOBALS[“wp_rewrite”]->flush_rules() did make everything work as I required but that wouldn’t be a good solution. Actually, you have to flush the rewrite rules after modifying them (i.e. also when registering custom post types). Also, you should never rely on these global variables. WordPress provides specific functions for nearly everything. For example, use flush_rewrite_rules() instead … Read more

WordPress 4.4+ breaks Walker Extension

Your original solution was a hack, and no surprise it failed. In general never add methods/attributes to objects that you do not control their class and future development. The right way is to create your own object to be passed to the walker. Pass to it the category object on construction and either populate fields … Read more

Minimal custom permalink structure

Hi *@Bobby Jack:* You’ll have absolutely zero problem given your number of pages and posts. If you were looking at 5000, 10k, 25k pages or more, then start to worry. And the real problem is with categories as the URL base in the current implementation of WordPress’ URL routing (which I hope to see changed … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)