Is there a built-in function to generate multiple paragraph tags based on a string with new line separators?
Have you tried apply_filters(‘the_content’, $section_string)? That should apply wp_autop which would add either <p> tags or <br>s.
Have you tried apply_filters(‘the_content’, $section_string)? That should apply wp_autop which would add either <p> tags or <br>s.
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
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.
Change if($meta = “yes”) to if($meta == ‘yes’). Your way is setting the variable to yes, so it’s always yes; the double equals symbol means to test for a condition rather than set it.
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
You can use wp_pluck_list like so: wp_pluck_list($recipe_categories, ‘name’); Which should return: array( ‘Bread’, ‘Breakfast’, ‘Cocktails’ )
I figured out how to do it. This code shows the number of posts on a page after clicking on a category in WordPress. Even if the post has lots of categories. <?php $category = get_queried_object(); echo $category->count; ?> I used this code as the code was in the category.php file and not part of … Read more
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
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
get_option() always returns a string. That has nothing to do with whether setlocale() has been used. Options are all stored in the option_value column of wp_options, which is a text column. Your float is likely being formatted for your locale when it tries to insert a float into the text column. Your problem is that … Read more