Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End how to stop broken images and links

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #30650
    leehughes
    Member

    Hi,

    I have set up some custom fields on my site and in the product listing page I have 30 products all set up like
    http://www.leehughes.co.uk/wp-content/uploads/2010/10/Screen-shot-2010-10-26-at-15.32.56.png

    These are made by "><?php echo $alt; ?>

    But now if i have pages with 14 items then I will have 16 broken images (like the screenshot) left over… is there a way using php to know how many products that page will have so it won’t go over?

    #77461
    TheDoc
    Member

    You’ll want to look at some sort of “while” statement. Unfortunately, outside of WordPress I don’t have too much PHP knowledge.

    #77462
    Bob
    Member

    So, instead of coding 30 anchor links, you only code 14 of them right?

    Although they’re probably dynamically created, so can you post your code please, for that products page?
    Like TheDoc said, a while loop seems appropriate. That way, you can have it display only 14 item links when you’ve only got 14 products.
    Anyway, some code would be handy.

    #77471
    Rob MacKay
    Participant

    Are you setting the products through the custom fields?

    Something like could work – but only if $link was an array really, so if you have like the custom field array, with the key that maybe all the stuff is in – then you could put that in. It should then loop through the array and only output each one as long as there is one.


    while($link) {

    echo "$alt";

    }

    Or if that dosn’t work…

    foreach($custom-field as $item) {

    echo "{$item}";

    }

    I hope that gives you an idea anyway. Hard to figure it out without more info really

    #77421
    leehughes
    Member

    Hey guys,

    I have uploaded the code for that template via a text file which you can see on this link: http://www.leehughes.co.uk/listings.txt

    Yes, it’s all through custom fields, hopefully you will understand it more than I do :P

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.