Rewrite Rule for Custom Page with Query Vars in URL

I manually deleted the .htaccess file and regenerated, which along with the code below, made the rewrite work. The second rewrite rule in the code below makes the pagination work properly. The .htaccess file doesn’t seem to be getting written with any rules though, but the rewrite is working now anyhow. function listen_rewrite_action() { add_rewrite_tag(‘%show%’,'([^/]*)’); … Read more

Custom Rewrite with Query vars

Add a rewrite endpoint instead of a rewrite rule and query var. This API function will do both of these things for you. function wpd_add_my_endpoint(){ add_rewrite_endpoint( ‘information’, EP_PAGES ); } add_action( ‘init’, ‘wpd_add_my_endpoint’ ); Now any page can have information appended to the end, and the value will be available via get_query_var(‘information’).

Enqueue Script with URL parameters

WordPress can automatically add the query variables for you. Instead of directly writing the query arguments, you can use it this way: $args = array( ‘f’ => ‘j’, ‘s’ => ‘w’, ‘c’ => ‘t’ ); wp_enqueue_script( ‘param-example’, add_query_arg( $args, ‘https://domain.com/example’) ); This is your solution, since according to code reference, the return value is unescaped … Read more

Passing Variable as URL Parameter — Security concerns?

Passing non-private/non-protected/non-sensitive values through the URL is quite widely used and a more reliable way of passing values from one page to another. The reason for this is, $_SERVER[‘HTTP_REFERER’] is totally unreliable and can never be trusted. It can also, in many case be an empty value. Check the two following posts for more details … Read more