bearcoding Posted July 26, 2017 Share Posted July 26, 2017 Hi. I have just put ultimate member on my site and added a wordpress Likebtn plugin to list all liked posts in the ultimate members profile page. But I notice there is a difference to how the liked pages are listed, compared with the author posts. I have compared the two templates and can see that on the post-single template, it asks if there is a thumb available and if so uses it in the post listing. But the um-liked-content posts listing template misses out this step and so does not show a thumb. I really really want to learn more about code structure so I can start to do this myself, but can anyone advice which section to lift from posts-single and use in um-liked-content. It looks like I need to move, this section but not 100% sure where to put it??? <?php if ( has_post_thumbnail( $post_id ) ) { $image_id = get_post_thumbnail_id( $post_id ); $image_url = wp_get_attachment_image_src( $image_id, 'full', true ); ?> <div class="um-item-img"><a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail( $post_id, 'medium' ); ?></a></div> <?php } ?> posts-single.php um-liked-content.php Quote Link to comment https://forums.phpfreaks.com/topic/304417-ultimate-member-template-tweak-help/ Share on other sites More sharing options...
bearcoding Posted July 26, 2017 Author Share Posted July 26, 2017 OK. I still trying. Looks to me I need to get the "checking for a thumb" code into the loop? So adding.... <div class="um-item"> <div class="um-item-link"><i class="um-icon-ios-paper"></i><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div> <?php if ( has_post_thumbnail( $post_id ) ) { $image_id = get_post_thumbnail_id( $post_id ); $image_url = wp_get_attachment_image_src( $image_id, 'full', true ); ?> <div class="um-item-img"><a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail( $post_id, 'medium' ); ?></a></div> <?php } ?> as part of the likebtn loop ie. below <?php foreach ($post_loop as $post): ?> Am I warm? Quote Link to comment https://forums.phpfreaks.com/topic/304417-ultimate-member-template-tweak-help/#findComment-1548902 Share on other sites More sharing options...
bearcoding Posted July 26, 2017 Author Share Posted July 26, 2017 (edited) So I take both files and end up with this. It feels very simplistic?!?! and so wrong? <?php /** * Most Liked Content tempplate */ // Block direct requests if ( !defined('ABSPATH') ) die('-1'); ?> <?php if (count($post_loop) > 0): ?> <div class="um-profile-note" style="display: block;"><span><?php echo __('Liked Content', LIKEBTN_I18N_DOMAIN); ?></span></div> <?php foreach ($post_loop as $post): ?> <div class="um-item"> <div class="um-item-link"> <?php if ($post['type'] == LIKEBTN_ENTITY_COMMENT) :?> <i class="um-icon-chatboxes"></i> <?php elseif (in_array($post['type'], array(LIKEBTN_ENTITY_USER, LIKEBTN_ENTITY_UM_USER, LIKEBTN_ENTITY_BP_MEMBER, LIKEBTN_ENTITY_BBP_USER))): ?> <i class="um-faicon-user"></i> <?php else: ?> ADDED CODE - TO BRING IN THUMB <?php if ( has_post_thumbnail( $post_id ) ) { $image_id = get_post_thumbnail_id( $post_id ); $image_url = wp_get_attachment_image_src( $image_id, 'full', true ); ?> <div class="um-item-img"><a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail( $post_id, 'medium' ); ?></a></div> <?php } ?> END <i class="um-icon-ios-paper"></i> <?php endif ?> <a href="<?php echo $post['link'] ?>"><?php echo $post['title'] ?></a> </div> <div class="um-item-meta"> <span><?php echo date_i18n(get_option('date_format'), strtotime($post['vote_date'])) ?></span> <span class="badge"> <?php if ($post['vote_type'] == 1): ?> <i class="um-faicon-thumbs-o-up"></i> <?php else: ?> <i class="um-faicon-thumbs-o-down"></i> <?php endif ?> </span> </div> </div> <?php endforeach; ?> <?php else: // No items ?> <div class="um-profile-note" style="display: block;"><span><?php echo __('No Content Liked Yet', LIKEBTN_I18N_DOMAIN); ?></span></div> <?php endif; ?> Edited July 26, 2017 by bearcoding Quote Link to comment https://forums.phpfreaks.com/topic/304417-ultimate-member-template-tweak-help/#findComment-1548904 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.