ButlerBlog

chad butler's weblog

  • About
  • Blog
  • WordPress Plugins
  • Contact
Home / Web / WordPress / WP-Members / Blocking content in a custom template

Blocking content in a custom template

By Chad Butler 2 Comments

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

Enjoyed this article?

Don't miss a single post. Subscribe to our RSS feed!

  • Facebook
  • Twitter
  • Email
  • Print
  • More
  • LinkedIn
  • Reddit
  • Tumblr
  • Pocket
  • Pinterest
Pages: 1 2

Filed Under: WP-Members Tagged With: development, plugins, tips, WP-Members

About Chad Butler

Chad Butler is a freelance writer and web developer. He has developed several popular WordPress plugins and has written for forbes.com, sfomag.com, and investopedia.com. He also runs a small organic farm in east Georgia.

Join Us!

I will never share your information. No spam. No junk. No kidding. Unsubscribe anytime.


Recent Posts:

  • The Right Product at the Right Time
  • Top 3 Time Wasters
    Keeping You From Success
  • Top 8 Tips to Create Your Own Website Easily With WordPress
  • How to Fix wp_mail
    Settings for WordPress Email
  • 7 Reasons Why Social Networking Can Help Your Business
  • Understanding WordPress wp_mail and
    how to fix it
  • Prevent WordPress email sent
    to spam with this
  • Easy wp mail SMTP settings for WordPress
  • The Importance of Supporting Developers
    of Free Open Source Software
  • How to Run an Effective Meeting





Archives

  • About
  • Blog
  • Archive
  • Contact

Site powered by WordPress, running on the Genesis Framework from StudioPress.

Unless otherwise noted, content on this site is © 2006-2021 ButlerBlog and may not be reproduced without express written permission from the author.

Some content may include affiliate links for which this site receives a small commission.

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.