Events Made Easy Forums How do I … Only show event on homepage if attribute is applied

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #43705
    Anonymous
    Inactive

    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.

    #49333
    Franky
    Keymaster

    do 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.

    #49334
    Anonymous
    Inactive

    Sorry, but I’ve no idea what you mean. My knowledge is limited when it comes to WordPress.

    #49335
    Franky
    Keymaster

    each 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.

    #49336
    Anonymous
    Inactive

    This 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.

    #49337
    Franky
    Keymaster
    #49338
    Anonymous
    Inactive

    Franky, 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.

    #49339
    Franky
    Keymaster

    Creating 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.

Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘How do I …’ is closed to new topics and replies.
Scroll to Top