The is_comments_popup WordPress PHP function determines whether the current URL is within the comments popup window.
Usage
if (is_comments_popup()) {
// Your custom code here
}
Parameters
- None
More information
See WordPress Developer Resources: is_comments_popup
Examples
Show a message in the comments popup window
Display a custom message when the current URL is within the comments popup window.
if (is_comments_popup()) {
echo '**Welcome to the comments popup!**';
}
Load a custom stylesheet for the comments popup window
Enqueue a custom CSS file only when the current URL is within the comments popup window.
function load_popup_stylesheet() {
if (is_comments_popup()) {
wp_enqueue_style('comments-popup', get_template_directory_uri() . '/css/comments-popup.css');
}
}
add_action('wp_enqueue_scripts', 'load_popup_stylesheet');
Disable the admin bar in the comments popup window
Remove the admin bar when the current URL is within the comments popup window.
function remove_admin_bar() {
if (is_comments_popup()) {
show_admin_bar(false);
}
}
add_action('init', 'remove_admin_bar');
Display a custom navigation menu in the comments popup window
Render a specific navigation menu when the current URL is within the comments popup window.
if (is_comments_popup()) {
wp_nav_menu(array('theme_location' => 'comments_popup_menu'));
} else {
wp_nav_menu(array('theme_location' => 'main_menu'));
}
Add a custom class to the body tag in the comments popup window
Add a specific class to the body tag when the current URL is within the comments popup window.
function add_popup_body_class($classes) {
if (is_comments_popup()) {
$classes[] = 'comments-popup';
}
return $classes;
}
add_filter('body_class', 'add_popup_body_class');