Answer the question
In order to leave comments, you need to log in
Carbon Fields + WP_Query. Why is information from association not displayed on non-landing pages?
There is a code for a php-enabled widget to display custom information from certain posts.
<?php
$myposts = new WP_Query( array('tax_query' => array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => 'post-format-aside', 'category_name' => 'theatre'))) );
if ( $myposts->have_posts() ) { while ( $myposts->have_posts() ) { $myposts->the_post(); ?>
<a href="<?php the_permalink(); ?>" class="title fa fa-slideshare"><?php the_title(); ?></a>
<?php
$ismore = strpos( $post->post_content, '<!--more-->' );
if ( $ismore ) :
the_content( sprintf( esc_html__( 'Read more %s ...','wp' ), '<span class="screen-reader-text">' . esc_html__( 'about ', 'wp' ) . get_the_title() . '</span>' ) );
else :
the_excerpt();
endif;
$events = carbon_get_post_meta( $post->ID, 'event_options' );
foreach ( $events as $event ) {?>
<div class="date fa fa-calendar-alt"><?php echo $event['event_date'];?> <?php echo $event['event_time'];?></div>
<?php $address = $event['event_adress']; // вот отсюда не считывает, если находишься не на целевой странице
foreach ( $address as $adres ) { ?>
<a href="" data-toggle="modal" data-target="#modalAdress<?php echo $adres['id']?>" class="adress fa fa-map-marker-alt" title="Адрес «<?php echo get_the_title($event['id']); ?>»"><?php echo get_the_title($adres['id']); ?></a>
<?php }}}} wp_reset_postdata();?>
<?php
$places = carbon_get_post_meta( $post->ID, 'event_options' );
if ( $places ) {
foreach ( $places as $place ) {
$address = $place['event_adress'];
foreach ( $address as $item ) {
?>
<div class="modal fade adress" id="modalAdress<?php echo $item['id']?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header text-center">
<h4 class="modal-title w-100 font-bold"><?php echo get_the_title($item['id']); ?></h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">x</span></button>
</div>
<div class="modal-body mx-3">
<?php echo carbon_get_post_meta($item['id'], 'venue_adress');?>
<br/><br/><iframe src="https://www.google.com/maps/embed?pb=<?php echo carbon_get_post_meta($item['id'], 'venue_location');?>" width="100%" height="80%" frameborder="0" style="border:0" allowfullscreen></iframe>
</div>
<div class="modal-footer d-flex justify-content-center"><button class="btn btn-block" data-dismiss="modal" aria-label="Close">Закрыть</button></div>
</div>
</div>
</div>
<?php }}}?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question