WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] How to get posts from one category? (4 posts)

  1. loauc
    Member
    Posted 1 year ago #

    Hi,

    I'm trying to build a custom loop for retrieving 8 events from the category 133:

    $args = array( 'post_type' => 'event', 'posts_per_page' => 8, 'category' => 133, );

    But if I change 133 for the category slug 'highlights' or if I leave it blank I get the full list of posts, not only the posts in category 133.

    What I'm doing wrong?

    Thanks

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

  2. agelonwl
    Member
    Posted 1 year ago #

    Hi,

    have you tried something like

    $EM_Events = EM_Events::get( array('scope'=>'future','category'=>133) );
    foreach ( $EM_Events as $EM_Event ) {
     echo $EM_Event->output("#_EVENTNAME");
    }
  3. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    i think it's because you're searching 'category' whereas we have a custom taxonomy, not post categories

  4. loauc
    Member
    Posted 1 year ago #

    Thanks,

    I did a loop with the following query:

    $args = array(
    	'post_type' => 'event',
    	'event-categories' => 'highlights',
    	'order' => 'DESC',
    	'posts_per_page' => 9,
    	'orderby' => 'event_start_date',
    	);
    $loop = new WP_Query( $args );

    It's working great. Thanks.

    Felix

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags