
Hello everyone,
I was wondering if there is any shortcuts to add a authors bio, related posts section below the post..??
Fo that I can use this
add_action( 'beans_post_after_markup', 'example_etc' );
function example_etc() {
?>
<div id="exauthorarea">
<div class="eximage">
<?php echo get_avatar( get_the_author_meta( 'user_email' ), 100 ); ?>
<h4>Article By <?php the_author_posts_link(); ?></h4>
</div>
<div class="exinfo">
<p>
<?php the_author_meta( 'description' ); ?>
<a class="exlink" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>">
View all posts by <?php the_author_posts_link(); ?>
<span class="meta-nav">→</span>
</a>
</p>
</div>
</div>
<div id="related-posts">
<h3><span>Posts you don't wanna miss</span></h3>
<ul>
<?php
$orig_post = $post;
global $post;
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'posts_per_page'=>3,
'caller_get_posts'=>1
);
$my_query = new wp_query( $args );
while( $my_query->have_posts() ) {
$my_query->the_post();
?>
<li>
<div class="relatedposts">
<div class="relatedthumb">
<a rel="external" href="<?php the_permalink() ?>">
<?php the_post_thumbnail(array(158,100)); ?>
</a>
</div>
<div class="related-post-title">
<h4 itemprop="headline">
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h4>
</div>
</div>
</li>
<?php }
}
$post = $orig_post;
wp_reset_query();
?>
</ul>
</div>
<?php
}
and there is one more question how do i add the popular posts..?? In a normal theme i usually add this in the single.php
setPostViews(get_the_ID());
and to show the posts i use this
query_posts('meta_key=post_views_count&orderby=meta_value_num&order=DESC');
if (have_posts()) : while (have_posts()) : the_post();
?>
<ul>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
</ul>
<?php
endwhile; endif;
wp_reset_query();
We can add all of these using {$markup_id}_before_markup {$markup_id}_prepend_markup {$markup_id}_append_markup {$markup_id}_after_markup but i was wondering if there is any shortcuts to do this because I think all of this will slow down the website.
Thank you,

Hi Anupam,
There is no shortcode in Beans for the Autor box and Related posts so as you correctly stated, you have add it yourself or perhaps use a plugin.
In is in the road map to add a serie of plugins for Beans to add that kind of functionalities but I don't have an ETA on that.
Cheers,

Hey Thierry,
Thanks for the information. And i wanted to know how to show the popular posts in the theme..??

Hey Anupam, same regarding popular posts, it would probably be part of the related posts plugin π

Hello Anupam,
As far as related posts are concerned, you could try something like this.
add_action( 'beans_footer_before_markup', 'related_posts_categories', 5 );
function related_posts_categories() {
if ( is_singular( 'post' ) ) {
global $post;
$count = 0;
$postIDs = array( $post->ID );
$related = '';
$cats = wp_get_post_categories( $post->ID );
$catIDs = array();
foreach ( $cats as $cat ) {
$catIDs[] = $cat;
}
$args = array(
'category__in' => $catIDs,
'post__not_in' => $postIDs,
'showposts' => 4,
//'ignore_sticky_posts' => 1,
'orderby' => 'rand',
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array(
'post-format-link',
'post-format-status',
'post-format-aside',
'post-format-quote'
),
'operator' => 'NOT IN'
)
)
);
$cat_query = new WP_Query( $args );
if ( $cat_query->have_posts() ) {
while ( $cat_query->have_posts() ) {
$cat_query->the_post();
$img = get_the_post_thumbnail( $post->ID, 'medium' );
$related .= '<li><a href="' . get_permalink() . '" rel="bookmark" title="Permanent Link to' . get_the_title() . '">' . $img . '</a><h3><a href="' . get_permalink() . '" rel="bookmark" title="Permanent Link to' . get_the_title() . '">'. get_the_title() .'</a></h3></li>';
}
}
if ( $related ) {
printf( '<hr><div class="related-posts uk-block"><div class="uk-container uk-container-center"><h4 class="uk-h2 uk-text-center">Lire aussi</h4><p class="uk-text-large uk-text-center uk-margin-large-bottom">Related posts</p><ul class="uk-grid uk-grid-width-1-4">%s</ul></div></div>', $related );
}
wp_reset_query();
}
}
This code snippet adds four related posts based on the category of the current post with a thumbnail (with NO fallback if there's no post thumbnail, be careful). In this snippet, the related posts are displayed just above the footer with beans_footer_before_markup
but you can obviously put it where you want.
Hope it helps.
Mat

Hey thierry and Mathieu
thanks for the info. But actually i wanted to show them without writing all of the code π so i guess i'll use the plugin.
Thank you for your suggestions.
And Mathieu that code works like a charm i show the related posts based on tags. Thank you for the help.