• Hello!

    I’m trying to understand the function add_rewrite_rule()
    Now a link to the first post looks as: https://localhost/?p=1
    In the setting of WordPress permalinks by default “https://localhost/?p=123”

    Create a new rule for the first post in functions.php

    Code:

    function NewRuleForFirstPost ()
    {
        add_rewrite_rule('first_post/?$', 'index.php/?p=1', 'top');
        flush_rewrite_rules();
    }
    add_action('init', 'NewRuleForFirstPost');

    But this method does not work – in the address line shows the /?p=1 ??
    help me, pls!

    P.S. sorry for bad english!

  • The topic ‘Work with the function add_rewrite_rule()’ is closed to new replies.