Show only specific categories in page permalinks
P粉329425839
P粉329425839 2023-09-16 13:15:48
0
2
666

I tried asking this question in the Wordpress Devlopment network without success, I tried showing only specific categories in the permalinks of the page.

Now permalink structure for all pages and posts (POST type)

example.com/the-post-title/

This works for all my post and page categories, I want all categories to look like this But I want this category "Downloads"

when I select it to display on these pages

example.com/downloads/the-post-title/

Can anyone help me with how to use php code or something else for this specific category.

I tried some plugins and searched on the web but didn't find anything relevant

P粉329425839
P粉329425839

reply all (2)
P粉127901279

You can usehttps://www.tiny.cloud/docs/plugins /opensource/link/This plugin is used to customize your links.

    P粉451614834

    You will need to define custom rewrite rules to capture requests for/downloads/and direct them correctly. To do this, useadd_rewite_rule()to match existing rewrite rules for posts and pages.

    Then usepost_linkfilterto change the URL of the post to include/downloads/.

    pseudocode:

    add_action( 'init', static function () { add_rewrite_rule( ... ); } ); add_filter( 'post_link', static function ( $permalink, $post ) { // add test for post is in category return sprintf( '/downloads/%s', $post->post_name ); }, 10, 2 );
      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!