How to create custom search result page with custom URL parameters for custom post type?

Add this code in functions.php function custom_rewrite_rule() { //Initializing Rewrite Tags add_rewrite_tag(‘%begin-date%’, ‘([^&]+)’); add_rewrite_tag(‘%end-date%’, ‘([^&]+)’); add_rewrite_tag(‘%offset%’, ‘([^&]+)’); //Find page rewrite rules add_rewrite_rule(‘^find/([^/]*)/([^/]*)/([^/]*)/?’,’index.php?page_id=<SEARCH_PAGE_ID>&begin-date=$matches[1]&end-date=$matches[2]&offset=$matches[3]’,’top’); add_rewrite_rule(‘^find/([^/]*)/([^/]*)/?’,’index.php?page_id=<SEARCH_PAGE_ID>&begin-date=$matches[1]&end-date=$matches[2]’,’top’); flush_rewrite_rules(); } add_action(‘init’, ‘custom_rewrite_rule’, 10, 0); On your custom search page template $begin_date = get_query_var(‘begin-date’); $end_date = get_query_var(‘end-date’); $offset = get_query_var(‘offset’) ? get_query_var(‘offset’) : 1; Create a page having slug find and … Read more

Custom HTML title based on URL parameter

Another approach that may be a bit more opaque to your users is to look at the referrer_url. This is a server-level variable that, while not 100% reliable, is generally a good indicator of where someone was when they clicked your link. It would not work if someone copied the link and sent it to … Read more

Handle multiple parameters in filter

The problem is that you use apply_filters incorrectly. This function takes at least two parameters: $tag (string) (Required) The name of the filter hook $value (mixed) (Required) The value on which the filters hooked to $tag are applied on. So the first param should be the name of the hook and as second param you … Read more

Add a class with body_class to a specific url with parameter

You’re overcomplicating it a bit. ?um_action=edit is a query string, and its values are available in the $_GET superglobal. To check if it exists, and has a specific value, you just need to do this: function leweb_add_body_class_um_edit_profile( $classes ) { if ( isset( $_GET[‘um_action’] ) && ‘edit’ === $_GET[‘um_action’] ) { $classes[] = ‘leweb-um-profile-edit’; } … Read more

Where is this function’s callback getting its arguments from?

If you have a look at function do_meta_boxes() in wp-admin/includes/template.php then you’ll see this line close to the end of the function: call_user_func($box[‘callback’], $object, $box); That calls the callback function and provides the two arguments. The $box argument holds all the information about the metabox, like ID, title, callback function. In wp-admin/edit-form-advanced.php, which displays your … Read more

How to parse a custom url (within WP site) and obtain params passed to that URL

First, you register your query vars param1 and param2: function wpse_101951_query_vars( $qv ) { $qv[] = ‘param1’; $qv[] = ‘param2’; return $qv; } add_filter( ‘query_vars’, ‘wpse_101951_query_vars’ ); To use this information, you can pretty much hook into any action or filter after parse_query. That’s the first action available after the query vars are set, so … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)