• 0

Wordpress Help (Recent Post Question)


Question

If you remember me, I've been working on the company website for almost a year. Well the content is not all to me yet. No surprise but I'm learning Wordpress and going to get it working using Starkers 4.0 which is a strip down version of wordpress for creating Wordpress theme.

http://viewportindustries.com/products/starkers/

Anyway, I'm trying to get the recent blog post to feed to my homepage but it's only showing the first recent post and repeating it 2 times which I want to show the last 3 recent blog post with the feature image in it. Can anyone help me?

http://www.romabio.com/test/


<!-- Blog Section -->
<div class="blog-Wrap">

<ul>

<?php query_posts("showposts=3"); the_post(); ?>

<li>
<a href="<?php the_permalink(); ?>">
<div class="date-Wrap">
<div class="blog-Month"><?php the_time('M'); ?></div>
<div class="blog-Day"><?php the_time('d'); ?></div>
<div class="blog-Bar"></div>
</div>
<div class="blog-img">
<img src="<?php the_post_thumbnail('homepage-thumb'); ?>" />
</div>
<h4><?php the_title(); ?></h4>
<?php the_excerpt(); ?>
</a>
</li>

<?php query_posts("showposts=3"); the_post(); ?>

<li>
<a href="<?php the_permalink(); ?>">
<div class="date-Wrap">
<div class="blog-Month"><?php the_time('M'); ?></div>
<div class="blog-Day"><?php the_time('d'); ?></div>
<div class="blog-Bar"></div>
</div>
<div class="blog-img">
<img src="<?php the_post_thumbnail('homepage-thumb'); ?>" />
</div>
<h4><?php the_title(); ?></h4>
<?php the_excerpt(); ?>
</a>
</li>

<?php query_posts("showposts=3"); the_post(); ?>

<li>
<a href="<?php the_permalink(); ?>">
<div class="date-Wrap">
<div class="blog-Month"><?php the_time('M'); ?></div>
<div class="blog-Day"><?php the_time('d'); ?></div>
<div class="blog-Bar"></div>
</div>
<div class="blog-img">
<img src="<?php the_post_thumbnail('homepage-thumb'); ?>" />
</div>
<h4><?php the_title(); ?></h4>
<?php the_excerpt(); ?>
</a>
</li>

</ul>

<?php wp_reset_query(); ?>

<div class="blog-Button">

<div class="button"><a href="#" title="Blog">View Blog</a></div>

</div>

</div>
<!-- Blog Section -->
[/CODE]

Link to comment
https://www.neowin.net/forum/topic/1155882-wordpress-help-recent-post-question/
Share on other sites

14 answers to this question

Recommended Posts

  • 0

Well your query loop is all wrong and doesn't actually loop over anything. I suggest you do some reading about the loop and PHP. http://codex.wordpress.org/Function_Reference/WP_Query.

the whole point of a loop is so that you dont have to repeat yourself as you have done.

You should use a new WP query and a while loop.

so to correct your code you could cut it down to the following:

&lt;?php $my_query = new WP_Query('posts_per_page=3'); ?&gt;
&lt;?php while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); ?&gt;
  &lt;li&gt;
     &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;         
        &lt;div class="date-Wrap"&gt;
           &lt;div class="blog-Month"&gt;&lt;?php the_time('M'); ?&gt;&lt;/div&gt;          
           &lt;div class="blog-Day"&gt;&lt;?php the_time('d'); ?&gt;&lt;/div&gt;          
           &lt;div class="blog-Bar"&gt;&lt;/div&gt;         
         &lt;/div&gt;         
         &lt;div class="blog-img"&gt;          
            &lt;img src="&lt;?php the_post_thumbnail('homepage-thumb'); ?&gt;"&gt;         
          &lt;/div&gt;         
          &lt;h4&gt;&lt;?php the_title(); ?&gt;&lt;/h4&gt;
         &lt;?php the_excerpt(); ?&gt;    
         &lt;/a&gt;   
