Show relevant sidebar posts on member detail pages
authorLaury GvR <laury@gaslightmedia.com>
Tue, 30 Jan 2018 22:06:01 +0000 (17:06 -0500)
committerLaury GvR <laury@gaslightmedia.com>
Tue, 30 Jan 2018 22:06:01 +0000 (17:06 -0500)
Posts are retrieved and displayed on member detail page sidebars
depending on whether said posts have a tag associated with that
member.

Also added an extra royalsider instance so it can be properly
initialized. This element is hidden, and is an unfortunate
necessity for the posts sidebar slideshow to show up until we get
a chance to find out why it is not being properly initialized.

page.php
sidebar-member.php

index 2836b72..b1269fe 100644 (file)
--- a/page.php
+++ b/page.php
@@ -65,8 +65,14 @@ get_header(); ?>
                        </main><!-- #main -->
                </div><!-- #primary -->
        </div><!-- .large-9.columns -->
-       <div class="medium-4 large-3 columns page-sidebar">
-               <?php get_sidebar('page');?>
+       <div class="medium-4 large-3 columns page-sidebar"> 
+               <?php 
+                if ( is_member() ) {
+                    get_sidebar('member');
+                } else {
+                    get_sidebar('page');
+                }
+                ?>
        </div><!-- .large-3.columns -->
 </div><!-- .body-content.row.column -->
 <?php
index 6cb24c0..0eab963 100644 (file)
@@ -8,13 +8,18 @@
  */
 
 // Get current user values
-if(isset($_GET['author_name'])) :
-       $curauth = get_user_by( 'login', '' );
+if ( is_member() ) :
+        
+        $member_name = get_member_name();
+        $member_id = get_member_data("id");
+        $member_slug = get_member_data("member_slug");
+//elseif(isset($_GET['author_name'])) :
+//     $curauth = get_user_by( 'login', '' );
 else :
-       $curauth = get_userdata(intval($author));
+       $curauth = get_userdata(intval($member_id));
+        $author_id = $curauth->ID;
 endif;
 
-$author_id = $curauth->ID;
 
 
 if ( ! is_active_sidebar( 'sidebar-2' ) ) {
@@ -22,18 +27,17 @@ if ( ! is_active_sidebar( 'sidebar-2' ) ) {
 }
 ?>
 
-<aside id="secondary" class="widget-area" role="complementary">
 
+<aside id="secondary" class="widget-area" role="complementary">
+               <section class="widget sidebar" style="display: none;">
+                        <h2 class="widget-title news-feed-title">What's Happening</h2>
+                        <div class="widget-container"><?php echo get_new_royalslider(2); ?></div>
+                </section>
        <?php if (! dynamic_sidebar('sidebar-top-ad')):endif; ?>
 
                                <?php
-                               //echo $curauth->user_nicename;
-                               //$string .=  $curauth->nickname;
                                $args = array(
-                                               // combine user nickname and selected tags into query
-
-                                               'tag' => $curauth->user_nicename,
-                                               //'tag' => 'founders-brewing-company',
+                                               'tag' => $member_slug,
                                                'orderby' => 'rand',
                                                'posts_per_page' => 8,
                                                'order'    => 'DESC',
@@ -48,12 +52,11 @@ if ( ! is_active_sidebar( 'sidebar-2' ) ) {
                                $loop = new WP_Query( $args );?>
 
                                <?php if ($loop->post_count == 0) { ?>
-
+                                    <h2>No posts</h2>
                                <?php } else { ?>
-
                                <section class="widget sidebar">
 
-                                       <h2 class="widget-title news-feed-title">What's Happening <?php echo '<br>at '.$curauth->nickname; ?></h2>
+                                       <h2 class="widget-title news-feed-title">What's Happening <?php echo '<br>at '.$member_name; ?></h2>
 
                                        <div class="widget-container">
 
@@ -104,7 +107,7 @@ if ( ! is_active_sidebar( 'sidebar-2' ) ) {
                                // combine user nickname and selected tags into query
                                //'tag' => $curauth->nickname . $string,
                                        'post_type' => 'deal',
-                                       'author' => $author_id,
+                                       'author' => $member_id,
                                        'orderby' => 'rand',
                                        'posts_per_page' => 3,
                                        'order'    => 'DESC'