Skip to content

Instantly share code, notes, and snippets.

Last active Jul 23, 2020
What would you like to do?
* Single
* @package EAGenesisChild
* @author Bill Erickson
* @since 1.0.0
* @license GPL-2.0+
* Related Posts
function ea_single_related_posts() {
$loop = new WP_Query( array(
'posts_per_page' => 3,
'post__not_in' => array( get_the_ID() ),
'category_name' => ea_first_term( 'category', 'slug' )
) );
if( $loop->have_posts() ):
echo '<section class="related-posts">';
echo '<header><h3>Related Posts</h3></header>';
while( $loop->have_posts() ): $loop->the_post();
get_template_part( 'partials/archive', 'related' );
echo '</section>';
add_action( 'genesis_after_entry', 'ea_single_related_posts', 5 );

This comment has been minimized.

Copy link

@bathrivijay05 bathrivijay05 commented Jul 21, 2020

I added the above code in my EA Genesis Child Theme's single.php file. It shows the following error.
Warning: urlencode() expects parameter 1 to be string, object given in F:\Do Not Delete\LOCALHOST\htdocs\wp\wp-includes\formatting.php on line 5371


This comment has been minimized.

Copy link
Owner Author

@billerickson billerickson commented Jul 23, 2020

I don't see the urlencode() function in the above code snippet so I don't believe it is responsible for the error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment