Blocking content in a custom template

Lately, this question has come up a lot.  How do you block content that is outside the loop and still display the login/registration forms on the page.

This type of issue may come up if you are using a custom query to put some specific content on a specific page, or it might be that you are displaying specific data that you want to protect.  As long as it is something in the WordPress template framework, you can still use WP-Members™ to block the content. 

There are some key WordPress concepts that I would suggest you be familiar with before I explain this.

First, understand the WordPress Loop and how to recognize it.  WP-Members™ specifically uses the Loop in blocking content.  The custom template method we are discussing here occurs when the Loop is not there, so you need to be able to recognize that fact.

Next, you should understand how page templates work.  Be able to recognize if the template you are using has the Loop or not.  If it does have an instance of the Loop, then this method of blocking content will likely not be necessary.  If, however, this template is using something custom outside or without the Loop, then this does apply.

Lastly, you need to know how to use the WordPress native function is_user_logged_in(). This function returns true if the user is logged in.  We will be using this as a conditional statement in the custom template to determine what to display to the user.

Next page: Putting it all together



Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>