Answer the question
In order to leave comments, you need to log in
How to display the content of the block that was clicked?
In general, I have a page with cards, they are created through acf repeater, by clicking on a card a page should open on which the elements for this card that is clicked should be displayed. They are also created via acf. Now the contents of all cards are displayed.
Answer the question
In order to leave comments, you need to log in
I'll try to paint, because going the path of least resistance is not entirely correct.
We create a new record type documents, change the x_theme text domain to our own. read:
https://wp-kama.ru/function/register_post_type
// Register Custom Post Type
function custom_post_type() {
$labels = array(
'name' => _x( 'Documents', 'Post Type General Name', 'x_theme' ),
'singular_name' => _x( 'Document', 'Post Type Singular Name', 'x_theme' ),
'menu_name' => __( 'Documents', 'x_theme' ),
'name_admin_bar' => __( 'Documents', 'x_theme' ),
'archives' => __( 'Documents Archives', 'x_theme' ),
'attributes' => __( 'Item Attributes', 'x_theme' ),
'parent_item_colon' => __( 'Parent Item:', 'x_theme' ),
'all_items' => __( 'All Items', 'x_theme' ),
'add_new_item' => __( 'Add New Item', 'x_theme' ),
'add_new' => __( 'Add New', 'x_theme' ),
'new_item' => __( 'New Item', 'x_theme' ),
'edit_item' => __( 'Edit Item', 'x_theme' ),
'update_item' => __( 'Update Item', 'x_theme' ),
'view_item' => __( 'View Item', 'x_theme' ),
'view_items' => __( 'View Items', 'x_theme' ),
'search_items' => __( 'Search Item', 'x_theme' ),
'not_found' => __( 'Not found', 'x_theme' ),
'not_found_in_trash' => __( 'Not found in Trash', 'x_theme' ),
'featured_image' => __( 'Featured Image', 'x_theme' ),
'set_featured_image' => __( 'Set featured image', 'x_theme' ),
'remove_featured_image' => __( 'Remove featured image', 'x_theme' ),
'use_featured_image' => __( 'Use as featured image', 'x_theme' ),
'insert_into_item' => __( 'Insert into item', 'x_theme' ),
'uploaded_to_this_item' => __( 'Uploaded to this item', 'x_theme' ),
'items_list' => __( 'Items list', 'x_theme' ),
'items_list_navigation' => __( 'Items list navigation', 'x_theme' ),
'filter_items_list' => __( 'Filter items list', 'x_theme' ),
);
$args = array(
'label' => __( 'Documents', 'x_theme' ),
'description' => __( 'Post Type Description', 'x_theme' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'revisions', 'custom-fields', 'page-attributes', 'post-formats' ),
'taxonomies' => array( 'documents_cat', 'documents_tag' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 25,
'menu_icon' => 'dashicons-text-page',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'show_in_rest' => false,
);
register_post_type( 'documents', $args );
}
add_action( 'init', 'custom_post_type', 0 );
/*
Template Name: Documents page
Template Post Type: documents
*/
<?php
$_posts = new WP_Query( array(
'post_type' => 'documents',
'posts_per_page' => -1,
));
?>
<?php if( $_posts->have_posts() ) : ?>
<div class="dicuments">
<?php while ( $_posts->have_posts() ) : $_posts->the_post(); ?>
// тут получаем произвольные поля
// тут вывод карточки включая стандартные теги и произвольные поля
<div class="document">
<h3><?php the_title() ?></h3>
<?php if ( has_post_thumbnail() ) : ?>
<div class="img-wrapper">
<?php the_post_thumbnail() ?>
</div>
<?php endif; ?>
<?php the_excerpt() ?>
<a href="<?php the_permalink() ?>">readmore</a>
</div>
<?php endwhile; ?>
</div>
<?php endif; wp_reset_postdata(); ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question