Notice: Trying to get property of non-object in
add_action('init', 'master_post');
function master_post(){
register_post_type('master', array(
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'taxonomies' => array('post_tag' , 'master_tag'),
'menu_position' => null,
'supports' => array('title','editor','author','thumbnail','excerpt')
) );
}
<?php
$tags = get_terms( array(
'taxonomy' => array( 'master_tag' ), // название таксономии с WP 4.5
) );
foreach( $tags as $tag ):
$posts = get_posts(array(
'numberposts' => 1000,
'orderby' => 'date',
'order' => 'DESC',
'post_type' => 'masters',
) )
?>
<h2> <?= $tag->name; ?> </h2>
<?php
foreach( $posts as $post ):
setup_postdata( $post );
?>
<article>
<h3> <?php the_title(); ?> </h3>
......
</article>
<?php
endforeach;
wp_reset_postdata();
endforeach;
?>