kadence cloud redirect traffic

Kadence offers a Cloud Library feature that allows a webmaster to reuse custom blocks or entire layouts that can be loaded in website projects, or give/sell access to the library to other users, who only have to provide a URL and API key. It’s pretty cool, check it out here.

Part of the Kadence Cloud setup is to have a publicly available website so that the API connection can reach the library. The only drawback here is that the cloud items are also publicly available from a URL ending in /cloud/cloud-item-slug. This could cause problems with unwanted pages getting indexed by search engines and potentially allowing visitors to see content intended for private or commercial use.

While it makes sense to block visitors from seeing these items, there are situations where viewing the items after publishing is a good idea, such as troubleshooting.

The Code Snippet

The following code checks (1) if the page is a Kadence Cloud post type and (2) that the user is not logged in. If the user is logged in, they are able to view the cloud library item directly. If not, they will be automatically redirected to the home page.

add_action( 'template_redirect', 'redirect_if_user_not_logged_in' );

function redirect_if_user_not_logged_in() {

    //check if the current page is a cloud item and if the user is logged in
    if ( is_singular( 'kadence_cloud' ) && ! is_user_logged_in() ) {
        // if both are true, then redirect to home page
        wp_redirect( home_url() );
    // exit redirect

This code can be loaded using the Code Snippets plugin or in your theme’s functions.php (or a child theme, ideally). You could also edit the redirect rule to send traffic to another URL if you are so inclined.

If you are using an SEO plugin that generates a sitemap automatically, it’s a good idea to see if you can omit these pages by excluding the post type. They won’t be indexed anyway with this redirect in place, but it would probably be best not to point search engines toward them in the first place and tie up your crawl budget.

Questions or comments? Let us know below.

Leave a Reply

Your email address will not be published. Required fields are marked *