Undefined variable error in new function

I believe that’s telling you that $post (in $post->ID) is undefined. Try this instead: function sh_reading_time() { $content = get_post_field( ‘post_content’, get_the_ID() ); $word_count = str_word_count( strip_tags( $content ) ); $readingtime = ceil($word_count / 200); if ($readingtime == 1) { $timer = ” minute”; } else { $timer = ” minutes”; } $totalreadingtime = $readingtime … Read more

Can’t switch to a child theme using filters template, option_template and option_stylesheet

For a parent theme, template and stylesheet should be the same, which is the name of the parent theme directory. But for a child theme, template should be the parent theme’s directory name, whereas stylesheet is the child theme’s directory name. So if you’ve got the following: Parent theme: Twenty Nineteen (directory name: twentynineteen) Child … Read more

Why get_user_by() doesn’t work in my code?

I tweaked your code to make sure the $email was defined before attempting to process. I stop where the problem may be. If you follow all the if and else code, the “continue”resident when an email address is NOT a part of a particular group (subscriber, admin, customer etc) will skip the processing and move … Read more

Combine embed_oembed_html and oembed_result

This works, just don’t know if it’s the proper way to do it: Yes, the functions are the same so they’re equivalent. There is nothing wrong here. But if we dig a bit deeper, we see they’re not 2 filters for the same thing at all: embed_oembed_html filters the cached oEmbed HTML. oembed_result filters the … Read more

replace text in Sort Box

There is a filter for sort options that you can use, but it looks like there is already a Sort By: Popularity option there. You can see the filter here. You may want to check to see if other plugins or your theme are defining where the Sort By text is coming from. WooCommerce also … Read more