Skip Navigation

[Gelöst] One taxonomies , multiple post types

This support ticket is created vor 6 Jahren. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Dieses Thema enthält 14 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Akhil vor 6 Jahren.

Assistiert von: Nigel.

Author
Artikel
#1131446

Hi nigel. good day .this is a big issue for me

Pls check this link : versteckter Link

its outputting all the custom post types rather then one as suppose to , i couldnt find any filter for this at the wordpress archive. is this how its suppose to ?

if i apply search filter i get this :
versteckter Link

usually whats the method to tackle this issue , i am sure taxonomy able to share acrosss multiple post types [ base on the taxomony options given ]

Thanks

#1131447

i am guessing i need to create taxonomies archive page ?

#1131900

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

Hi Dee

That link is the taxonomy archive for the "d01-raffles-place..." term of the district taxonomy.

It will show all posts with that term, irrespective of type.

If you want to customise that, creating a custom archive at Toolset > WordPress archives won't actually help, because it will follow the default behaviour.

You need to use pre_get_posts to modify the relevant query.

Here is an example you can use, where you would have to edit the taxonomy slug, and the post type.

/**
 * Limit taxonomy archive to a particular post type
 */
function tssupp_custom_archive($query) {

	if (is_tax('sector')) {

		$query->set('post_type', array('listing'));
	}
}
add_action('pre_get_posts', 'tssupp_custom_archive');
#1131904

Hi nigel.

The code seems display multiple post type for the taxonomies. Yes its working but what i need is link like this to function:

versteckter Link
versteckter Link

how can i approach this pls. many thanks !

#1131922

Btw ive addded multimple post type in the array. so the taxonomies is usable in those post.

#1131964

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

Sorry, I don't understand what the issue is, could you explain more fully please.

#1131976

Ok.

i have custom tax [district, state, country] , 3 custom post types will be using the same taxonomy.

for tax archive , its generating default url that output 3+ other custom post types, which is :
versteckter Link

the fn that you gave able to few cpt to these taxonimes, its fine, but what i need is each of these taxonomy on its on custom post types,

desired urls area:

versteckter Link
versteckter Link

versteckter Link
versteckter Link

etc,

How do i approach this ? i have no clue even to start ! Thanks !

#1132019

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

"its generating default url"

That's back to front when it comes to thinking about archives.

WordPress tries to interpret the URL to work out what you want to display.

Enter a URL in the browser and WordPress will parse it and compare it to your permalink structure to determine what page we are on.

Yes, for individual posts when you save a post it will save it with a url that corresponds to your permalinks ("generate the url").

Looking at your sample URLs I'm not sure what is a post type, what is a taxonomy, what is a term, but it looks like you are wanting to work with custom rewrite rules again.

I don't really have anything to add to what I've written before, that Toolset provides the UI for adding rewrite options when registering custom post types and custom taxonomies, but doesn't have any opinion about what those should be or how to customise them beyond the basics available in the UI.

When it comes to displaying content, it will just display whatever WordPress thinks it should be displaying, i.e. if WordPress interprets your rewrite rules to mean that we are on a particular taxonomy term page, then that is what Toolset will display at that page.

Those sample URLs look like a single post could have one of many possible URLs, but a single post should have a unique URL.

#1132025

'Looking at your sample URLs I'm not sure what is a post type, what is a taxonomy, what is a term, but it looks like you are wanting to work with custom rewrite rules again.'

custom post type = landed-house, dir
tax : district,

listings, is just a layout page with few views,

#1132026

from the discussion it seems like its not straighforward to use one taxonomies to multiple cpt,

i have the plugins to create permalinks, works fine., but not for this case when taxonomies is used in many cpt.

in this case the best way is to create taxonomies for each cpt ? like landed-house-district, office-district , dir-district, etc ?
performance wise i am guessing there is setback since its a tax rather then just layout ? 🙂

#1132640

Hi, i hope to close this ticket soon. thanks.

#1132683

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

It's not a problem to assign a taxonomy to multiple post types generally, the issue arises only because of the custom rewrite rules you want to adopt, which mix the CPT and taxonomy slugs, and so lead to potential ambiguity.

I don't see how this would have any impact on performance if you were to go ahead and create separate taxonomies for each CPT, it just implies more work for you setting it up.

#1133222

Hi nigel , thanks. i am guessing will post relationship solve my issue ?

duplicating tax for 6 post types is a big job cause the depth involved, however this is the last resort .

#1133635

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

I've re-read this thread a couple of times to see that I understand what you are aiming for.

You are applying taxonomies to multiple post types (nothing unusual there).

You want custom permalinks for your taxonomy pages.

The structure you want looks something like

site.com/some-static-page/cpt-slug/tax-slug/term-slug/

(I'm not sure how the page slug, e.g. listings or directory, is supposed to fit into this.)

As described at the outset, a taxonomy archive will display all of the posts with the specific term assigned, irrespective of post type. We discussed some example code above that can be used to modify which post types are included in the archive.

However, it seems like what you want is to be able to include the CPT slug in the URL and then modify which type of posts are shown in the archive based upon that CPT slug included in the URL.

I'm sorry but I can't help you with that. You'll need an expert in rewrite rules to know whether it is even possible, and to implement it if it is.

This isn't an issue that is specific to Toolset in any way, you would be in the same position if you had registered the post types and taxonomies manually without using a plugin.

Which is good news inasmuch as you don't need a Toolset expert to solve this, you just need a WordPress rewrite rules expert.

I'd suggest you try asking on wordpress.stackexchange.com first, and if you can't find the answer you need there, you'll need to look at recruiting a developer to implement this particular request for you.

#1133641

Thank you for all the explanations, without this explanations, i cant barely move forward.

i just wanted to confirm if i missed antyhing on the usage of post-relationship

Now that i am clear and decided to add/duplicate the tax for each of the post types that required. url rewriting is straight forward for this case ,same as the :directly: cpt.

My issue is resolved now. Thank you!