$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>categories - Create custom Perma link|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

categories - Create custom Perma link

matteradmin10PV0评论

I have a page with with address localhost/ . .In the navigation bar I have a new page link named Blog. SO wheni travel to that page the link is localhost/blog . Now here is my thing ...when i click on any post of that page the next page permalink become localhost/{The-post-name}. what i want is to print the link fully... like /localhost/blog/{the-post-name}. for every post i walk through this page

I have a page with with address localhost/ . .In the navigation bar I have a new page link named Blog. SO wheni travel to that page the link is localhost/blog . Now here is my thing ...when i click on any post of that page the next page permalink become localhost/{The-post-name}. what i want is to print the link fully... like /localhost/blog/{the-post-name}. for every post i walk through this page

Share Improve this question asked Feb 15, 2019 at 10:32 RITIKRITIK 1011 bronze badge
Add a comment  | 

2 Answers 2

Reset to default 0

Just go to Settings > Permalinks, select Custom Structure and enter the following:

/blog/%postname%/

That will add /blog/ to the beginning of post names in their permalinks. This will not affect Pages.

You can add a rewrite rule to WordPress:

add_action( 'init', 'wpse_328813_rewrite' );
function wpse_328813_rewrite()
{
    add_rewrite_rule(
        '^blog/(.+)/?$', 
        'index.php?pagename=$matches[1]',
        'top'
    );
}

What that is saying is, "WordPress, when someone requests a URL with "blog", followed by a slash, and then some text, maybe followed by another slash, try to load a page matching that slug. Oh, and do this before you try any of your other rewrite rules."

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far