1
I created a specific Post-type in functions.php:
// Meus posts types
function meus_posts_type() {
// Testemunhos
register_post_type('testemunhos',
array(
'labels' => array(
'name' => __('Testemunhos'),
'singular_name' => __('Testemunhos')
),
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-format-chat',
'supports' => array('title', 'editor', 'thumbnail', 'page-attributes'),
)
);
register_post_type('consultorias',
array(
'labels' => array(
'name' => __('Consultorias'),
'singular_name' => __('Consultorias')
),
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-clipboard',
'supports' => array('title', 'editor', 'thumbnail', 'page-attributes'),
)
);
register_post_type('treinamentos',
array(
'labels' => array(
'name' => __('Treinamentos'),
'singular_name' => __('Treinamentos')
),
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-welcome-learn-more',
'supports' => array('title', 'editor', 'thumbnail', 'page-attributes'),
)
);
register_post_type('clientes',
array(
'labels' => array(
'name' => __('Clientes'),
'singular_name' => __('Clientes')
),
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-admin-multisite',
'supports' => array('title', 'thumbnail', 'page-attributes'),
)
);
}
add_action( 'init', 'meus_posts_type' );
OK.
I made a "page-training.php" page with:
<?php
get_header();
/*
Template name: Treinamentos
*/
?>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<section class="features18 popup-btn-cards cid-rlWkB2eQKv" id="features18-y">
<div class="container">
<h2 class="mbr-section-title pb-3 align-center mbr-fonts-style display-2"><strong>WORKSHOPS E TREINAMENTOS</strong></h2>
<h3 class="mbr-section-subtitle display-5 align-center mbr-fonts-style mbr-light"><strong>GOVERNOS | EMPRESAS | ONGs (IN-COMPANY
)</strong><div>Workshops e treinamentos especializados em gestão integrada de resíduos sólidos
</div><div><br></div></h3>
<?php
if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb( '<p id="breadcrumbs">','</p>' );
}
?>
<?php query_posts( 'post_type=treinamentos' ); ?>
<?php if(have_posts()): while(have_posts()): the_post(); ?>
.......
However, when I click on the link I want, the single.php does not show the post of the post-type, it shows the 404.php.
How do I read the post-type post? Do I have to create a single-nameSingle.php? If so, what would this structure look like?
My single.php is like this:
<?php get_header();?>
<br/><br/><br/><br/><br/><br/><br/><br/>
<div class="container">
<?php
if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb( '<p id="breadcrumbs">','</p>' );
}
?>
<center>
<h1><?php single_post_title(); ?></h1>
</center>
<div class="row">
<div class="col-md-9">
<?php
if (have_posts()): the_post();
the_post_thumbnail('medium_large', array('class' => 'img-fluid'));
the_content();
endif;
?>
</div>
<div class="col-md-3">
<?php if ( is_active_sidebar('sidebar-1') ) {
dynamic_sidebar('sidebar-1');
} ?>
</div>
<!--<div class="col-md-3">
<?php //get_sidebar('personalizado') ?>
</div>-->
</div>
</div>
<?php //get_footer('personalizado'); ?>
<?php get_footer(); ?>
I edited with my 'Single.php'. The way you presented my 'Page.php' to list, I need to show the contents of what is already listed in a 'post_type' .... @daviaragao
– Ramos
I don’t understand what you said.
– DaviAragao