Posts Tagged wordpress
Related posts bug in Mystique

Mystique is an awesome theme designed by the people at http://digitalnature.ro/ Over the past few days I’ve been working with this theme, tweaking it and trying to set it up.
And I found a little bug in the theme. On single pages, $post has an unexpected behavior. Its there, but points to the wrong post.
After a few hours of bug hunting, I was able to figure out what was causing this. The flaw was in the “comments” part of the code. The commenting area has a list of “Related posts”. To generate this list, Mystique has to use the $post. Thus, all code after the comments box (like the sidebar, footer, etc) cannot access any post data.
To fix this, go to Theme > Editor in your WordPress installation. And select the theme to edit as Mystique. We’ll edit the “Comments” file… comments.php.

Scroll down to the very bottom of the file. You’ll see some code for related posts. It starts with
if($rp_query && $rp_query->have_posts() && $jquery): ?>
To fix the bug, you need to restore $post to its original value. We’ll do just that. The line of code above checks if there exist any related posts. If it does, it echoes them out with proper formatting.
So add this line just after the if($rp_query… line:
<?php /*MODIFICATION */ $currentID =$post->ID; ?>
Now, we need to restore the $post using this $currentID. And the place to do that is right after the Related Posts work is done. And that happens here:
<!– /related posts –>
<?php endif; ?>
We’ll restore the $post right before the block of text ends. And that is done using:
<?php /* MODIFICATION */ query_posts(‘p=’.$currentID); the_post(); ?>
Here’s what the entire block of code looks like on my screen:

I found this in the latest version of Mystique (v2.3.1) so I’m guessing this has been an issue with past versions as well.
Anyway, I hope you found this useful.

Video Copilot
A cell dweller
Amit's Blog
Gandhi's Ashonomics
Harsha's blog
Irrashonally urs
The instance just lost