WordPress.org

Ready to get started?Download WordPress

Forums

Custom rewrite to page but no url substitution (4 posts)

  1. JayChandler
    Member
    Posted 3 years ago #

    Hi

    I've got a strange problem. I have a page with follwing permalink
    /my-first-page ( id = 20 )

    Now i want to have another url /foo pointng to /my-first-page

    So i did some research on that and found following solution

    add_filter('rewrite_rules_array','wp_insertMyRewriteRules');
    add_action('init','flushRules');
    
    function flushRules(){
        global $wp_rewrite;
        $wp_rewrite->flush_rules();
    }
    
    function wp_insertMyRewriteRules($rules)
    {
        $newrules = array();
        $newrules['^foo$'] = 'index.php?p=20';
        return $newrules + $rules;
    }

    Thats just working but wp redirects to the url /my-first-page.
    I dont want wp to change my url rather i want to tell wp take this page id and show it under my custom url /foo

  2. David Gard
    Member
    Posted 3 years ago #

    So you are not in effect rewriting, you want to display the content from one page on anothe. You can do this with domains and it is know as Parking, but not sure if it is possible with single pages.

  3. JayChandler
    Member
    Posted 3 years ago #

    Yes i want to show content from /my-first-page under /foo. Isn't there any way to tell wp to do this. Can't be that problem ?

  4. Taylor Baybutt
    Member
    Posted 3 years ago #

    I want to do the same thing. In Buddypress I have a group that does not belong with the other groups. I want to give it its own url outside of the standard group permalink structure.

    Did you ever solve your problem?
    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.