422

How to Make Your Website Visible to Search Engines: A Guide to SEO Visibility

Powered by WPCodeBox

This snippet helps remind you to publish your site and ensure search engine visibility after going live, crucial for SEO.


<?php
/**
* Check if Website is visible to Search Engines
*/
function wpse_check_visibility() {
    if ( ! class_exists( 'WPSEO_Admin' ) ) {
        if ( '0' == get_option( 'blog_public' ) ) {
        add_action( 'admin_footer', 'wpse_private_wp_warning' );
        }
    }
}
add_action( 'admin_init', 'wpse_check_visibility' );

/**
* If website is Private, show alert
*/
function wpse_private_wp_warning() {
    if ( ( function_exists( 'is_network_admin' ) && is_network_admin() ) ) {
        return;
    }
    echo '<div id=""robotsmessage"" class=""error"">';
    echo '<p><strong>' . __( 'Huge SEO Issue: You're blocking access to robots.', 'wpse-seo' ) . '</strong> ' . sprintf( __( 'You must %sgo to your Reading Settings%s and uncheck the box for Search Engine Visibility.', 'wordpress-seo' ), '<a href=""' . esc_url( admin_url( 'options-reading.php' ) ) . '"">', '</a>' ) . '</p></div>';
}

Other Snippets

WPCodeBox is a WordPress Code Snippets Manager that allows you to share your WordPress Code Snippets across your sites.