Duplicate Slugs on multilingual site (with Polylang)

Go on your back-office, and go on Polylang (Languages) Settings. Then, on URL modifications, check if the option “The language is set from the directory name in pretty permalinks” is checked. If not, check it. Then click on Save changes. Now, you should see this option below : “Share slugs Activated” “Allows to share the … Read more

WordPress Page Slug with URL custom template

Eventually I found out a solution. Below is how I have achieved this. In my functions.php file, I have put below code. add_filter(‘query_vars’, ‘add_user_var’, 0, 1); function add_user_var($vars){ $vars[] = ‘user’; return $vars; } add_rewrite_rule(‘^user/([^/]+)/?$’,’index.php?pagename=user&user=$matches[1]’,’top’); This generally adds a rewrite rule if it finds user in the URL. Now I have added a page template … Read more

Create a custom plugin with dynamic child pages listing database records

A basic implementation could go like this: Setup public query variables This lets you fetch these later through get_query_var() add_filter( ‘query_vars’, function( $vars ) { $vars[] = ‘team_category’; $vars[] = ‘team_id’; return $vars; } ); Add a rewrite rule This is responsible for turning a url like /team/allstars/999 into a format WordPress can handle. Make … Read more

Custom slugs with dates & IDs on Custom Post Type

Yes, it’s not hard to do that. Just register your post type and enable rewriting for that post type, i.e. set rewrite to true. Once registered, modify its permalink structure like so: global $wp_rewrite; $wp_rewrite->extra_permastructs[‘<post type>’][‘struct’] = ‘<your structure here>’; Use the post_type_link filter to replace rewrite tags like %post_id% in the permalink URL. If … Read more