Skip Navigation

[Gelöst] Archive page for custom post type created by TheEventsCalendar | #135

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

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 support ticket is created vor 2 Jahre, 6 Monate. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+00:00)

This topic contains 3 Antworten, has 2 Stimmen.

Last updated by romanB-3 vor 2 Jahre, 6 Monate.

Assisted by: Jamal.

Author
Artikel
#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: Englisch (English ) Französisch (Français )

Timezone: Africa/Casablanca (GMT+00: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: Englisch (English ) Französisch (Français )

Timezone: Africa/Casablanca (GMT+00: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!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.