Rewrite rule page url with category

Just of the top of my head, something along this way might work: function wpse178647_rewrite() { add_rewrite_rule( ‘^([^/]+)/([^/]+)/?$’, ” ‘index.php?category_name=$matches[1]&pagename=$matches[2]’, ‘top’ ); } add_action( ‘init’, ‘wpse178647_rewrite’ ); Completely and utterly untested.

Clash of the rewrites

Your best option is to register neighborhoods as a custom taxonomy and use that instead of categories. In your theme’s functions.php file, you just need to add: function neighborhoods_init() { // create a new taxonomy register_taxonomy( ‘neighborhoods’, ‘post’, array( ‘label’ => __( ‘Neighborhoods’ ), ‘hierarchical’ => true ) ); } add_action( ‘init’, ‘neighborhoods_init’ ); Next, … Read more

How to give a CPT (custom post type) a date based url

Assuming that your event rewrite slug is event and you want your datebased URLs to look like: http://domain.com/event/2011-06-14/ function custom_permalink_for_my_cpt( $rules ) { $custom_rules = array(); // a rewrite rule to add our custom date based urls $custom_rules[‘event/([0-9]{4}-[0-9]{2}-[0-9]{2})/?$’] = ‘index.php?post_type=event&event-date=$matches[1]’; return $custom_rules + $rules; } add_filter( ‘rewrite_rules_array’, ‘custom_permalink_for_my_cpt’ ); // add a query var so … Read more

What’s the URL for a category archive?

There is no date-based archive for a category. The /category/[slug]/ pages are already “archives”, in that they display old posts over different pages. The different pages can be accessed by adding page/2/, page/3/, … to the URL. The template tags to add these links are next_posts_link() and previous_posts_link(). If you want to add a date-based … Read more

Display posts with author in the url with custom post types

You can use the %author% tag in the rewrite property in register_post_type(). However, although the rewrite rules are added (after they’re flushed) – WordPress doesn’t replace the tag with its appropriate value when generating the permalink of your post type. For instance you end up with the permalink www.example.com/%author%/gallery-name The following replaces %author% with the … Read more

Custom slug in front of search URL

None of the above worked for me. Found another solution by overwriting the search rewrite rules using the search_rewrite_rules filter. 1 – Add this to the functions.php of your theme: add_filter( ‘search_rewrite_rules’, function($rules) { $new_rules = []; // New search slug here $new_search_slug = ‘zoeken’; foreach ($rules AS $key => $value){ $new_rules[str_replace(‘search’, $new_search_slug, $key)] = … Read more

Why is WordPress saving full-urls to the database?

If there were only relative URLs, what would they be relative to? A post can be viewed in several different contexts, including a feed, and a WordPress install can move into a different directory relative to root. There are issues with doing it either way, absolute URLs just give you a more concrete starting point … Read more

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