Is there a good way of just displaying one category image for a post with multiple categories assigned to it? I’ve been poking at it for much of the evening, which almost guarantees I’ve missed something really obvious, but…
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
June 09, 2008 4:22am
Subscribe [2]#1 / Jun 09, 2008 4:22am
Is there a good way of just displaying one category image for a post with multiple categories assigned to it? I’ve been poking at it for much of the evening, which almost guarantees I’ve missed something really obvious, but…
#2 / Jun 10, 2008 4:02am
Anyone?
#3 / Jun 10, 2008 4:18am
Hi
Should be pretty easy and straightforward, haven’t tested this but as {categories} does not seem to have a {count} variable, you could use PHP
<?php $count = 0; ?>
{categories}
<?php if ($count++ < 1) { ?>
{category_image}
<?php } ?>
{category_name}
{/categories}or something similar. Haven’t tested this, just wrote it down here.
#4 / Jun 10, 2008 5:17am
And if that does still not work, there’s always raw SQL queries as solution to almost any db related problem.
#5 / Jun 10, 2008 8:35am
Erk. I fear queries. But thanks, I’ll give that one a try.
#6 / Jun 10, 2008 8:42am
There seems to be a working one in that paralled thread.
#7 / Jun 10, 2008 10:20am
On a final note, have you tried this?
{categories limit="1"}
{category_image}
{/categories}#8 / Jun 10, 2008 1:08pm
Gah! What did I say about missing something incredibly obvious? That’s sorted it - thanks! 😉
#9 / Jun 10, 2008 1:19pm
Don’t feel too bad, please: I get paid to know such things and initially missed it as well… 😊