• Resolved mencmi

    (@mencmi)


    Hi!

    I have a small problem. How I can list also custom post types on main page? Can you specify which part of code should I edit to do this? I have done something similar for mailing subscription where I use this code in functions.php:

    function my_post_types($types) {
    $types[] = ‘event’;
    return $types;
    }

    I want to list post type same post type “event” from events manager pulgin also on the main page…

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi mencmi. In this thread the OP mentions that they “found php to load CP to home page”. You might inquire on that thread to see if they can share how they did it.

    Thread Starter mencmi

    (@mencmi)

    Hi, thank you. I solve it.. just a litle bit of coding added to functions.php

    add_action( ‘pre_get_posts’, ‘add_my_post_types_to_query’ );
    function add_my_post_types_to_query( $query ) {
    if ( is_home() && $query->is_main_query() )
    $query->set( ‘post_type’, array( ‘post’,’event’ ) );
    return $query;
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom post type listing on main page’ is closed to new replies.