Rewriting permalinks with custom posts
Oh dear, turns out I need to touch up on my regex, the second match only matches one character. It ought to be: ‘([\w]{2})/the-wines/([^/]+)/?’ => ‘index.php?pagename=$matches[2]&lang=$matches[1]’
Oh dear, turns out I need to touch up on my regex, the second match only matches one character. It ought to be: ‘([\w]{2})/the-wines/([^/]+)/?’ => ‘index.php?pagename=$matches[2]&lang=$matches[1]’
After struggling for a while in the web.config structure. I found out we need to clear the rule before to add another rule. Just add tag </clear> <?xml version=”1.0″ encoding=”UTF-8″?> <configuration> <system.webServer> <rewrite> <rules> <clear/> <rule name=”wordpress” patternSyntax=”Wildcard”> <match url=”*”/> <conditions> <add input=”{REQUEST_FILENAME}” matchType=”IsFile” negate=”true”/> <add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” negate=”true”/> </conditions> <action type=”Rewrite” url=”index.php”/> </rule> </rules> … Read more
In Admin Panel go to Settings -> Permalinks -> at the lower left click on save changes to refresh all permalinks including your custom post type.
… and as per usual, I figure it out as soon as I post the question -.- Using this answer, I changed apache2.conf under /etc/apache2/. There is a section towards the bottom talking about the security model. The section Directory /var/www/ needs to be changed from AllowOverride None to AllowOverride All. I restarted apache and … Read more
In your Settings > Permalink page, you would select the “Custom Permalink” radio button, and simply add: /%postname%/ . This will make it so that when you click on the “reviews” tag, that it should only show “http://www.example.com/reviews” when you are on the Archive page for reviews. HOWEVER, this may have adverse repercussions on the … Read more
I think I found it myself. Now I’ve successfully managed to add a /photos endpoint to a permalink URL, such as: http://mywordpressite.com/projects/a-project/photos And then a custom template, photos.php will load and show – with access to the global $post variable. Helpful links: http://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint http://codex.wordpress.org/Template_Hierarchy In my functions.php I added functions for the single_template and query_vars … Read more
In my case I was trying to get the permalink before I had set up the post types. I double checked the Action Reference: https://codex.wordpress.org/Plugin_API/Action_Reference And updated the hooks I was using to trigger my theme setup. Once done, the get_permalink worked as expected.
The first step is to add a query var so WordPress will recognize it and parse its value in rewrite rules. function wpd_query_vars( $query_vars ) { $query_vars[] = ‘users_filter_name’; return $query_vars; } add_filter( ‘query_vars’, ‘wpd_query_vars’ ); Next, add a rewrite rule to capture the requests and set the users_filter_name: function wpd_user_rewrite_rule(){ add_rewrite_rule( ‘^user-profile/([^/]*)/?’, ‘index.php?page_id=31848&users_filter_name=$matches[1]’, ‘top’ … Read more
No need to change core files: add_action( ‘init’, ‘wpse316713_pagination_base_rewrite_rule’ ); function wpse316713_pagination_base_rewrite_rule() { global $wp_rewrite; $wp_rewrite->pagination_base=”image”; } Go to permalink options page, and press save to flush the rewrite rules, changes should apply afterwards.
Have you somehow hidden/removed the slug metabox? (is something like this located in your functions.php?) function remove_post_meta_box() { remove_meta_box(‘slugdiv’, ‘post’, ‘normal’); } add_action(‘admin_menu’, ‘remove_post_meta_box’); If that’s the case, it’s causing the error. There is a Trac ticket for this already, but the only way to currently solve it is to remove it.