Sauter la navigation

[Résolu] Archive page for custom post type created by TheEventsCalendar | #135

Ce fil est résolu. Voici une description du problème et la solution proposée.

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 Il y a 3 années et 9 mois. 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.

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+01:00)

Ce sujet contient 3 réponses, a 2 voix.

Dernière mise à jour par romanB-3 Il y a 3 années et 9 mois.

Assisté par: Jamal.

Auteur
Publications
#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

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

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 lien caché

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!