&lt;/li&gt;
&lt;?php endwhile; ?&gt;

But I would suggest you read up on what the code is actually doing so you can understand and implement it correctly with WordPress in the future.

  • 0

Neowins messing up for some reason.

Heres the code:

&lt;?php $my_query = new WP_Query('posts_per_page=3'); ?&gt;
&lt;?php while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); ?&gt;
  &lt;li&gt;
     &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;         
        &lt;div class="date-Wrap"&gt;
           &lt;div class="blog-Month"&gt;&lt;?php the_time('M'); ?&gt;&lt;/div&gt;          
           &lt;div class="blog-Day"&gt;&lt;?php the_time('d'); ?&gt;&lt;/div&gt;          
           &lt;div class="blog-Bar"&gt;&lt;/div&gt;         
         &lt;/div&gt;         
         &lt;div class="blog-img"&gt;          
            &lt;img src="&lt;?php the_post_thumbnail('homepage-thumb'); ?&gt;"&gt;         
          &lt;/div&gt;         
          &lt;h4&gt;&lt;?php the_title(); ?&gt;&lt;/h4&gt;
         &lt;?php the_excerpt(); ?&gt;    
         &lt;/a&gt;   
&lt;/li&gt;
&lt;?php endwhile; ?&gt;

Oh and your code is completely invalid as you cant have all that in an anchor tag.

Showposts in a WP_Query is also deprecated.

  • 0

Neowins messing up for some reason.

Heres the code:

&lt;?php $my_query = new WP_Query('posts_per_page=3'); ?&gt;
&lt;?php while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); ?&gt;
  &lt;li&gt;
	 &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;		
		&lt;div class="date-Wrap"&gt;
		   &lt;div class="blog-Month"&gt;&lt;?php the_time('M'); ?&gt;&lt;/div&gt;		  
		   &lt;div class="blog-Day"&gt;&lt;?php the_time('d'); ?&gt;&lt;/div&gt;		  
		   &lt;div class="blog-Bar"&gt;&lt;/div&gt;		
		 &lt;/div&gt;		
		 &lt;div class="blog-img"&gt;		  
			&lt;img src="&lt;?php the_post_thumbnail('homepage-thumb'); ?&gt;"&gt;		
		  &lt;/div&gt;		
		  &lt;h4&gt;&lt;?php the_title(); ?&gt;&lt;/h4&gt;
		 &lt;?php the_excerpt(); ?&gt;	
		 &lt;/a&gt;  
&lt;/li&gt;
&lt;?php endwhile; ?&gt;

Oh and your code is completely invalid as you cant have all that in an anchor tag.

Showposts in a WP_Query is also deprecated.

Thanks for the code fix! It's in HTML5 and you can put DIV tags in an anchor tag.

  • 0

No, I mean if you go to the w3 site it will pass!

w3 won't check those kind of things, it only checks if you use correct css and html tags without typos and forgetting to close them but not if a html tag is in another html tag :p

Anyway you should be using <p> tags for text instead of div, div isn't meant to be used everywhere >.>

  • 0

Whats wrong with WordPress?

Can be a nightmare to work with. In my work we have a few clients who insist on using it and it's always more hassle than it needs to be. Some truly dumb stuff can happen in it. Plugins that interfere and make the whole system inoperable. Similarly plugins that seem to magically "fix" everything when you install them again. Wordpress keeps a "database version" in a table but can also allow it to move out of sync with the rest of the installation again causing much mirth and comedy. Generally be very afraid when you see "one click install!" or "easy update!" mentioned anywhere near it. Run it on a windows based server and there can be no end of weird permissions errors that crop up from time to time.

No doubt in a lot of cases it does the job. It has plenty of features and often it's relatively simple to work in. However on the flip side it usually has "too many features" for the average user because it tries to be all things to all men. Once you need to do something out of the ordinary you spend your entire life seemingly hacking functions and loops to get it to what you need. And because so many hands touch it the code can sometimes make next to no sense. Overall it just has the feel that it's one sticking plaster away from falling to pieces around you. It's certainly not a "precision tool".

  • 0

