Silahkan Melihat Tutorial di website kami dengan nyaman ENJOY YOUR LIFE ☕

Custom Url ReWrite in Wordpress

here Example How To generate custom url rewrite in wordpress

Check it

function create_custom_rewrite_rules() {
global $wp_rewrite;

$rewrite_tag = '%patentID%';
$wp_rewrite->add_rewrite_tag( $rewrite_tag, '(.+?)', 'patentID=' );
$rewrite_keywords_structure = $wp_rewrite->root . "%pagename%/$rewrite_tag/";
$new_rule = $wp_rewrite->generate_rewrite_rules( $rewrite_keywords_structure );

$wp_rewrite->rules = $new_rule + $wp_rewrite->rules;

return $wp_rewrite->rules;
}

function add_custom_page_variables( $public_query_vars ) {
$public_query_vars[] = 'patentID';

return $public_query_vars;

}

function flush_rewrite_rules132() {

global $wp_rewrite;

$wp_rewrite->flush_rules();

}

add_action( 'init', 'flush_rewrite_rules132' );
add_action( 'generate_rewrite_rules', 'create_custom_rewrite_rules' );
add_filter( 'query_vars', 'add_custom_page_variables' );


You can get this using

$patentID = get_query_var('patentID');  in you template




0 komentar:

Post a Comment

Custom Url ReWrite in Wordpress