Skip Navigation

[Resolved] Archive page for custom post type created by TheEventsCalendar | #135

This thread is resolved. Here is a description of the problem and solution.

Problem:
The user would like to create an archive template for the Organizers and the Venues post types that are registered by
TheEventsCalendar plugin.

Solution:
The plugin registers both post types without the option to have archives. We can hook into the registering process and change the arguments of the post types. This is an example for the Venues post types(slug: tribe_venue):

add_filter( 'register_post_type_args', 'change_tec_venue_cpt', 10, 2 );
 
function change_tec_venue_cpt( $args, $post_type ){
 
    if( $post_type === 'tribe_venue' ){
        $args['has_archive'] = 'venue';
        $args['rewrite'] = array(
            'slug' => 'venues',
            'with_front' => true,
        );
    }
    return $args;
}

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 3 replies, has 2 voices.

Last updated by romanB-3 1 month ago.

Assigned support staff: Jamal.

Author
Posts
#2166373

Hi,
I followed this ticket https://toolset.com/forums/topic/archive-page-for-custom-post-type-created-by-another-plugin/ and have exact same issue: "I am now able to see 'organizers', but 'Venues' are still not showing. I've reversed the order as well with 'venues' at first' that made no difference."
Thanks.

#2166607

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello and thank you for contacting Toolset support.

Can I access your website and check the custom code that you are using? Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#2167777

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Thank you for the credentials. I was able to fix the issue by changing the post types arguments using custom code instead of registering it. I commented this line:

// add_action( 'init', 'update_tribe_venue_post_type');  

And I corrected the following lines:

add_filter( 'register_post_type_args', 'change_tec_venue_cpt', 10, 2 );

function change_tec_venue_cpt( $args, $post_type ){

	if( $post_type === 'tribe_venue' ){
		$args['has_archive'] = 'venue';
		$args['rewrite'] = array(
			'slug' => 'venues',
			'with_front' => true,
		);
	}
	return $args;
}

And that was enough to make the venues appear in Toolset archives hidden link

I'll let you do the same for organizers because I don't think the best solution is to register the post type twice(from the theme and from the plugin).

I hope this helps. Let me know if you have any questions.

#2167785

My issue is resolved now. Thank you!