WordPress Learning (iv)---URL pseudo-static simple understanding

Source: Internet
Author: User
Tags vars

Do a test on the page-url.php page

functions.php Join

Add_filter (' Rewrite_rules_array ', ' my_insert_rewrite_rules '); Add_filter (' Query_vars ', ' my_insert_query_vars '); Add_action (' wp_loaded ', ' my_flush_rules ');//When WP loads, run the My_flush_rules method//If there is no rule in the pseudo-static rule, reset function my_flush_ Rules () {$rules = get_option (' rewrite_rules ');  Gets the option data table ' Rewrite-rules ' if (!isset ($rules [' url-(. *). html '])) {global $wp _rewrite; $WP _rewrite->flush_rules ();}} Add a new pseudo-static rule function My_insert_rewrite_rules ($rules) {$newrules = array (); $newrules [' url-(. *). html '] = ' index.php? Pagename= $matches [0]&v= $matches [1] '; return $newrules + $rules;} Add a variable name function My_insert_query_vars ($vars) {Array_push ($vars, ' V '); return $vars;} echo $wp _query->query_vars[' V '];  Write to the place where you want to get the pass value

  

After saving, enter localhost/wordpress/url-123.html in the browser address bar;

Attached:Some parameters of wordpress fixed link settings

    1. %year%: Based on the year the article was published, such as 2010;
    2. %monthnum%: Based on the month of the article release, such as 01;
    3. %day%: Based on the date of the article release, such as 06;
    4. %hour%: Based on the article published hours, such as 23;
    5. %minute%: Based on the article release minutes, such as 43;
    6. %second%: Based on the post number of seconds, such as 33;
    7. %postname%: An article-based postname whose value is the abbreviated name specified at the time of writing, and the title of the article without specifying a thumbnail name;
    8. %post_id%: Based on article post_id, such as 48;
    9. %category%: Based on the classification of articles, sub-classifications are processed into the form of "classification/sub-classification";
    10. %author%: Based on the author name of the article.

WordPress Learning (iv)---URL pseudo-static simple understanding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.