Customize WordPress Flip Link Prefix

WordPress seven eight hundred and fourteen Reading mode

The default page number prefix of WordPress page turning link is/page/2/, which can be customized through the following code, such as/mylink/2/. Add code to the current topic function template functions.php:

Code 1
 function zm_rewrite_rules() { global $wp_rewrite; $wp_rewrite->author_base     = 'autors';//  Author Archive Flip Prefix $wp_rewrite->search_base     = 'search';//  Search Flip Prefix $wp_rewrite->pagination_base = 'mylink';//  Page number prefix $wp_rewrite->flush_rules(); } add_action( 'init', 'zm_rewrite_rules' );

Modify the names of autors, search, and mylink respectively.

If it does not take effect, the open link is displayed as 404, and you can save the fixed link settings in the WP background.

The above code may affect operation efficiency.

Code 2
 function zm_base() { $GLOBALS['wp_rewrite']->pagination_base = 'mylink'; } add_action( 'init', 'zm_base' ); function zm_rewrite( $rules ) { $new_rules = array( 'obchod/mylink/([0-9]{1,})/?$' => ' index.php? post_type=product&paged=$matches[1]', ); $rules = array_merge( $new_rules, $rules ); return $rules; } add_filter( 'rewrite_rules_array', 'zm_rewrite' );

Modify the mylink name.

After adding code, you need to save the fixed link settings in the WP background, or they will not take effect.

summary

Conclusion: It is recommended to use Code 2 to run more efficiently.

As for why to customize the link, in addition to personalization, it can increase the difficulty of malicious collection.

 Customize WordPress Flip Link Prefix

Most of the articles on this site are original and used for personal learning records, which may be helpful to you, for reference only!

 weinxin
My Wechat
Copyright Notice
Please indicate the source and link of the original article reprinted on this site. Thank you for your cooperation!
five hundred and ninety-eight million eight hundred and forty-five thousand and six
 
 Robin
five hundred and ninety-eight million eight hundred and forty-five thousand and six
Comments seven    Visitors five    Author two
    •  Big Bear
      Big Bear zero

      There is a service/0/that does not jump to 404. The display is the home page, and the number of 0 changes to six. How can I troubleshoot this fault? :oops:

        •  Robin
          Robin

          @ Big Bear This must have nothing to do with the code

            •  simple life
              simple life four

              @ Robin Ah Xi, I can't find the problem, so I just use the rewrite rule to mask it

          •  Novice on the road
            Novice on the road zero

            It's useless for malicious collection, unless your website is randomly generated, which is not conducive to your website optimization

              •  Robin
                Robin

                @ Novice on the road It's definitely useless, just to increase the difficulty

                •  Qianqian Classic
                  Qianqian Classic two

                  @ Novice on the road Rather than prevent others from collecting you, it is better to improve the quality and loading speed of content websites. And you can't help it. As you know from the data collection, it has all kinds of functions. Because when you defend, the code is doomed to be complex, and it takes time to load, and then your SEO will go on, the gain is not worth the loss. But there is no egg. In addition, the collection is handed over to the firewall instead of the theme.

                •  ll
                  ll one

                  Share, like, poster This has plug-ins, which file is the code in the theme

                 anonymous

                Comment

                Anonymous netizens
                 :?:  :razz:  :sad:  :evil:  :!:  :smile:  :oops:  :grin:  :eek:  :shock:  :???:  :cool:  :lol:  :mad:  :twisted:  :roll:  :wink:  :idea:  :arrow:  :neutral:  :cry:  :mrgreen:

                Drag the slider to complete validation