Issue with custom loop in Archive page

The problem is you aren’t saving your custom query’s results. To do it your way, you would need to save the query’s results to a variable, like so: $myposts = query_posts( $archive_args ); if ( $myposts->have_posts() ) : while ($myposts->have_posts()) : $myposts->the_post(); However, that’s not the most efficient way. WP runs the default query in … Read more

I receive taxonomy id

there is a mistake in fetching the product attribute name. first of all, we have to get all options ids & attribute names than we have to fetch attribute name by its id & attribute slug. please check below updated code snippet and let me know if this is worked for you or not.if not … Read more

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