Archived topic
Getting Critical Error while Adding Related Post Element
8 replies · Started by Rohit on September 10, 2021
Hello I want to add related Post with help of Elements in my website, but getting critical error and also blog design is mashup.
I'm following this tutorial
https://www.wplogout.com/display-related-posts-in-generatepress-theme/
Hi there,
i can't debug the issues from another users site tutorial.
But this is the original code i wrote for displaying a related WP Show Posts list in your Hook Element:
<div class="wpsp-related-posts grid-container">
<h2>Related Posts</h2>
<?php
if ( is_single() ) {
$cats = get_the_category();
$cat = $cats[0];
} else {
$cat = get_category( get_query_var( 'cat' ) );
}
$cat_slug = $cat->slug;
$list = get_page_by_title( 'related', 'OBJECT', 'wp_show_posts' );
if ( function_exists( 'wpsp_display' ) && is_object( $list ) ) {
wpsp_display( $list->ID, 'tax_term="' . $cat_slug . '"' );
}
?>
</div>
And this blog post from the site it was orginally added to explains how - see Related Posts:
https://gpsites.co/merch/the-single-post/
MAIN THING TO NOTE. You don't need to add the WPSP ID to the code above. You just need a WPSP List titled: related
related post not showing with this code also.
Hi Rohit,
Can you show us the settings of the Hook Element you've placed David's on?
Perhaps its missing a display rule location or it's not hooked to the correct hook.
Let us know. :)
here it is
https://prnt.sc/1rwcwsq
https://prnt.sc/1rwd0z5
Show Related post Title only, but related post not visible.
Do you have WP Show Posts plugin installed and activated?
That is needed to make wpsp_display() function run. Can you check and confirm?
it is possible to add without plugin?
it is possible to add without plugin?
It's not possible to make it run without the plugin, unfortunately.
wpsp_display() is a function taken from the plugin.