WordPress.org

Ready to get started?Download WordPress

Forums

Events Maker
[resolved] Display events with regular posts (5 posts)

  1. design_studio
    Member
    Posted 10 months ago #

    Hello. First of all - Events Maker looks great and easier to use than other similar plugins. I am trying to find a way to display the events along with the regular posts on the main page but no luck so far. Is there an easy way to do that or for example to replace the standard WordPress front blog page with events only instead of posts. Working on a local installation so cannot provide link for now.
    Thank you in advance.

    http://wordpress.org/plugins/events-maker/

  2. dFactory
    Member
    Plugin Author

    Posted 10 months ago #

    You can do that in number of ways. For example create a page template where you query 2 post types - post & event (http://codex.wordpress.org/Class_Reference/WP_Query). Or you could use the pre_get_posts() action to alter the front-page query to include event post type also (http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts)

    But you will face one problem: events have some additional query parameters as described in our doc (http://www.dfactory.eu/docs/events-maker-plugin/wp_query/). So you won't be able to use those to query events and posts at the same time. In any other case, there should be no problem with that.

    It would be easier to query just events instead of posts in your main query. You'd only need to use pre_get_posts() action and modify the query parameters to use event post type only. Then you could also use additional events parameters to modify your display (like ordering, number of events to display, start / end dates - anything you want).

  3. design_studio
    Member
    Posted 10 months ago #

    Thank you for your detailed explanation.
    So far I tried the pre_get_posts() action and it looks like it is what I am after so far. Below is the code I use in my functions.php file:

    add_filter( 'pre_get_posts', 'my_get_posts' );
    function my_get_posts( $query ) {
    	if ( is_home() && $query->is_main_query())
    		$query->set( 'post_type', array( 'post', 'event' ) );
    	return $query;
    }

    I might try your final suggestion as well - to query just events instead of posts in the main query.

    Thanks for your help one more time.

  4. m3ink4mpf
    Member
    Posted 10 months ago #

    i have the same problem with you, and i already did same as you do. thank you for the solution. but i have another question, how to change the footer of post, i mean the event already shown up in the front page, but the footer of event still using post style which there are date/time, author, posted in (post category), and comment. i wanna change it to use the information that event has such as ticket, organizer, event date, etc. same that it's displayed in single event page. what file should i change?

  5. dFactory
    Member
    Plugin Author

    Posted 10 months ago #

    Just look at the template files shipping with the plugin (in templates subfolder) - you'll see how it is done (for example for event start/end date, location, category display). Each part of the code is commented, so you should easily figure out what it does. Then just copy the parts of code you want and paste into appropriate theme files.

Reply

You must log in to post.

About this Plugin

About this Topic