• Resolved design_studio

    (@design_studio)


    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.

    https://www.ads-software.com/plugins/events-maker/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author dFactory

    (@dfactory)

    You can do that in number of ways. For example create a page template where you query 2 post types – post & event (https://codex.www.ads-software.com/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 (https://codex.www.ads-software.com/Plugin_API/Action_Reference/pre_get_posts)

    But you will face one problem: events have some additional query parameters as described in our doc (https://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).

    Thread Starter design_studio

    (@design_studio)

    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.

    m3ink4mpf

    (@m3ink4mpf)

    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?

    Plugin Author dFactory

    (@dfactory)

    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display events with regular posts’ is closed to new replies.