Note that there are some explanatory texts on larger screens.

plurals
  1. POPassword protect category output in a WordPress blog page template
    primarykey
    data
    text
    <p>I am trying to edit a blog archive page template that will hide all output unless a password is entered. Currently when "Password protected" is selected, it only hides content entered into the page and not the category output as well.</p> <p>Apparently WordPress has a function reference called Post_Password_Required that should be wrapped around the category output in the template. This way if the blog template is called and is also password protected, WordPress will block all output until the password is entered.</p> <p><a href="http://codex.wordpress.org/Function_Reference/post_password_required" rel="nofollow">http://codex.wordpress.org/Function_Reference/post_password_required</a></p> <p>Now, after arbitrarily trying to figure out where to place this code in the page-blog.php and failing i'm wondering if anyone has a better idea of where to place it.</p> <p>I'm using an Elegant Themes template and their support is balls on the issue. Telling me I need to find a plugin to do this and coping out to contact a 3rd party developer to fix this. Here is the code for the blog template for reference. I appreciate any help.</p> <pre><code>&lt;?php /* Template Name: Investor */ ?&gt; &lt;?php if (is_front_page()) { ?&gt; &lt;?php get_template_part('home'); ?&gt; &lt;?php } else { ?&gt; &lt;?php $et_ptemplate_settings = array(); $et_ptemplate_settings = maybe_unserialize( get_post_meta($post-&gt;ID,'et_ptemplate_settings',true) ); $fullwidth = isset( $et_ptemplate_settings['et_fullwidthpage'] ) ? (bool) $et_ptemplate_settings['et_fullwidthpage'] : false; $et_ptemplate_blogstyle = isset( $et_ptemplate_settings['et_ptemplate_blogstyle'] ) ? (bool) $et_ptemplate_settings['et_ptemplate_blogstyle'] : false; $et_ptemplate_showthumb = isset( $et_ptemplate_settings['et_ptemplate_showthumb'] ) ? (bool) $et_ptemplate_settings['et_ptemplate_showthumb'] : false; $blog_cats = isset( $et_ptemplate_settings['et_ptemplate_blogcats'] ) ? (array) $et_ptemplate_settings['et_ptemplate_blogcats'] : array(); $et_ptemplate_blog_perpage = isset( $et_ptemplate_settings['et_ptemplate_blog_perpage'] ) ? (int) $et_ptemplate_settings['et_ptemplate_blog_perpage'] : 10; ?&gt; &lt;?php get_header(); ?&gt; &lt;div id="content-left"&gt; &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt; &lt;div class="entry post clearfix"&lt;?php if ($fullwidth) echo ' style="padding-right: 10px;"'; ?&gt;&gt; &lt;?php $width = 140; $height = 140; $classtext = 'thumbnail alignleft'; $titletext = get_the_title(); $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext); $thumb = $thumbnail["thumb"]; ?&gt; &lt;?php if($thumb &lt;&gt; '' &amp;&amp; get_option('myproduct_page_thumbnails') == 'on') { ?&gt; &lt;?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext , $width, $height, $classtext); ?&gt; &lt;?php }; ?&gt; &lt;?php the_content(); ?&gt; &lt;?php wp_link_pages(array('before' =&gt; '&lt;p&gt;&lt;strong&gt;Pages:&lt;/strong&gt; ', 'after' =&gt; '&lt;/p&gt;', 'next_or_number' =&gt; 'number')); ?&gt; &lt;div id="et_pt_blog"&gt; &lt;?php $cat_query = ''; if ( !empty($blog_cats) ) $cat_query = '&amp;cat=' . implode(",", $blog_cats); else echo '&lt;!-- blog category is not selected --&gt;'; ?&gt; &lt;?php $et_paged = is_front_page() ? get_query_var( 'page' ) : get_query_var( 'paged' ); ?&gt; &lt;?php query_posts("showposts=$et_ptemplate_blog_perpage&amp;paged=" . $et_paged . $cat_query); ?&gt; &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt; &lt;?php if ( post_password_required() ) ?&gt; &lt;div class="et_pt_blogentry clearfix"&gt; &lt;h2 class="et_pt_title"&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt; &lt;p class="et_pt_blogmeta"&gt;&lt;?php esc_html_e('Posted','MyProduct'); ?&gt; &lt;?php esc_html_e('on','MyProduct'); ?&gt; &lt;?php the_time(get_option('myproduct_date_format')) ?&gt; &lt;?php $thumb = ''; $width = 184; $height = 184; $classtext = ''; $titletext = get_the_title(); $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext); $thumb = $thumbnail["thumb"]; ?&gt; &lt;?php if ( $thumb &lt;&gt; '' &amp;&amp; !$et_ptemplate_showthumb ) { ?&gt; &lt;div class="et_pt_thumb alignleft"&gt; &lt;?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?&gt; &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;span class="overlay"&gt;&lt;/span&gt;&lt;/a&gt; &lt;/div&gt; &lt;!-- end .thumb --&gt; &lt;?php }; ?&gt; &lt;?php if (!$et_ptemplate_blogstyle) { ?&gt; &lt;p&gt;&lt;?php truncate_post(550);?&gt;&lt;/p&gt; &lt;a href="&lt;?php the_permalink(); ?&gt;" class="readmore"&gt;&lt;span&gt;&lt;?php esc_html_e('read more','MyProduct'); ?&gt;&lt;/span&gt;&lt;/a&gt; &lt;?php } else { ?&gt; &lt;?php global $more; $more = 0; ?&gt; &lt;?php the_content(); ?&gt; &lt;?php } ?&gt; &lt;/div&gt; &lt;!-- end .et_pt_blogentry --&gt; &lt;?php endwhile; ?&gt; &lt;div class="page-nav clearfix"&gt; &lt;?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?&gt; &lt;?php get_template_part('includes/navigation'); ?&gt; &lt;?php } ?&gt; &lt;/div&gt; &lt;!-- end .entry --&gt; &lt;?php else : ?&gt; &lt;?php get_template_part('includes/no-results'); ?&gt; &lt;?php endif; wp_reset_query(); ?&gt; &lt;/div&gt; &lt;!-- end #et_pt_blog --&gt; &lt;?php edit_post_link(esc_html__('Edit this page','MyProduct')); ?&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;!-- end .post --&gt; &lt;?php endwhile; endif; ?&gt; &lt;/div&gt; &lt;!-- end #content-left --&gt; &lt;?php if (!$fullwidth) get_sidebar(); ?&gt; &lt;?php get_footer(); ?&gt; &lt;?php } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload