• Resolved hahvensa

    (@hahvensa)


    Is it possible to add wordpress comment count to event-list?

    I have a single-event.php template that supports comments like usual wordpress articles, but i’m not sure how to show them in the event-list page. I have done the layout for event-list in settings formats/layouts and I guess there’s no placeholder for wordpress comments.

    Should I do a specific page template instead?

    http://wordpress.org/extend/plugins/events-manager/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    we don’t have any placeholders for that. you’d need to use php to either create a placeholder that does this or use PHP to display your events and show the comment count.

    you’d use the wp method to get comment counts for the post id for that event.

    Thread Starter hahvensa

    (@hahvensa)

    ok, sorry i’m new to this plugin. Can I get events like this http://pastebin.com/hDMfVu8N
    and add wp count comments to this array?
    What is the right way to get post id for the events?

    Plugin Support angelo_nwl

    (@angelo_nwl)

    though I haven’t tried it yet, I think you can try to combine this http://codex.wordpress.org/Function_Reference/wp_count_comments with your pastebin link however try to used EM_Events::get() instead

    e.g.

    if (class_exists('EM_Events')) {
    $events = EM_Events::get(array('scope' => 'future'));
    
    foreach($events as $event) {
      echo $event->output('#_EVENTNAME')." - ".wp_count_comments($event->output('#_EVENTPOSTID'));
    }
    
    }

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    better yet,

    $event->post_id

    or

    $event->ID

    Thread Starter hahvensa

    (@hahvensa)

    Hmm, tried but i get an error “Object of class stdClass could not be converted to string ” so I guess I’m doing something wrong here and getting an object instead of string??

    I also tried $event->post_id and $event->ID but I’m not getting it right. I’m able to output the events without wp_count_comments so something wrong there.

    Could you post the code you’re now using? Thanks.

    Thread Starter hahvensa

    (@hahvensa)

    Thanks for help. I used the code above and replaced the
    ($event -> output(‘#_EVENTPOSTID’));
    with
    ($event -> post_id));

    I’m getting something with this but it’s not right
    http://pastebin.com/CLTXb3Tw

    Plugin Support angelo_nwl

    (@angelo_nwl)

    can I know what are you getting?

    Thread Starter hahvensa

    (@hahvensa)

    oh, i’m getting it almost right with the pastebin code 🙂 the layout/formatting is just messed up

    First Event name,
    First Event excerpt

    – First event comment number
    Second event name
    Second event excerpt

    – Second event comment number
    Third event name etc.

    If you can post the format / order you actually want, I should be able to tell you how to switch it around.

    Plugin Support angelo_nwl

    (@angelo_nwl)

    you can change the formatting on this line

    echo $event->output('#_EVENTNAME,#_EVENTEXCERPT').' - '.$comments_count->total_comments;

    e.g.

    echo $event->output(array('format'=>'#_EVENTNAME, #_EVENTEXCERPT -'.$comments_count->total_comments,'format_header
    '=>'<ul>','format_footer'=>'</ul>'));

    Thread Starter hahvensa

    (@hahvensa)

    Thanks for help! I didin’t manage to do it like that but I got the right formatting like this

    <?php if (class_exists('EM_Events')) {
    $events = EM_Events::get(array('scope' => 'all' ));
    
    foreach($events as $event) {
    $comments_count = wp_count_comments($event->post_id);
    echo '<div class="post">';
    echo $event->output(
    '<div class="post-meta">{is_past}<span class="silver" href="">Mennyt</span>{/is_past}
    {is_current}<span class="green" href="">Käynnissä</span>{/is_current}
    {is_future}<span class="green" href="">Käynnissä</span>{/is_future} #_EVENTDATES</div>
    <div class="post-entry">
    <div class="post-thumbnail"><a href="#_EVENTURL">#_EVENTIMAGE{100, 100}</a></div>
    <h4><a href="#_EVENTURL">#_EVENTNAME</a></h4>
    <p>#_EVENTEXCERPT</p><span class="tags">#_EVENTTAGS</span></div>').
    '<div class="comments">'.$comments_count->total_comments;'</div>';
    echo '</div>';
    }
    
    }
    ?>

    Thread Starter hahvensa

    (@hahvensa)

    oh, sorry about the ugly formatting, the last lines should be

    '<div class="comments">'.$comments_count->total_comments;
    echo '</div></div>';
    }
    
    }
    ?>

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Comment count on event-list’ is closed to new replies.