Conditional post thumbnail based on logged status and post tag

Hey you have to use the below logic to handle the above conditions, it will work. if (!is_user_logged_in() && has_tag(‘private’)) { ?> <a href=”https://wordpress.stackexchange.com/questions/368246/<?php the_permalink(); ?>” title=”<?php the_title_attribute(); ?>”> <img src=”<?php bloginfo(‘template_directory’); ?>/img/default-login.jpg” alt=”<?php the_title(); ?>” /> </a> <?php } else if( is_user_logged_in() && has_tag(‘private’) ) { // show the actual featured image // check … Read more

Recent posts on homepage: different thumbnail based on logged in status and post category

If you want to use the the_ functions (e.g. the_permalink() and the_title()) and including in_category() (without specifying the second parameter) outside of The Loop (the standard one which calls the_post()), you should access the global $post variable and call setup_postdata() to set up global post data and after your foreach ends, call wp_reset_postdata() to restore … Read more

Thumbnail is showing outside its div instead of inside it

the_post_thumbnail() echo the output, hence that’s why the thumbnail is misplaced. To manually echo the output, you should use get_the_post_thumbnail() instead: echo ‘<div class=”post-image right”>’ . // wrapped get_the_post_thumbnail(null, ‘featured-portrait-large’) . ‘</div>’; Or you can instead do this: echo ‘<div class=”post-image right”>’; the_post_thumbnail(‘featured-portrait-large’); echo ‘</div>’;

Featured Image meta box shows at the bottom?

The add_meta_box code you’ve posted does certainly register the metabox to the bottom of the side area. If the box is shown in the center then i imagine it’s because you’ve(at some point) moved the metabox, as can be done with any of the metaboxes(all drag and drop). WordPress remembers where you move boxes to, … Read more

Displaying caption with featured image

To use this you will need to add this to in place of your themes thumbnail function: function your_thumbnail_caption($html, $post_id, $post_thumbnail_id, $size, $attr) { $attachment =& get_post($post_thumbnail_id); if ($attachment->post_excerpt || $attachment->post_content) { $html .= ‘<p class=”thumbcaption”>’; if ($attachment->post_excerpt) { $html .= ‘<span class=”captitle”>’.$attachment->post_excerpt.'</span> ‘; } $html .= $attachment->post_content.'</p>’; } return $html; } add_action(‘post_thumbnail_html’, ‘your_thumbnail_caption’, null, … Read more

WordPress image crop probems

You don’t need to do manual cropping; just create a custom image size, and WordPress will perform the cropping on image upload. e.g. in functions.php: add_image_size( ‘portfolio-thumbnail’, 214, 187, true ); Then in your portfolio template, inside the Loop: the_post_thumbnail( ‘portfolio-thumbnail’ ); (I assume you know how to handle the rest of the output, such … Read more