Pobranie kategorii z acf Taxonomy field
—
<?php $term = get_sub_field('seasonal'); ?>
<?php if( $term ): ?>
<span><?php echo $term->name; ?></span>
<?php endif; ?>
<?php $term = get_sub_field('seasonal'); ?>
<?php
// global $post;
$args = array(
'numberposts' => 6,
'category' => $term->term_id,
);
$myposts = get_posts( $args );
foreach($myposts as $post) : setup_postdata($post);
?>
<?php
if (has_post_thumbnail( get_the_ID()) ):
$image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'home-post' );
endif;
?>
<a href="<?php the_permalink(); ?>" class="post">
<figure style="background-image:url(<?php echo $image[0]; ?>)">
<figcaption>
<img src="<?php echo get_bloginfo('template_directory'); ?>/images/plus-ico.svg" alt="<?php _e('Read more', 'ZephyrPoint')?>" class="ico-more">
<h5><?php echo $term->name; ?></h5>
<div class="content-text">
<h2><?php echo limit_words(get_the_title(), '4'); ?></h2>
<p><?php echo limit_words(get_the_excerpt(), '8'); ?></p>
</div><!-- /.text -->
</figcaption>
</figure>
</a>
<?php endforeach; wp_reset_query(); ?>
—
Hope this helps and happy coding :)
Zobacz jeszcze
Pobranie nazwy, linku do strony przez ID
-- <?php echo get_the_title(332); ?> <?php echo esc_url(get_permalink(332)); ?> <a href="<?php echo esc_url( get_permalink( get_page_by_title( 'Monthly Events' ) )...