php - 如何在点击时显示特定的自定义帖子
问题描述
我想知道如何显示特定的自定义帖子-为了您的信息,我已经在 wordpress 仪表板面板中注册了自定义帖子类型,并且我还在根目录中创建了 single-news.php 文件,然后所有步骤都已完成,无论其帖子不可见,你能告诉我我该怎么做吗?
<?php
// The Query
$query = new WP_Query(array('post_type' => 'news', 'posts_per_page' => '1'));
// The Loop
if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="row">
<div class="col-md-6 post_img">
<?php the_post_thumbnail(); ?>
</div>
<div class="col-md-6 post_content">
<h2><?php the_title(); ?></h2>
<p><?php the_content(); ?></p>
</div>
</div>
<?php endwhile; endif; wp_reset_query(); ?>
解决方案
推荐阅读
- google-drive-api - Google Drive API V3 - 复制功能不复制内容
- java - 如何从循环外部访问 for 循环中的值?
- sql - 来自其他表的分组日期范围
- python - 取消 Build 密钥在 Sublime Text 3 中不起作用
- asp.net-core - 检测到可能的对象循环。在 System.Text.Json 和 Newtonsoft.Json
- windows-10 - 右键单击所选文本打开 URL
- java - 如何使用自定义 jooq 生成器并将其用作 sbt 任务?
- c++ - 网格相交 3D
- git - 使用子模块为项目创建工作树
- python - 在 Django 保存功能中重置密码