Show Custom Taxonomy Title

You can use single_term_title(): <h3><?php single_term_title(); ?></h3> To hide it if there are no posts, use the if ( have_posts() ) : function: <?php if ( have_posts() ) : ?> <h3><?php single_term_title(); ?></h3> <?php endif; ?> If not an archive, you can use get_term_by() to get the term object for the term and then echo … Read more

get_page_by_title with an apostrophe in variable

Title Hello world!@#$%^*(),.;:\ will work but any title you enter containing ‘ ” < > & characters won’t work because in $content variable you have escaped HTML entities so Mal’s Post becomes Mal&#8217;s Post. To bypass it you can use sanitize_title function along with get_page_by_path. function shortcode_equipment($atts, $content = null) { $path = sanitize_title($content); $equipment … Read more

how to trace notice warning on core function is_page() & is_singular in class-wp-query.php

You can create your own custom error handler and add stack trace to your error log. set_error_handler(‘wpse_288408_handle_error’); function wpse_288408_handle_error( $errno, $errstr, $errfile, $errline ) { if( $errno === E_USER_NOTICE ) { $message=”You have an error notice: “%s” in file “%s” at line: “%s”.” ; $message = sprintf($message, $errstr, $errfile, $errline); error_log($message); error_log(wpse_288408_generate_stack_trace()); } } // … Read more

How to check If Oembed is empty or not

The wp_oembed_get() only works for supported oEmbed providers. The return value is also is a URL of false, as mentioned per codex: If $url is a valid url to a supported provider, the function returns the embed code provided to it from the oEmbed protocol. Otherwise, it will return false. Therefore, is the input is … Read more

Adding ads code between comments

The end-callback of wp_list_comments() One way is to use the end-callback argument in: wp_list_comments( [ ‘end-callback’ => ‘wpse_comments_ads_injection’, … other arguments … ], $comments ); in addtion to your other wp_list_comments arguments, by defining: function wpse_comments_ads_injection( $comment, $args, $depth ) { static $instance = 0; $tag = ( ‘div’ == $args[‘style’] ) ? ‘div’ : … Read more

get_users(…) only returns one user

The include key on get_users requires an array of IDs (numbers). You are giving it an array of objects that have an ID property. If you look at your first var dump you will see this. WP is casting that to a number and returning the user with that number which is not what you … Read more

Display user role Name – not slug

WordPress does not (currently) have a global function (e.g. get_role_name()) for getting the role name (e.g. Shop Manager for shop-manager or maybe shop_manager etc.), but you can easily get (and then display) it like so: $role=”shop-manager”; // the role slug; it’s up to you how to get the value.. $role_name = $role ? wp_roles()->get_names()[ $role … Read more