我制作了一些自定义的帖子类型,用一些帖子填充它们,并将模板标签添加到模板中。
现在的问题是,每当我单击自定义帖子类型(The\\u permalink())上的“阅读更多”按钮时,它都不会显示单页。它显示主页。
我已经创建了一个。php文件和一个Smolenboek。php文件,它应该转到这2个文件中的1个。
我还通过单击设置->永久链接中的“保存”按钮刷新了。
Permalinks现在在Post Name上,我对他们有点了解,但这并不重要。
The Custom Post Type
function smoelenboek() {
$labels = array(
\'name\' => _x( \'Smoelenboek Sectie\', \'post type general name\', \'your-plugin-textdomain\' ),
\'singular_name\' => _x( \'Smoelenboek Sectie\', \'post type singular name\', \'your-plugin-textdomain\' ),
\'menu_name\' => _x( \'Smoelenboek Sectie\', \'admin menu\', \'your-plugin-textdomain\' ),
\'name_admin_bar\' => _x( \'Smoelenboek Sectie\', \'add new on admin bar\', \'your-plugin-textdomain\' ),
\'add_new\' => _x( \'Smoelenboek item toevoegen\', \'content\', \'your-plugin-textdomain\' ),
\'add_new_item\' => __( \'Voeg een nieuwe Smoelenboek item toe\', \'your-plugin-textdomain\' ),
\'new_item\' => __( \'Nieuwe Smoelenboek item\', \'your-plugin-textdomain\' ),
\'edit_item\' => __( \'Bewerk Smoelenboek item\', \'your-plugin-textdomain\' ),
\'view_item\' => __( \'Bekijk Smoelenboek item\', \'your-plugin-textdomain\' ),
\'all_items\' => __( \'Alle Smoelenboek items\', \'your-plugin-textdomain\' ),
\'search_items\' => __( \'Zoek Smoelenboek items\', \'your-plugin-textdomain\' ),
\'parent_item_colon\' => __( \'Hoofd Smoelenboek items\', \'your-plugin-textdomain\' ),
\'not_found\' => __( \'Geen Smoelenboek items gevonden\', \'your-plugin-textdomain\' ),
\'not_found_in_trash\' => __( \'Geen Smoelenboek items gevonden in prullenbak\', \'your-plugin-textdomain\' )
);
$args = array(
\'label\' => __(\'smoelenboek\'),
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => false,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'smoelenboek\' ),
\'capability_type\' => \'post\',
\'has_archive\' => false,
\'hierarchical\' => true,
\'menu_position\' => null,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'custom-fields\', \'revisions\',\'post-formats\' )
);
register_post_type( \'smoelenboek\', $args );
}
add_action( \'admin_init\', \'smoelenboek\' );
The Section
<?php $options = get_option( \'custom_voorpagina_panel_smoelenboek\' ); ?>
<section id="smoelenboek">
<div class="container persoon-wrapper">
<h1> <?php echo $options[\'smoelenboek-titel\']; ?> </h1>
<h3> <?php echo $options[\'smoelenboek-sub-titel\']; ?> </h3>
<?php
$loop = new WP_Query(
array(
\'post_type\' => \'smoelenboek\',
\'posts_per_page\' => 4
)
);
while($loop->have_posts()):
$loop->the_post();
$thumbnail_url = wp_get_attachment_url(get_post_thumbnail_id());
?>
<div class="persoon">
<?php
$image = get_field(\'afbeelding\');
if( !empty($image) ):
// thumbnail
$size = \'products_thumb\';
$thumb = $image[\'sizes\'][ $size ];
$width = $image[\'sizes\'][ $size . \'-width\' ];
$height = $image[\'sizes\'][ $size . \'-height\' ];
?>
<img src="<?php echo $thumb; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>">
<div class="wrapper">
<h3> <?php the_title(); ?> </h3>
<a href="<?php the_permalink() ?>"> <?php the_field(\'button_tekst\') ?></a>
</div>
</div>
<?php
endif;
endwhile;
?>
</div>
<div class="meer-personen container">
<a href="/"> <?php echo $options[\'smoelenboek-bekijk-meer\']; ?> </a>
</div>
</section>
Conclusion: 已创建自定义帖子类型,自定义帖子类型的单页无效。如果有人能帮我做这件事就好了。
EDIT: 还有单曲斯莫伦博克。php不工作
EDIT 2: /你好,世界工作。拿起单曲。php非常好。
谢谢,丹。