is_active_sidebar() Always Returns False

The is_active_sidebar(‘Test’); function works correctly if the correct slug is used. I think that the problem is that you are constructing the sidebar ID like this: $sidebarID = preg_replace(“/[\s_]/”, “-“, strtolower($page->post_title)); Then prepending sidebar- to it … register_sidebar(array( ‘name’ => $page->post_title, ‘id’ => ‘sidebar-‘.$sidebarID, // But you are using the unmodified title as the slug … Read more

disable comments if array exists

Assuming you’re properly using comment_form() to output the comment reply form: if( ! array_key_exists( ‘comments’, $wp_query->query_vars ) ) { // Output the comment form comment_form(); } Edit Based on your comments.php code: // If the user isn’t logged in, don’t display comment form if ( is_user_logged_in() ) { global $wp_query; // If the post type … Read more

Exclude custom function content from certain pages

Check for the type of the page: function get_author_bio ($content=””){ if ( ! is_single() ) // not a blog post, stop immediately { return $content; } global $post; // continue with regular work The easiest way to learn these check functions is a look at the function get_body_class(). Here are the most important: is_rtl() is_front_page() … Read more

How can we use conditional tags in plugins?

TL,DR; You are hooking early. In the plugin, the css file loads site-wide by default, I want to load it only on the single post. It’s a very good thought many developers don’t take this into account while developing themes/plugins. is_single() isn’t working in plugins Where are you using is_single template tag in WP run … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)