First of all, thank you for such an excellent plugin! s2Member has been a fantastic addition to the site and I am extremely happy with it!
I have most of it setup, and am currently hitting a wall on how to display member only posts in the loop of a template page. I would say I am intermediate at theme creation in wp, and have created a widget in order to display a different message to members and non-members (e.g. subscribe to one and login to the other).
I know the easy way would be to display posts of a specific members only category e.g. Premium Content.
However, we will have many Authors contributing to the site within the company, and therefore I expect there will be a few that will find it difficult to adhere to the rule of posting premium content in the "Premium Content" category (as obvious as that sounds )!
With this in mind, I need to create a more dynamic method. Below is an example of the code I am using for the home-page.php
- Code: Select all
<div id="main">
<div id="left_column">
<div class="left_col_box"> <span class="main_titles">Featured Content</span>
<?php $args = array(
'posts_per_page' => 1,
'post__in' => get_option( 'sticky_posts' ),
'ignore_sticky_posts' => 1
);
query_posts( $args );?>
<?php rewind_posts(); ?>
<?php while (have_posts()) : the_post(); ?>
<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_title(); ?>
</a></h1><br />
<?php the_content('Read more »'); ?>
<br /><div class="post_details">
by <?php the_author() ?> Date: <time datetime="<?php the_time('Y-m-d') ?>" pubdate="<?php the_time('F jS, Y') ?>"><?php the_time('F jS, Y') ?></time>
<br/>
Posted in
<?php the_category(', ') ?>
| <?php the_tags('Tags: ', ', ', '<br />'); ?>
<?php edit_post_link('Edit', '', ' | '); ?></div>
<div class="clear"></div>
</div>
<?php endwhile; ?>
<div class="left_col_box"> <span class="main_titles">Recent Content</span>
<?php
// The Query
query_posts( array('posts_per_page=5','ignore_sticky_posts' => 1) );
// The Loop
while ( have_posts() ) : the_post(); ?>
<h2 style="margin-bottom: 0px;"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_title(); ?>
</a></h2>
<div class="post_details">
by <?php the_author() ?> Date: <time datetime="<?php the_time('Y-m-d') ?>" pubdate="<?php the_time('F jS, Y') ?>"><?php the_time('F jS, Y') ?></time>
<br/>
Posted in
<?php the_category(', ') ?>
| <?php the_tags('Tags: ', ', ', '<br />'); ?>
<?php edit_post_link('Edit', '', ' | '); ?>
</div>
<?php endwhile;
// Reset Query
wp_reset_query();
?>
</div>
</div>
<div id="right_column">
<?php if ( is_active_sidebar( 'rcb-widget-area' ) ) : ?>
<div class="right_col_box">
<?php dynamic_sidebar( 'rcb-widget-area' ); ?>
</div>
<?php endif; ?>
</div>
</div>
This will show any user (logged in or not) all posts with a featured on the top, and a list on the bottom. I want to create the same layout only with Featured Premium Post on the top and Latest Premium Content on the bottom. I am hoping the answer will be something simple like:
- Code: Select all
<?php $args = array(
'posts_per_page' => 1,
'post__in' => get_option( 's2member_posts' ),
'ignore_sticky_posts' => 1
);
query_posts( $args );?>
<?php rewind_posts(); ?>
<?php while (have_posts()) : the_post(); ?>
Alas, I expect it will be something a bit more challenging!
Thank you in advance for your help and I hope I haven't rambled too much!