Solved my issue. Just a syntax error. I added a $
var id = $("panel-connect");
should be
var id = ("panel-connect");
I solved most of this, needed to query the taxonomy directly instead of querying the post for the taxonomy.
$terms = get_terms(array(
'taxonomy' => 'cpt_series',
'hide_empty' => true,
'meta_query' => array(
array(
'key' => 'series_type',
'value' => 'main',
'compare' => 'LIKE'
),
),
));
if ( ! empty( $terms ) ) {
echo '<ul>';
foreach ( $terms as $term ) {
$image = get_field('series_graphic', 'cpt_series_' . $term->term_id . '' );
$seriesLink = get_term_link($term->term_id, $taxonomy = 'cpt_series');
$seriesGraphic = $image['url'];
?>
<li>
<a href="<?=$seriesLink?>">
<img src="<?=$seriesGraphic?>" />
<?=$term->name?>
</a>
</li>
<?php
}
echo '</ul>';
} else {
echo 'No term found.';
}
Only thing outstanding is how to sort them by the date.
Current setup:
I have a custom post type messages
every message has a taxonomy attached cpt_series
the taxonomy series has custom fields of series_graphic, series_type, date_start, date_end
(graphic is an img, type is a dropdown, date’s are both d/m/y)
I’m attempting to build a query that will return the all of the terms of the taxonomy ‘series’ with the type ‘main’ and sort them by the date_start
this was my attempt – it doesn’t work
trying to learn more about WordPress query
$args = array(
'post_type' => 'messages',
'post_status' => 'publish',
//trying to query the taxonomy
'tax_query' => array(
array(
'taxonomy' => 'cpt_series',
//trying to query the custom field
'meta_query' => array(
array(
'key' => 'series_type',
'value' => 'main',
'compare' => 'IN'
)
)
)
)
);
Haven’t started tryin to figure out the sort by date yet.
Any help in this would be great, thanks.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.