problem with association fields
-
hi,
i use carbon fields for my project and i want to put a assocaition field. in my back office, the association field works but in my front office i have got some problems for use all the datas.
in my exmaple i want take a terms values and the post of custom post type. with my code i can take the terms with the ID but i cannot take the post. My code is here :
//start by fetching the terms for the catalogue taxonomy $terms = get_terms( 'catalogue', array( 'orderby' => 'portique-antivol', 'order' => 'DESC', 'hide_empty' => 0, ) ); //variables for carbon fields association $id = get_the_ID(); $name = 'crb_association'; //array of carbon fields association $arraySols = carbon_get_post_meta($id, $name, 'association'); //check arraySols with a foreach : i take a term ID... foreach ($arraySols as $arraySol) { if( $arraySol['type'] == 'term' ){ $idTerm = $arraySol['id']; $terms = get_terms( 'catalogue', array( 'order' => 'DESC', 'hide_empty' => 0, 'include' => $idTerm ); foreach ($terms as $term) { //Images of my custom category $image = wp_get_attachment_image_src( carbon_get_term_meta( $term->term_id, 'crb_thumb' ), array( 381, 286 ) ); echo '<div class="global-solutions">'; echo '<img src="' . $image[0] . '" alt="solutions" />'; echo '<div class="desc-solutions">'; // Define the query $args = array( 'post_type' => 'solutions', 'catalogue' => $term->slug ); $querySolutions = new WP_Query( $args ); // output the term name in a heading tag echo '<h2>' . $term->name . '</h2>'; echo '<ul>'; // Start the Loop while ( $querySolutions->have_posts() ) : $querySolutions->the_post(); echo '<li class="solutions-listing" >'; echo '<a href="'. get_permalink() .'">'; echo the_title(); echo '</a>'; echo '</li>'; endwhile; echo '</ul>'; // use reset postdata to restore orginal query wp_reset_postdata(); echo '</div>'; echo '</div>'; } } }
with this code i can take a term of this association fields but i can’t take the post…
whats the procedure for take the post of the association fields?
thanks so lot
doogie1
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘problem with association fields’ is closed to new replies.