Hi nigel.
from here :https://toolset.com/forums/topic/tag-widget-current-post-type/
i thought the issue is solved as i just need to load the view inside widget , but i was wrong,
this is my current tag widget output , its not detecting the post type , its displaying all post types.
ive set the filter
Taxonomy filter : Select posts with taxonomy: Blog Categories the same as the page where this View is shown.
the code is very straight forward
[wpv-if evaluate="'[wpv-post-taxonomy type="blog-tag" format="slug"]' != '' "]
<div class="article_meta_tag">
<i class="fal fa-tags"></i> [wpv-post-taxonomy type="blog-tag" separator=""]
</div>
[/wpv-if]
what could be the issue pls, thanks.
Hi,
I assume we are talking about the widget "TAGS" of this page:
hidden link
If it is wordpress built-in "Tag cloud" widget, It is expected result: it will output all terms in taxonomy "Tag".
And the parameter "post_type" of filter hook widget_tag_cloud_args won't work in your case, that parameter is for return a tag link with URL parameter "post_type=my-cpt-slug", see wordpress document:
https://developer.wordpress.org/reference/functions/wp_tag_cloud/#source
line 691:
$link = get_edit_term_link( $tag->term_id, $tag->taxonomy, $args['post_type'] );
In your case, it needs custom codes, I suggest you setup your own custom shortcode, query terms only belongs to current post type, and display this shortcode in a text widget, see similar thread:
https://wordpress.stackexchange.com/questions/118861/getting-taxonomy-terms-used-by-custom-post-type
For setup shortcode, please check this document:
https://developer.wordpress.org/reference/functions/add_shortcode/
Sorry luo i didnt post the page issue , its this hidden link .
its a widget views -
Thanks for the details, the URL you mentioned above seems to be a term "foods" archive page.
I can see the view's result is "No items found".
I assume you are going to display posts of specific custom post type.
If it is, please try these:
1) Create a wordpress archive with Views plugin:
https://toolset.com/documentation/user-guides/creating-wordpress-custom-post-archives/
2) in section "Loops Selection", choose option "Categories", click "Edit" button, then you can specific the custom post types as you want, see screenshot post-type.JPG
totally wrong thing youre looking at.
my issue is the WIDGET on the sidebar. Nowhere i mention "archive ".
1. the widget tag is displaying 3 loops of the codes, not sure why.
Do i need to create view for each post type using filter and load into widget-wp view ?
or some adjustment needed to detect the cpt ?
Is it wordpress built-in "Tag cloud" widget?
If it is, please check my first answer:
https://toolset.com/forums/topic/view-tag-not-filtering-detecting-current-post-type/#post-1132547
You might need to consider custom codes, please let me know if you need assistance to setup the custom shortcode. thanks
No its not, its toolset widget.
i realise my mistake too. its not auto detecting the taxonomies. not custom post type. post type is main : blog.
update : somehow its displaying logically now. but the issue that remain is double loop repeating of the view.
pls let me know if you still unclear ill try to explain further.
How do you setup the view? please provide your website credentials in below private message box
Please have a look at your view "Blog Tag View", it is a post view, query posts of post type "RISE Blogs", and display the terms assigned to each post:
[wpv-post-taxonomy type="rise-blog-tag" separator=""]
Since there are two posts in the result, so it is expected result:
double loop repeating of the view
There isn't such kind of built-in feature, you will need to consider custom codes.
Hi, do you mean the view will loop depending on number of post of the post type blog ?
is there something wrong with my filter :
Select posts with taxonomy: Blog Categories the same as the page where this View is shown
or should i set to taxonomies view instead ? if no, How do i stop this ?
Luo, is there any other way to achive this ? Pls share. thanks
Q1) do you mean the view will loop depending on number of post of the post type blog ?
Yes, as I mentioned above, since there are two items in the result, so view's loop will be triggered twice, it will conduct other problem: duplicated term links, for example,
Post 1 with term A + term B
Post 2 with term B + term C
You post view will output "term B" twice.
Q2) or should i set to taxonomies view instead ?
The taxonomy view won't work in your case, as I mentioned above, there isn't such kind of built-in feature within Views plugin
Q3) is there any other way to achive this ?
It needs custom codes, I have shared a link in my first answer:
Getting taxonomy terms used by custom post type
https://wordpress.stackexchange.com/questions/118861/getting-taxonomy-terms-used-by-custom-post-type
But your case is much complicated than above example, I suggest you check it with our Toolset contractors:
https://toolset.com/contractors/
Hi, any update on this ? hope to close this ticket soon.