dslreports logo
 
    All Forums Hot Topics Gallery
spc
Search similar:


uniqs
1270

DFWDraco76
Premium Member
join:2001-02-21
Dallas, TX

DFWDraco76

Premium Member

MySQL Problem on WordPress Blog

I recently set up a WordPress blog at »www.thelifeofbrian.info/blog. It's been a challenge getting everything moved over from the old blog (»dfwdraco76.blogspot.com), but I'm getting there.

The problem I'm having at this point, which showed up after working correctly for at least a week, is that the "Recent Posts" box in the upper right hand corner is showing the FIRST 10 posts ever made to the blog instead of the LAST 10. It worked fine in the beginning. AND, when I use the "Recent Posts" widget built into WordPress - that works correctly.

According to my hosting company (»www.thelifeofbrian.info/ ··· -update/) it is a problem with MySQL. When I asked them for a bug number they referred me to »bugs.mysql.com/bug.php?id=32202. They're saying there's nothing they can do to fix it until MySQL fixes the problem, and there are no workarounds.

The problem I have with that is the fact that the build-in Recent Posts widget works just fine. So what I need to figure out is:

  • What is the SQL query that the "Recent Posts" built into my theme is using?
  • Where does this SQL query live so I can modify it
  • What is the SQL query that the "Recent Posts" widget built into WordPress is using?


I haven't made much progress in this area just yet... I was hoping somebody here might have some suggestions on where to find this, or how to figure it out?

Robert
Premium Member
join:2001-08-25
Miami, FL

Robert

Premium Member

Please post the actual code used to display the recent posts.

DFWDraco76
Premium Member
join:2001-02-21
Dallas, TX

DFWDraco76

Premium Member

This is the best I can do -- like I said, I'm not sure where the actual SQL query lives.
<div class="tabbertab">
<h2>Recent Posts</h2>
<ul>
<?php $myposts = get_posts('numberposts=10&offset=1'); foreach($myposts as $post) :?>
<li><a href="<?php the_permalink(); ?>"><?php the_title();?></a></li>
<?php endforeach; ?>
</ul>
</div>
 

"get_posts" looks to me (a non-php person) like some kind of function, but it's not in the sidebar.php file where the above code lives - and I haven't found it anywhere else.

I've asked about this (and many other things) where I got this theme (Statement) but haven't gotten any help with it so far...
DFWDraco76

DFWDraco76 to Robert

Premium Member

to Robert
I have a working solution now....

I guess I was trying to dig too deep, looking for SQL queries.

I found that the built-in Recent Posts was using
<?php get_archives('postbypost', '10', 'custom', '<li>', '</li>'); ?>
 

So I substituted that and it's working. Not like before -- the other way omitted the most recent post (that's right on top anyway), but I can live with this.
DFWDraco76

1 edit

DFWDraco76

Premium Member

Since I linked to this thread from the Statement theme website I should explain the workaround better.

In wp-content/themes/statement/sidebar.php, I replaced this:
# <?php $myposts = get_posts('numberposts=10&offset=1'); foreach($myposts as $post) :?>  
# <li><a href="<?php the_permalink(); ?>"><?php the_title();?></a></li>  
# <?php endforeach; ?>  
 

with this:

(according to the WP Codex, 'get_archives' is depracated --so use this instead)
<?php wp_get_archives('type=postbypost&limit=10&format=html'); ?> 
 

All I know anything about the get_posts vs. get_archives functions is what I read here and here.

The only drawback I've found to this workaround at this point is that it includes the most recent post, whereas the original code left it off.