Click here to Skip to main content
14,869,895 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The error is on line 4, here's the full code :

$orig_post = $post;
global $post;
$categories = get the category($post->ID);
if ($categories)	{
$category_ids = array();
foreach($categories as $individual category) {
$ category ids[] = $individual_category->term id;
'category in’	=> $ category ids,
'post not in’ => array($post->ID),
'posts per page’=> 4,	
'ignore_sticky posts’=>1,
'orderby’ =>	’rand’	
$my_query = new wp_query( $arqs );
i f( $my_query->have_posts()	)	{
echo '<div class="relatedposts"><h3>Related Posts :</h3>'; while( $my query->have posts() )	{
$my query->the post();?>
<div class="relatedthumb">
<a rel="external" href="<?php the_permalink()?>"><?php
the post thumbnail(array(150,100)); ?><br />
<?php the_title(); ?>
<?php }
echo '</div>';
} };
$post = $orig post;
wp reset query(); ?>

What I have tried:

I have tried to figure out but its still error, plz help :')
Updated 10-Mar-21 7:49am

1 solution

Names can't contain spaces, use camelCase names instead:
$categories = get the category($post->ID);
$categories = getTheCategory($post->ID);
You can use underscores insead, but that's pretty old school these days:
$categories = get_the_category($post->ID);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900