WordPress.org

Ready to get started?Download WordPress

Forums

Page permalinks - .html ending? (7 posts)

  1. pad
    Member
    Posted 6 years ago #

    I know for posts you can have a fake .html ending in your permalinks, is this at all possible for pages too?

    Thanks in advance

  2. pad
    Member
    Posted 6 years ago #

    Anyone?

  3. Alex Concha
    Member
    Posted 6 years ago #

    Yes, it is posible.

    You can do it changing page_structure in WP_Rewrite::get_page_permastruct (wp-includes/rewrite.php) or hack it with a plugin:

    add_action('init', 'change_page_permalink', -1);
    function change_page_permalink() {
    	global $wp_rewrite;
    	if ( strstr($wp_rewrite->get_page_permastruct(), '.html') != '.html' )
    		$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.html';
    }
  4. Robberto
    Member
    Posted 6 years ago #

    How exactly do I change that?
    I tried several times, but each time resulting in some error.
    What part of the rewrite.php to I change/delete/overwrite?

    In my rewrite.php I see this:

    function page_rewrite_rules() {
    $uris = get_option('page_uris');
    $attachment_uris = get_option('page_attachment_uris');

    $rewrite_rules = array();
    $page_structure = $this->get_page_permastruct();
    if( is_array( $attachment_uris ) ) {
    foreach ($attachment_uris as $uri => $pagename) {
    $this->add_rewrite_tag('%pagename%', "($uri)", 'attachment=');
    $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure,

    EP_PAGES));
    }
    }
    if( is_array( $uris ) ) {
    foreach ($uris as $uri => $pagename) {
    $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
    $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES));
    }
    }

    return $rewrite_rules;
    }

  5. Robberto
    Member
    Posted 6 years ago #

    When I go to Options > Permalinks and create custom structure: %postname%.html --- why doesn't that work?

    Why do none of my posts of pages end with .html?

    What am I missing?

  6. pad
    Member
    Posted 6 years ago #

    This doesn't appear to work anymore!

  7. menod
    Member
    Posted 5 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic