Forums
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Sorry Doc – I feel a little bad asking you to trawl though my code.
/*
Template Name: Home
*/
?>
I’ve never seen multiple queries in a single loop like that. That’s probably what is causing the custom fields to go wonky. Here’s my version of your template:
What We Do
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
; ?/>/images/leads.jpg)
" class="button">View More
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
; ?/>/images/leads.jpg)
" class="button">View More
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
; ?/>/images/customers.jpg)
" class="button">View More
Note that I’m resetting the query after each loop.
Also, I’ve removed the custom fields altogether, since I really don’t see why you want to use them when you can just link directly to the image in your theme’s folder.
If you need to link to a custom field, don’t combine the template directory code with the custom field code, I’m sure that was causing some issues as well.
Yes, that is really helpful. I thought the loop had to contain all queries but it makes sense that you would break it up and reset it after it each group.
Regarding custom fields, isn’t the benefit that they can be changed by the user using the WP back-end?
Totally, but not if they are linking to images in your theme’s folder that they’d have to upload.
Yeah, it’s best if you post thumbnails if it isn’t already being used or get a multiple post thumbnails plug in. This way they just upload the image and its inserted.
Ok, but to do that would you simply use a class to ensure the images are located in the right position and would that class need to be wrapped in any code?