Do I need to use wp_reset_postdata for my function?

Yes you should, otherwise you could interfere with another query happening on the same page. Using $the_query->the_post(); interferes with the global $post variable, and wp_reset_postdata() serves that exact purpose, to reset the global $post variable to the original (global) query. Read more

Remove Custom Divs from AMP pages

Thanks to Thomas’ answer to my question at StackOverflow – https://stackoverflow.com/questions/53158606/remove-div-with-a-class-without-removing-content Here’s how you can do it on WordPress for AMP. In your theme’s functions.php add the following:- add_action( ‘pre_amp_render_post’, ‘amp_vid_rmv’ ); function amp_vid_rmv() { add_filter( ‘the_content’, ‘amp_vid_div_rmv’ ); } function amp_vid_div_rmv($content) { $content = preg_replace(‘#<div class=”yt”>([\s\S]*?)</div>#’, ‘$1’, $content); return $content; } Please feel free … Read more

Add_filter when value is no variable?

I can’t really make sense of what you’re trying to do. This code: apply_filters( ‘cc_get_content_preview’, get_the_excerpt(), 55 ); Will let developers hook into the cc_get_content_preview hook to change the value that the cc_get_content_preview() function returns. When developers hook into an action or filter, they do so using a callback function. This function will receive any … Read more

How to get correct value from checked()?

The purpose of checked() is to output a checked=”checked” attribute based on a current value. By using it the way you’re using it there you’re forcing Si to never be checked and No to always be checked. So what you want to do is use both arguments of checked() to compare the value of the … Read more

Return category name with & Ampersand doesnt work

Using titles in such comparisons is always a little bit risky – you have to deal with encodings and so on. Much safer way is using of slugs in code, because they are url-safe. So your code could look like this: function posend_text_shortcode() { $mycategory = get_the_category(); $slug = ”; if ( ! empty($mycategory) ) … Read more

How to check if a Customizer setting is set?

Adding an action will fire the function regardless, but you can add an if statement to see if the value has been set. This way the tag will not fire if the value is not set function chrome_theme_meta() { $chrome_theme = get_theme_mod( ‘chrome_theme’, ” ); if(!empty($chrome_theme){//test to see if a value is set echo ‘<meta … Read more