Php 按类别显示自定义帖子类型
我正在创建一个名为“Blog”的CPT,我想在一个类别中显示内容,但n没有出现在我的主题中Php 按类别显示自定义帖子类型,php,wordpress,Php,Wordpress,我正在创建一个名为“Blog”的CPT,我想在一个类别中显示内容,但n没有出现在我的主题中 在这里,我在我的CPT中创建了一个条目,并分配了类别“Champioship” 现在我转到我的页面生成器,选择要显示的类别 结果:使用我的CPT创建的条目不会出现 我的CPT代码: <?php // Register Custom Post Type function blog_post_type() { $labels = array( 'name'
- 在这里,我在我的CPT中创建了一个条目,并分配了类别“Champioship”
- 现在我转到我的页面生成器,选择要显示的类别
- 结果:使用我的CPT创建的条目不会出现
<?php
// Register Custom Post Type
function blog_post_type() {
$labels = array(
'name' => _x( 'Blogs', 'Post Type General Name', 'Kingsclub' ),
'singular_name' => _x( 'Blog', 'Post Type Singular Name', 'Kingsclub' ),
'menu_name' => __( 'Blog', 'Kingsclub' ),
'name_admin_bar' => __( 'Blog', 'Kingsclub' ),
'archives' => __( 'Archivo blog', 'Kingsclub' ),
'attributes' => __( 'Atributos recetas', 'Kingsclub' ),
'parent_item_colon' => __( 'Blog padre:', 'Kingsclub' ),
'all_items' => __( 'Todas', 'Kingsclub' ),
'add_new_item' => __( 'Agregar nueva', 'Kingsclub' ),
'add_new' => __( 'Agregar', 'Kingsclub' ),
'new_item' => __( 'Nueva', 'Kingsclub' ),
'edit_item' => __( 'Editar', 'Kingsclub' ),
'update_item' => __( 'Actualizar', 'Kingsclub' ),
'view_item' => __( 'Ver blog', 'Kingsclub' ),
'view_items' => __( 'Ver blog', 'Kingsclub' ),
'search_items' => __( 'Buscar receta', 'Kingsclub' ),
'not_found' => __( 'No encontrado', 'Kingsclub' ),
'not_found_in_trash' => __( 'No encontrado en la papelera', 'Kingsclub' ),
'featured_image' => __( 'Imagen detacada', 'Kingsclub' ),
'set_featured_image' => __( 'Asignar imagen destacada', 'Kingsclub' ),
'remove_featured_image' => __( 'Remover imagen', 'Kingsclub' ),
'use_featured_image' => __( 'Usar como imagen detacada', 'Kingsclub' ),
'insert_into_item' => __( 'Insertar', 'Kingsclub' ),
'uploaded_to_this_item' => __( 'Subir', 'Kingsclub' ),
'items_list' => __( 'Lista', 'Kingsclub' ),
'items_list_navigation' => __( 'Navegación', 'Kingsclub' ),
'filter_items_list' => __( 'Fitro', 'Kingsclub' ),
);
$rewrite = array(
'slug' => 'blog',
'with_front' => true,
'pages' => true,
'feeds' => true,
);
$args = array(
'label' => __( 'Blog', 'Kingsclub' ),
'description' => __( 'Contenido de blog', 'Kingsclub' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'author', 'comments', ),
'taxonomies' => array( 'category', 'post_tag' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-format-aside',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $rewrite,
'capability_type' => 'page',
'show_in_rest' => true,
);
register_post_type( 'blog_post_type', $args );
}
add_action( 'init', 'blog_post_type');
请包括显示您希望类别显示的内容的代码,以及为什么撤消将图像添加到问题中的更改?它使我们更容易理解,而不必打开许多单独的链接。是的,没错。我已经上传了缺失代码的另一部分请包括显示您希望类别显示的内容的代码,还有,为什么要撤消将图像添加到问题中的更改?它使我们更容易理解,而不必打开许多单独的链接。是的,没错。我已经上传了缺失代码的其他部分
<article <?php post_class($blog_classes); ?>>
<?php if($image_url <> ""){?>
<figure><a href="<?php the_permalink(); ?>"><img src="<?php echo $image_url;?>" alt=""></a></figure>
<?php }?>
<div class="text">
<?php
if($px_node->var_pb_blog_view == 'blog-medium'){
$before_cat = "<ul class='post-options blog-medium-options'><li>";
$categories_list = get_the_term_list ( get_the_id(), 'category', $before_cat, ', ', '</li></ul>' );
if ( $categories_list ){
printf( __( '%1$s', 'Kingsclub'),$categories_list );
}
}
?>
<h2 class="pix-post-title"><a href="<?php the_permalink(); ?>" ><?php the_title(); ?> - PRONOSTICOS, APUESTAS, PREDICCION</a></h2>
<?php
px_get_the_excerpt($px_node->var_pb_blog_excerpt,false);
wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'Kingsclub' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) );
?>
<div class="blog-bottom">
<?php
if($px_node->var_pb_blog_view <> 'blog-medium'){
px_posted_on(true,false,false,false,true,false);
}
?>
<?php if($px_node->var_pb_blog_view =="blog-large"){?>
<a href="<?php the_permalink(); ?>" class="btnreadmore btn pix-bgcolrhvr"><i class="fa fa-plus"></i><?php if($px_theme_option["trans_switcher"] == "on") { _e("LEER MÁS",'Kingsclub'); }else{ echo $px_theme_option["trans_read_more"];}?></a>
<?php } ?>
</div>
</div>
</article>