Events Made Easy › Forums › How do I … › Only show event on homepage if attribute is applied
- This topic has 7 replies, 2 voices, and was last updated 12 years, 9 months ago by Franky.
-
AuthorPosts
-
Tue 31 Jan 2012 at 14:34 #43705AnonymousInactive
The below code is outputting 6 events on my homepage. It seems to be choosing the 6 by post ID. I want to change this so that it will only show a post on the homepage if the custom attribute called HOMEPAGE is added to the post.
How do I do this?
<?php if(is_front_page()): ?>
<div id="eventBoxes">
<ul>
<?php $vReturn = eme_get_events_list('limit=6'); ?>
<?php
$vReturn = explode("",$vReturn);
foreach($vReturn as $item) {
if(strpos($item,'<div id="homepage">yes</div>') !== false) {
echo $item;
}
}
?>
</ul>
<br class="clear" />
<?php else: ?>
<div id="content">
<?php echo the_content(); ?>
</div>
<?php endif; ?>I tried adding this IF function before, but this didn’t do the trick.
<?php if(isset($_POST['HOMEPAGE']) && $_POST['HOMEPAGE'] == 'yes') : ?>
Thanks in advance.
Tue 31 Jan 2012 at 16:51 #49333FrankyKeymasterdo a “print_r” in your php-loop for each event to see the content of it, so you can base your php code on that.
Tue 31 Jan 2012 at 21:46 #49334AnonymousInactiveSorry, but I’ve no idea what you mean. My knowledge is limited when it comes to WordPress.
Tue 31 Jan 2012 at 22:22 #49335FrankyKeymastereach event is an php-array, so the php-function print_r prints out the contents of that array for you, and then you can choose the elements which are interesting for you to do an if-statement on.
Thu 2 Feb 2012 at 01:06 #49336AnonymousInactiveThis is my default event list format…
<li class="home">
<div id="homepage">#_ATT{HOMEPAGE}</div>
<div class='event_header'>#_LINKEDNAME</div><a href="#_EVENTPAGEURL"><img src="#_ATT{thumb}" alt="Event Thumb" /></a>
<div class="event_details">
<p class="excerpt">
#_ATT{excerpt}
</p>
<p class="readmore">
<a href="#_EVENTPAGEURL">Continue Reading...</a>
</p>
</div>
</li>Now, all of the functions/attributes included in that template work perfectly fine, except for the HOMEPAGE one. I’ve no idea why. Thing is, I can’t find where these custom attributes are configured in the code. If I could, then I’d be able to read through it and hopefully find a solution.
Thu 2 Feb 2012 at 09:14 #49337FrankyKeymasterDid you read this: http://www.e-dynamics.be/wordpress/?cat=29
Thu 2 Feb 2012 at 13:38 #49338AnonymousInactiveFranky, I have done that (see text in my last post). Is what I’ve done not correct? I’d appreciate if you could point out the errors.
When I’m editing an event, the HOMEPAGE attribute can be selected. Problem is that it does nothing! Selecting it doesn’t make the event appear on the homepage. I don’t know how/where to define the instruction for #_ATT{HOMEPAGE}.
Please can you tell me.
Thu 2 Feb 2012 at 22:47 #49339FrankyKeymasterCreating an attribute called HOMEPAGE doesn’t mean is shows on the homepage (where and how would it be shown?). In your case: create a event category and assign the events you want shown on the home page to that cat. Then use “[events_list category=3]” (with 3 being the category id of your choice) in a post that’s always shown on the homepage.
-
AuthorPosts
- The forum ‘How do I …’ is closed to new topics and replies.