所有permalink输出都有可用于修改的过滤器:post_link
, post_type_link
, page_link
, tag_link
, category_link
, term_link
.
一个简单的示例page_link
:
function wpd_append_query_string( $url, $id ) {
// check some condition and add a query string var
if( some_condition ) {
$url = add_query_arg( \'var\', 1, $url );
}
return $url;
}
add_filter( \'page_link\', \'wpd_append_query_string\', 10, 2 );