display & link taxonomies on single-*.php – Piklist Support https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/feed/ Tue, 08 Feb 2022 20:58:48 +0000 https://bbpress.org/?v=2.6.6 en-US https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3188 <![CDATA[display & link taxonomies on single-*.php]]> https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3188 Sat, 17 Jan 2015 21:58:59 +0000 Jan Gruchow Hi
i set up a custom post type “product” and a custom taxonomie “product-color”.

Now i want to display the active colors on the single-product.php an link to the color-archive-page. It should be like tags an categories are linked on the standard posts on most templates.

Can anyone tell me, what code i have to put into my theme?

Thx
Jan

]]>
https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3189 <![CDATA[Reply To: display & link taxonomies on single-*.php]]> https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3189 Sun, 18 Jan 2015 00:06:21 +0000 Steve Welcome to the Piklist Community!

I think you want to use wp_get_object_terms()

The example on the codex page looks like it will do what you want.

Let us know if this works for you.

]]>
https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3190 <![CDATA[Reply To: display & link taxonomies on single-*.php]]> https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3190 Sun, 18 Jan 2015 11:18:40 +0000 Jan Gruchow Hi

perfekt, that was what i was looking for.

For interested readers, here is the full snipped i use:

$product_colors = wp_get_object_terms( $post->ID,  'product_color' );
						if ( ! empty( $product_colors ) ) {
							if ( ! is_wp_error( $product_colors ) ) {
								echo '<ul>';
									foreach( $product_colors as $term ) {
										echo '<li><a href="' . get_term_link( $term->slug, 'product_color' ) . '">' . $term->name . '</a></li>'; 
									}
								echo '</ul>';
							}
						}
]]>
https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3191 <![CDATA[Reply To: display & link taxonomies on single-*.php]]> https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3191 Sun, 18 Jan 2015 12:25:31 +0000 Steve Glad it worked for you! One of the best parts of Piklist is that, in most cases, you can use standard WordPress functions to work with your data.

]]>
https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3192 <![CDATA[Reply To: display & link taxonomies on single-*.php]]> https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3192 Sun, 18 Jan 2015 18:47:40 +0000 Jan Gruchow that’s true.

since i’am not good in programming, it is hard for me to find the right things in the WP-codex-reference, especially if i don’t even know what to look for.

]]>
https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3195 <![CDATA[Reply To: display & link taxonomies on single-*.php]]> https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3195 Wed, 21 Jan 2015 07:20:59 +0000 Jan Gruchow I have one mor question: As i wrote in my example, i use
<a href="' . get_term_link( $term->slug, 'product_color' ) . '">' . $term->name . '</a>
to generate my links back to the archive. these links look like this:
domain.com/?color=blue

My problem ist, that i want to use the product-archive-template. The links should look like domain.com/products/?color=blue

is there a easy way to change the links, so the custom-post-type-slug is added? I couldn’t find anything in the wp-codex.

]]>
https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3198 <![CDATA[Reply To: display & link taxonomies on single-*.php]]> https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3198 Wed, 21 Jan 2015 19:21:27 +0000 Steve @jan– It looks like you left off a parameter when you registered the taxonomy. Try adding:

,'rewrite' => array( 
  'slug' => 'products' 
)

Look in piklist/add-ons/piklist-demos/piklist-demos.php for an example of how we registered the piklist_demo_type taxonomy.

]]>
https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3284 <![CDATA[Reply To: display & link taxonomies on single-*.php]]> https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3284 Mon, 09 Feb 2015 09:15:04 +0000 Jan Gruchow Hi

i have set the rewrite slug. But this is for the singe-product-url, not?

I have set:


,'has_archive' => 'products'
		,'rewrite' => array(
		  'slug' => 'product'
		)

That way, URLs like:
domain.com/products/a-product-list
domain.com/product/a-single-product
and it works fine.

I only dont know, how i can get the get_term_link-function to link to the specific product-archive and not just the generic archive…
The Link:
domain.com/?color=blue
is also displaying the right product, but i uses the default archive-template. I that to use my specific archive-product-template so i need them to link to domain.com/PRODUCTS/?color=blue

]]>
https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3287 <![CDATA[Reply To: display & link taxonomies on single-*.php]]> https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3287 Mon, 09 Feb 2015 18:40:43 +0000 Steve @Jan– Taxonomies also use the rewrite parameter.

]]>
https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3289 <![CDATA[Reply To: display & link taxonomies on single-*.php]]> https://piklist.com/support/topic/display-link-taxonomies-on-singel-php/#post-3289 Mon, 09 Feb 2015 19:32:53 +0000 Jan Gruchow Thanks for the hint, but i think it’s still not the right solution for me.

i have set the rewrite for the taxonomies to “false”, because i want my categories with URL-Parameters.
If i use the the slug and/or with-front for the rewrite, i automatically active the pretty links (what i don’t want). And there is also no way to set the “/products/”.

Or am i missing something?

]]>