There are hundreds of artists under the above taxonomy, so I decided to create a widget area on the taxonomy-artists.php template to put the Display Posts query parameters in a Custom HTML widget for each archive’s use.
This is my code:
<div id="track-and-album-rev" class="track-and-album-revs">
<h1>Album reviews</h1>
[display-posts taxonomy="artists" tax_term="current" tag="album-reviews" tax_relation="AND" image_size="thumbnail" include_author="true" include_date="true" date_format="F j, Y" orderby="date" wrapper="div" wrapper_class="display-posts-listing grid" meta_key="_thumbnail_id]
<!-- /wp:shortcode -->
<h1>Track reviews</h1>
[display-posts taxonomy="artists" tax_term="current" tag="track-reviews" tax_relation="AND" image_size="thumbnail" include_author="true" include_date="true" date_format="F j, Y" orderby="date" wrapper="div" wrapper_class="display-posts-listing grid" meta_key="_thumbnail_id]
<!-- /wp:shortcode --></div>
However, this does not query only the posts with the current tax_term (e.g., /artists/black-hibiscus) that also have the given tag. Instead, it outputs all posts with the tag “album-reviews” and “track-reviews“, disregarding the taxonomy and tax_term rules.
Any advice is greatly appreciated.
]]>Thank you for your great support!
]]>Im struggling with taxonomies and taxonomy terms not returning what im expecting.
this is my code:
<?php if( get_row_layout() == 'post_grid' ):?>
<div class="post-grid">
<style>
.post-grid {
display: grid; gap: 2%; grid-template-columns: repeat(<?php the_sub_field('post_per_row'); ?>,minmax(0,1fr));}.single-item a img {width: 100%; height: <?php the_sub_field('post_image_height')?>; object-fit: cover;}</style>
<?php
$PostTypeChoice = get_sub_field('post_type_choice');
$PostsPerPage = get_sub_field('post_per_page');
$categoryTag = get_sub_field('category_tag');
$categoryTagTerm = get_sub_field('category_tag_term');
$postGridArgs = array(
'post_type' => $PostTypeChoice,
'posts_per_page' => $PostsPerPage,
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => $categoryTag,
'field' => 'name',
'terms' => $categoryTagTerm,
'operator' => 'IN'
)
)
);
$postGridItems = new WP_Query($postGridArgs);
while($postGridItems -> have_posts()): $postGridItems -> the_post();
?>
<div class="single-item">
<?php if(get_sub_field('with_image') == '1'):?><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('medium'); ?></a><?php endif;?><a href="<?php the_permalink(); ?>"><h2><?php the_title();?></h2></a><a href="<?php the_permalink(); ?>"><span>Read More..</span></a></div>
</div>
<?php endwhile; wp_reset_query(); ?>
<?php endif; ?>
Im trying to create simple customisable post grid.
So <?php echo (get_sub_field('category_tag_term'));?>
returns “New Cat, Uncategorised” exactly what i want.
BUT
echo $categoryTagTerm;
returns just the word “array” not what i want.
so if im using this $categoryTagTerm = get_sub_field('category_tag_term');
why are they not the same?
when you try loading the page linked above im just displaying what is in the variables using “echo” and “print_r”
im just so confused because the data i want is there, but its not working.
what am i doing wrong?
Help please!
]]>This only happens when I modify a taxonomy term through the EDIT screen. Creating a taxonomy term doesn’t cause the problem. Editing the description or parent term from the EDIT screen causes the problem.
Has anyone had a similar issue? I don’t even know where to start to debug this…
Any help would be greatly appreciated.
]]>is it possible with Taxonomy Terms to be able to create new taxonomies ?
Best Regards
Nexus
is there any solution to convert existing Taxonomy to Taxonomy Terms without lost all data?
]]>I am building a site which will have quite many images. Each image has multiple hierarchical taxonomies and some custom fields. Some images (but not all) will have a custom post built around them – the media file will become the CPT’s featured image. The CPT will share the taxonomies and custom fields with its featured image.
To save time and achieve consistency, I would like to automate it. On saving the CPT, I would like to take the terms from the featured image and save them automatically. My PHP skills are minimal, but I’m trying to learn it by reverse-engineering and adapting stuff.
I have come up with this:
function set_cpt_terms( $post_id, $post ) {
if(is_post_type('my-cpt-slug')) {
global $post;
$post_id = $post->ID;
$thumbnail_id = get_post_thumbnail_id( $post->ID );
$taxonomies = get_object_taxonomies( $thumbnail_id );
foreach ( (array) $taxonomies as $taxonomy ) {
$terms = wp_get_post_terms( $thumbnail_id, $taxonomy );
if ( !empty( $terms ) ) {
$termArr = array_map(create_function('$obj', 'return $obj->term_id;'), $terms);
$tmp = wp_set_object_terms( $post_id, $termArr, $taxonomy, true );
}
}
}
}
add_action( 'save_post', 'set_cpt_terms', 100, 2 );
`
But obviously, that doesn’t work as expected. Any ideas how to fix it?
Greetings,
Tom
I was setting up a Taxonomy Term field and I noticed that the “Default Value” does not work properly. I tried to use the name and the slug for a specific term and I can never get it to be selected by default.
I noticed the field is not mentioned in the Documentation
Is this a bug or not supported?
ACF, ACF Pro 5.2.9, ACF Extended 0.8.8
]]>I need help with a modification for woocomerce. I need to modify the shopping cart so that I can empty the products along with their variations.
I show with image what I need to do
https://i.stack.imgur.com/ln7gK.jpg
if not possible, at least remove the individual button product
]]>