Convert a string into a decimal number for use in query

For decimal values, use DECIMAL as it says in the official WP_Query documentation: ‘meta_value‘ – Note that a ‘meta_key=keyname‘ must also be present in the query. Note also that the sorting will be alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, … Read more

Pass Variables or Variable Place-Holder from Editor to PHP

You should use str_replace, which accepts arrays as arguments: $content = “Email: {{email}}\nFirst Name: {{first_name}}”; $body = str_replace( [‘{{email}}’, ‘{{first_name}}’], [‘[email protected]’, ‘Mickey Mouse’], $content ); Be careful about using $ in your placeholders. Since it’s widely used in PHP, it’s not safe. It was the reason I’ve used mustache-like syntax in my example.

Seo Friendly Filter URLs

Yes, it is possible. Option 1: Programmatically using add_rewrite_rule() Add the rewrite rule: /* The rule matches: * example.com/product-category/rings/rings-in-gold/ * example.com/product-category/rings/rings-in-gold/page/<number>/ */ add_action( ‘init’, function () { add_rewrite_rule( ‘^product-category/rings/rings-in-gold(?:/page/(\d+)|)/?$’, // $matches[1] is the (\d+) (page number) from the above Regex, if any. ‘index.php?product_cat=rings&filter_material=gold&paged=$matches[1]’, ‘top’ ); } ); For other categories, just copy the above add_rewrite_rule() … Read more

Noindex Posts From Certain Authors In WordPress

From codex: is_author() is a conditional tag which determines whether the query is for an existing author archive page. so it does not work for your scope. Best solution, instead of using the template file header.php is to write a function in functions.php hooking the proper action wp_head: add_action(‘wp_head’,’AS_exclude_author_from_indexing’); function AS_exclude_author_from_indexing(){ $toIndex = array(111,112,113); $user_id … Read more

WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank

If you haven’t done so already, I would recommend you to turn on debug logging in wp-config.php as it makes it easier to trace the error in your code. // added to wp-config.php define( ‘WP_DEBUG’, true ); define( ‘WP_DEBUG_LOG’, true ); // find error.log in /wp-content, shows backtrace for errors define( ‘WP_DEBUG_DISPLAY’, false ); // … Read more