• I have a function that pulls in a custom post_type (events) and shows the two upcoming events. It works fine when I pull in the function in a post or page’s sidebar. When I use it on the home page (the one place I need it work at) – it doesn’t work correctly.

    <?php
    	$todaysDate = date('Y/m/d');
    	$event_widget_query = new WP_Query('post_type=events&posts_per_page=2&post_status=publish&meta_key=event_date&meta_compare=>=&meta_value=' . $todaysDate . '&orderby=meta_value&order=ASC');
    ?>

    If I simplify it on the homepage:

    <?php
    	$todaysDate = date('Y/m/d');
    	$event_widget_query = new WP_Query('post_type=events&posts_per_page=2');
    ?>

    It just pulls in the two most recent posts – not the two most recent events. What can I do so that this function works on the home page? Is it a multiple loop issue? I’ve tried rewind_posts and wp_reset_query.

  • The topic ‘Function works everywhere except home page’ is closed to new replies.