Skip Navigation

[Resolved] Show related posts with YARPP

This support ticket is created 2 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 6 replies, has 2 voices.

Last updated by a.R 2 years, 11 months ago.

Assisted by: Jamal.

Author
Posts
#2226813

a.R

How to implement a TOOLSET-TEMPLATE here? Thank you 🙂

<?php if ( have_posts() ) : ?>
<ul>
	<?php
	while ( have_posts() ) :
		the_post();
		?>
	<li><a href="<?php the_permalink(); ?>" rel="bookmark norewrite" title="<?php the_title_attribute(); ?>" ><?php the_title(); ?></a><!-- (<?php the_score(); ?>)--></li>
	<?php endwhile; ?>
</ul>
<?php else : ?>
<p>No related posts.</p>
<?php endif; ?>
#2226901

Hello and thank you for contacting the Toolset support.

I am sorry, but I am not sure to understand your request. This seems like a partial template from the theme. It seems to display a list of posts' titles as links, and it uses a "the_store" function which I am not familiar with.

Can you elaborate more on what you want to achieve?

In the meantime, I am sure you will find these documentation articles worth reading:
- https://toolset.com/documentation/customizing-sites-using-php/creating-templates-single-custom-posts/
- https://toolset.com/documentation/customizing-sites-using-php/displaying-child-posts/
- https://toolset.com/documentation/customizing-sites-using-php/displaying-parent-posts/
- https://toolset.com/documentation/customizing-sites-using-php/

#2227015

a.R

Hi Jamal, thank you so far. Just forget about the sCore, it´s just a yarpp-thing.
Guess I can boil down the question to: how display a post within the loop in PHP with a TOOLSET-template?
Regards, Achim

#2227073

I'll assume that you are talking about content templates. You can use the render_view_template function as follow:

//Renders the post $mypost using the Content Template with ID equal to 80
echo render_view_template( 80, $mypost );

It also accepts a 3rd argument $user, read more about it here https://toolset.com/documentation/programmer-reference/views-api/#render_view_template

To render a view, user the render_view function in the same documentation article.

Archive templates are definitely a special case, if that's the case, please elaborate more on your use case so I can understand it better.

Keep in mind that a content template is meant to display ONE post, where as a view is meant to query and display a list of posts. Content templates can be used inside a view's loop to render the current post in the loop. Views can also be used inside content templates.

I hope this helps. Let me know if you have any questions.

#2228459

a.R

Great, that looks good! Thank you 🙂
So in this example, 80 would be the number of the post template?

(I don´t find the difference between template and view hard to understand at all.)

#2228693

Yes, indeed. 80 is the ID of the content template. You can get it from the URL while editing the content template.

To get the IDs of the views, activate the legacy editor in Toolset->Settings->General(tab)->Editing experience. Then reload the page. This will add the menu item Toolset->Views, and in that list you can get the ID of the views on the first column.

#2230151

a.R

GREAT, thank you!