Chú ý: Taxonomy và post type không bao giờ được trùng nhau :( xem ảnh:
// ===========
add_action('init', 'my_realisaties_taxonomy', 30);
function my_realisaties_taxonomy() {
$labels = array(
'name' => _x('Realisaties', 'taxonomy general name'),
'singular_name' => _x('Realisatie', 'taxonomy singular name'),
'search_items' => __('Search Realisaties'),
'all_items' => __('All Realisaties'),
'parent_item' => __('Parent Realisatie'),
'parent_item_colon' => __('Parent Realisatie:'),
'edit_item' => __('Edit Realisatie'),
'update_item' => __('Update Realisatie'),
'add_new_item' => __('Add New Realisatie'),
'new_item_name' => __('New Genre Realisatie'),
'menu_name' => __('Realisatie Taxonomy'),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array('slug' => 'realisaties'),
'show_in_rest' => true,
'rest_base' => 'realisatiesabc',
);
register_taxonomy('realisatiesabc', array('realisaties'), $args);
flush_rewrite_rules(true);
}
C:\xampp\htdocs\wordpress1\wp-content\themes\twentytwentyone\taxonomy-realisatiesabc.php
<?php
/**
* The template for displaying archive pages
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package WordPress
* @subpackage Twenty_Twenty_One
* @since Twenty Twenty-One 1.0
*/
get_header();
?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : ?>
<?php the_post(); ?>
<?php get_template_part( 'template-parts/content/content', get_theme_mod( 'display_excerpt_or_full_post', 'excerpt' ) ); ?>
<?php endwhile; ?>
<?php twenty_twenty_one_the_posts_navigation(); ?>
<?php else : ?>
<?php get_template_part( 'template-parts/content/content-none' ); ?>
<?php endif; ?>
<?php get_footer(); ?>
C:\xampp\htdocs\wordpress1\wp-content\themes\twentytwentyone\single-realisaties.php
<?php
/**
* The template for displaying all single posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package WordPress
* @subpackage Twenty_Twenty_One
* @since Twenty Twenty-One 1.0
*/
get_header();
$elementor_page = get_post_meta( get_the_ID(), '_elementor_edit_mode', true );
if ($elementor_page ) {
echo "Yes";
}else {
echo "No";
}
/* Start the Loop */
while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content/content-single' );
endwhile; // End of the loop.
get_footer();