Related posts

Posted in: Newspaper
Post count: 220

we want to have related posts based on the taxonomies,is it possible ??

If not can you provide a solution to display related posts using widget …

Thanks

Post count: 6600

Hi,

Not sure what you mean as the actual version of the theme related posts system is based on taxonomies: http://screencast.com/t/XljCStnKsX and to change it you’d need custom mortification to the theme for which you need custom work. Sorry!

Thanks for the message!

  • This reply was modified 11 years by Lucian.
Post count: 220

Hi Lucian,

i want to disabled related post system from the theme,

we want to disply the related posts using the widget we have already available in the sideabar ..http://i60.tinypic.com/fjqq2s.jpg

can you provide the short code to display the content in place of related posts http://i62.tinypic.com/k71ab.jpg

Thanks

  • This reply was modified 11 years by srikanth.
Post count: 1291

Hi,

First you have to disable the Related Articles from Theme Panel – http://screencast.com/t/SxkPbkvIysgA
Then use the do_shortcode() function to call the plugin shortcode on the desired location inside the post template files – http://screencast.com/t/oOBXd4Rp31https://developer.wordpress.org/reference/functions/do_shortcode/

Check the plugin documentation to find it’s shortcode.

Thank you!

Post count: 220

Thanks for the reply.. i found the following information from the plugin author …

Add related posts automatically after the post content by using a code snippet in your (child) theme’s functions.php file

add_filter( ‘the_content’, ‘add_related_posts_after_post_content’ );
function add_related_posts_after_post_content( $content ) {

//check if it’s a single post page.
if ( is_single() ) {

// check if we’re inside the main loop
if ( in_the_loop() && is_main_query() ) {

// add your own attributes here (between the brackets [ … ])
$shortcode = ‘[related_posts_by_tax posts_per_page=”4″]’;

// add the shortcode after the content
$content = $content . $shortcode;
}
}

return $content;
}

in our theme,can we put the code in the function.php directly ??

Post count: 1291

Hi,

Yes, you can place it at the end of the functions.php file.
The shortcode is – http://screencast.com/t/ywl8VeRS
Make sure that the double quotes and the other signs are similar to the default ones, if possible use a code editor like Notepad++. If you decide for different position the do_shortcode() line should look like this:

<?php echo do_shortcode('[related_posts_by_tax posts_per_page="4"]'); ?>

Thank you!

  • This reply was modified 11 years by Emil G.
Post count: 220

Thanks for the Help… it works ….

Viewing 7 posts - 1 through 7 (of 7 total)
The forum ‘Newspaper’ is closed to new topics and replies.