Can be a nightmare to work with. In my work we have a few clients who insist on using it and it's always more hassle than it needs to be. Some truly dumb stuff can happen in it. Plugins that interfere and make the whole system inoperable. Similarly plugins that seem to magically "fix" everything when you install them again. Wordpress keeps a "database version" in a table but can also allow it to move out of sync with the rest of the installation again causing much mirth and comedy. Generally be very afraid when you see "one click install!" or "easy update!" mentioned anywhere near it. Run it on a windows based server and there can be no end of weird permissions errors that crop up from time to time.

No doubt in a lot of cases it does the job. It has plenty of features and often it's relatively simple to work in. However on the flip side it usually has "too many features" for the average user and once you need to do something out of the ordinary you spend your entire life seemingly hacking functions and loops to get it to anything. Overall it just has the feel that it's one sticking plaster away from falling to pieces around you.

Well for a start this threads issue was really nothing to do with WordPress. It was a lack of understanding of a php concept (loops).

I would say any CMS can be a nightmare to work with, especially if you dont know what you are doing.

The plugin issue is again not really WordPress's fault.

I have come across the database issue though lol. Was an easy fix however and the site had been moved across numerous hosts by loads of different people.

I suppose stuff like that teaches you the value of good backup systems.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I recently tried edge. It seems a lot better. A lot of the junk in it is gone. It seems less bloated and snappy.
    • Lethal fake phone chargers are still being sold on Amazon and eBay, UK watchdog warns by Paul Hill Credit: Pexels The UK consumer rights organization, Which?, is claiming that “potentially lethal knock-off chargers” are still being sold on online marketplaces seven years after it exposed the danger of these chargers. In its latest investigation, it bought 15 USB phone chargers from several online marketplaces and found they were missing key information, meaning they cannot be legally sold in the UK. Which? bought the 15 chargers from seven online marketplaces. These were Amazon (including Amazon Haul), AliExpress, B&Q Marketplace, Debenhams Marketplace, and eBay. It said that the chargers were so badly made that anyone using them was at risk of electric shock. Over half the chargers also posed fire and explosion risks. Of the chargers purchased, one was a fake Apple USB-C 35W power adaptor charger. To confuse buyers, the box was branded with an Apple logo, but testing found it to be a fake. Further testing picked up arcing sounds after 10 seconds of use, where a current jumps between two parts of the electrical circuit, which can cause fires, explosions, or electric shock. The manufacturers of this particular charger also put modeling clay inside it to make it feel more weighty, robust, and genuine. Not all of the chargers were technically faulty; however, some were missing key packaging, markings, and documentation, meaning they can’t be sold in the UK legally. Which? said that it is now campaigning alongside a coalition of safety groups and businesses for new laws that make online marketplaces responsible for ensuring the safety of products that they choose to list on their websites. It also said the government needs to start using powers under the Product Regulation and Metrology Act, which was adopted last July, to impose safety requirements on online marketplaces via secondary legislation, but so far, there have been delays. No matter what country you are in, be sure to properly research what you are buying and only buy authentic chargers to prevent fires. You can read more about Which?’s research here.
    • Visual Studio finally gets long-awaited feature that developers will love by Usama Jawad Visual Studio Code is Microsoft's popular, lightweight, open-source code editor, it is actually Visual Studio that is the company's flagship integrated development environment (IDE). Although the IDE already offers a boatload of useful features for developers, Microsoft has finally introduced a long-requested capability that will be loved by many. While developers have already been able to create Git pull requests (PRs) directly within Visual Studio for the past couple of years, it had not been possible to review a PR without switching to the browser, until now. Microsoft revealed in December 2025 that it is working on UX that enables developers to do just that, and fast-forward to June 2026, and Visual Studio finally has native capabilities to open and inspect a PR, discuss feedback, and wrap up the review, all without switching to the browser. This integration works for both GitHub and Azure DevOps (including on-prem). Developers have access to multiple surfaces to open a PR, including Git Repository, Git Changes, and the Git menu in Visual Studio. Once you open a PR, all the important details will be immediately visible to you, from where you can navigate to various levels of granularity and branch states, depending on the reviews that you are engaged in. As you would expect, you also get a diff view that enables you to see code changes inline or side-by-side in a separate panel. You can also review commit-by-commit. Additionally, this UX fosters collaboration as you can leave comments, reply to threads, and resolve conversations easily. Naturally, you can also leverage Copilot to apply a code suggestion to fix a potential issue. When you are done, you have the ability to approve, complete, and merge the PR. This is a pretty major feature as it has been requested heavily for the past few years. You can try it out in Visual Studio 2026 version 18.7, made available here recently. Microsoft plans to enhance this experience further in future releases with comment filtering, a timeline of PR activity, and more.
    • This AdGuard Family lifetime deal is still only $15.97 by Steven Parker Today's highlighted Neowin Deal comes via our Apps + Software section, where you can get a lifetime subscription and save 90% on a lifetime AdGuard Family Plan. AdGuard is a unique program that has all the necessary features for what they claim to be "the best web experience." The software combines the an advanced ad blocker, a privacy protection module, and a parental control tool—all working in one app. This software deals with annoying ads, hides your data from a multitude of trackers, protects you from malware attacks, and even lets you restrict your kids from accessing inappropriate content. Install AdGuard and see the internet as it was supposed to be: clean and safe. Get rid of annoying banners, pop-ups & video ads once and for all Hide your data from the multitude of trackers & activity analyzers that swarm the web Avoid fraudulent and phishing website and malware attacks Protect your kids online by restricting them from accessing inappropriate & adult content Good to know Family Plan Length of access: lifetime This plan is only available to new users Redemption deadline: redeem your code within 30 days of purchase Max number of devices: 9 Access options: desktop & mobile Software version: AdGuard Family Updates included A lifetime subscription of AdGuard Family Plan normally costs $169.99, but this deal can be yours for just $15.97, that's a saving of $157.02. For full terms, specifications, and license info please click the link below. Get this AdGuard Family lifetime deal for just $15.97 (was $169.99) Although priced in U.S. dollars, this deal is available for digital purchase worldwide. As an online publication, Neowin too relies on ads for operating costs and, if you use an ad blocker, we'd appreciate being whitelisted. In addition, we have an ad-free subscription for $28 a year, which is another way to show support! Support queries If you have queries or need support for any of the Neowin Deals, please use the contact form here. Neowin Deals are managed and sold by StackCommerce who represent Neowin on an affiliate basis. Why we post these deals We post these because we earn commission on each sale so as not to rely solely on advertising, which many of our readers block. It all helps toward paying staff reporters, servers and hosting costs. So for those that keep moaning and complaining, be thankful we're still online for you to even do that. Other ways to support Neowin Whitelist Neowin by not blocking our ads Create a free member account to see fewer ads Make a donation to support our day to day running costs Subscribe to Neowin - for $14 a year, or $28 a year for an ad-free experience Disclosure: Neowin benefits from revenue of each sale made through our branded deals site powered by StackCommerce.
    • the MCT currently downloads 26200.8653, so not completely up to date.
  • Recent Achievements

    • Week One Done
      Timaximus earned a badge
      Week One Done
    • One Month Later
      Timaximus earned a badge
      One Month Later
    • Rookie
      FBSPL went up a rank
      Rookie
    • First Post
      davidbazooked earned a badge
      First Post
    • Week One Done
      davidbazooked earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      499
    2. 2
      PsYcHoKiLLa
      175
    3. 3
      +Edouard
      160
    4. 4
      Steven P.
      83
    5. 5
      ATLien_0
      75
  • Tell a friend

    Love Neowin? Tell a friend!