Answer the question
In order to leave comments, you need to log in
How to add .html to the end of a link?
There is a site URL
1st https://my_site.com/
remains as it is.
2nd level: https://my_site.com/my_second_page.html
3rd level and above:
https://my_site.com/my_second_page/my_third_page.html
if ( !strpos($wp_rewrite->get_page_permastruct(), '.html')){
$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.html';
}
// некоторые ссылки тогда битые
// для продукта
function wpse_178112_permastruct_html( $post_type, $args ) {
if ( $post_type === 'product' )
add_permastruct( $post_type, "{$args->rewrite['slug']}/%$post_type%.html", $args->rewrite );
}
add_action( 'registered_post_type', 'wpse_178112_permastruct_html', 10, 2 );
// для категории, когда идем на страницу категории там ОШИБКА 404
function wpse_178112_category_permastruct_html( $taxonomy, $object_type, $args ) {
if ( $taxonomy === 'product_cat' )
add_permastruct( $taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%.html", $args['rewrite'] );
}
add_action( 'registered_taxonomy', 'wpse_178112_category_permastruct_html', 10, 3 );
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question