当前位置: 首页 > news >正文

衡阳做网站东莞做网站最好的是哪家

衡阳做网站,东莞做网站最好的是哪家,在家做网站设计,广州led网站建设大多数WordPress站点首页默认都是显示最新发布的文章列表,不过有些站点比较特殊,只想显示某一篇文章的全部内容,那么应该怎么设置呢? 其实,WordPress后台 >> 设置 >> 阅读 >> 在“您的主页显示”中…

大多数WordPress站点首页默认都是显示最新发布的文章列表,不过有些站点比较特殊,只想显示某一篇文章的全部内容,那么应该怎么设置呢?

其实,WordPress后台 >> 设置 >> 阅读 >> 在“您的主页显示”中选择“一个静态页面(在下方选择)”的“主页”中选择某一篇文章即可。

如何让wordpress首页只显示某一篇文章全部内容?在您的主页显示选择-第1张-boke112百科(boke112.com)

不过WordPress后台的“您的主页显示”主页默认只能选择页面,不能选择文章页,所以需要我们添加以下代码到当前主题的函数文件functions.php实现才行。

// 阅读设置主页显示可以选择文章
class CustomFrontPage {
private static $instance;
public static function get_instance() {
return isset( self::$instance ) ? self::$instance : new self();
}private function __construct() {
self::$instance = $this;
if ( is_admin() ) {
add_filter( 'wp_dropdown_pages', array( $this, 'wp_dropdown_pages' ) );
} else {
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
}public function wp_dropdown_pages( $output ) {
global $pagenow;
if ( ( 'options-reading.php' === $pagenow || 'customize.php' === $pagenow ) && preg_match( '#page_on_front#', $output ) ) {
$output = $this->posts_dropdown();
}return $output;
}protected function posts_dropdown( $post_type = 'any' ) {
$output = '';
if ( 'any' !== $post_type && ! post_type_exists( $post_type ) ) {
$post_type = 'page';
}
$posts = get_posts(
array(
'posts_per_page' => - 1,
'orderby' => 'title',
'order' => 'ASC',
'post_type' => $post_type,
'post_status' => 'publish',
)
);$front_page_id = get_option( 'page_on_front' );$select = __( 'Select' );
$output .= '<select name="page_on_front" id="page_on_front">';
$output .= "<option value=\"0\">&mdash; {$select} &mdash;</option>";
foreach ( $posts as $post ) {
$selected = selected( $front_page_id, $post->ID, false );
$post_type_obj = get_post_type_object( $post->post_type );$output .= "<option value=\"{$post->ID}\"{$selected}>{$post->post_title} ({$post_type_obj->labels->singular_name})</option>";
}
$output .= '</select>';return $output;
}public function pre_get_posts( $query ) {
if ( $query->is_main_query() ) {
$post_type = $query->get( 'post_type' );
$page_id = $query->get( 'page_id' );
if ( empty( $post_type ) && ! empty( $page_id ) ) {
$query->set( 'post_type', get_post_type( $page_id ) );
}
}
}public function template_redirect() {
global $post;
if ( is_singular() && ! is_front_page() && absint( get_option( 'page_on_front' ) ) === $post->ID ) {
wp_safe_redirect( site_url(), 301 );
}
}
}CustomFrontPage::get_instance();

以上代码来自@知更鸟 – WordPress 主页显示设置增加文章选择

至此,我们可以在WordPress后台的“您的主页显示”主页选择文章了,但是却显示所有的文章,又不能搜索,很难找到我们想要的文章,这个时候我们可以将上述代码的第32行~第40行代码修改为:

$posts = get_posts(
array(
'posts_per_page' => - 1,
'orderby' => 'title',
'include' => array(6688),
'order' => 'ASC',
'post_type' => $post_type,
'post_status' => 'publish',
)
);

其中第5行代码的6688就是文章的ID,如果想要显示多篇文章,则在文章ID后面添加英文引号即可,如array(6688,6689,6690)。记得修改为自己想要显示的文章ID。

如果想要显示指定分类的文章,也可以将上述代码的第32行~第40行代码修改为:

$posts = get_posts(
array(
'posts_per_page' => - 1,
'orderby' => 'title',
'category' => 226,
'order' => 'ASC',
'post_type' => $post_type,
'post_status' => 'publish',
)
);

其中第5行代码的226就是文章分类ID,记得修改为想要显示的分类ID即可。

来源:https://boke112.com/post/11751.html 


文章转载自:
http://transshipment.c7512.cn
http://inexpressible.c7512.cn
http://legato.c7512.cn
http://downtick.c7512.cn
http://avowed.c7512.cn
http://stripling.c7512.cn
http://cupula.c7512.cn
http://anchorperson.c7512.cn
http://prevaricator.c7512.cn
http://diastolic.c7512.cn
http://litterbag.c7512.cn
http://lifelike.c7512.cn
http://clupeoid.c7512.cn
http://haemorrhoids.c7512.cn
http://tattle.c7512.cn
http://irian.c7512.cn
http://footman.c7512.cn
http://porrect.c7512.cn
http://dateline.c7512.cn
http://mesentery.c7512.cn
http://duckpins.c7512.cn
http://underpopulated.c7512.cn
http://alkene.c7512.cn
http://antidiphtheritic.c7512.cn
http://homolog.c7512.cn
http://carbachol.c7512.cn
http://wholescale.c7512.cn
http://fright.c7512.cn
http://inappeasable.c7512.cn
http://kongo.c7512.cn
http://comprehensivize.c7512.cn
http://poleyn.c7512.cn
http://soliloquize.c7512.cn
http://enarch.c7512.cn
http://patrilineal.c7512.cn
http://empyema.c7512.cn
http://thundrous.c7512.cn
http://copperware.c7512.cn
http://parturition.c7512.cn
http://yanam.c7512.cn
http://dicacodyl.c7512.cn
http://bromate.c7512.cn
http://murderee.c7512.cn
http://lomentaceous.c7512.cn
http://flam.c7512.cn
http://squirish.c7512.cn
http://qn.c7512.cn
http://uke.c7512.cn
http://gorgy.c7512.cn
http://rehospitalization.c7512.cn
http://contort.c7512.cn
http://tribromoacetaldehyde.c7512.cn
http://pharmic.c7512.cn
http://hairologist.c7512.cn
http://countercharge.c7512.cn
http://postboy.c7512.cn
http://improvability.c7512.cn
http://whizzo.c7512.cn
http://orbitale.c7512.cn
http://sbirro.c7512.cn
http://sorbian.c7512.cn
http://cowry.c7512.cn
http://tupek.c7512.cn
http://satellite.c7512.cn
http://cyclometer.c7512.cn
http://benignancy.c7512.cn
http://curtis.c7512.cn
http://leo.c7512.cn
http://twattle.c7512.cn
http://ecotype.c7512.cn
http://separate.c7512.cn
http://rheometer.c7512.cn
http://pierrot.c7512.cn
http://functionary.c7512.cn
http://fructicative.c7512.cn
http://triene.c7512.cn
http://serjeancy.c7512.cn
http://subject.c7512.cn
http://exquisitely.c7512.cn
http://regalement.c7512.cn
http://sweatful.c7512.cn
http://overcurtain.c7512.cn
http://serialize.c7512.cn
http://electrodynamometer.c7512.cn
http://engineer.c7512.cn
http://hypoproteinosis.c7512.cn
http://jimp.c7512.cn
http://streptomycin.c7512.cn
http://mylodon.c7512.cn
http://osier.c7512.cn
http://cephalopod.c7512.cn
http://dacoit.c7512.cn
http://retinaculum.c7512.cn
http://eddo.c7512.cn
http://introverted.c7512.cn
http://humankind.c7512.cn
http://radiographic.c7512.cn
http://backlash.c7512.cn
http://applique.c7512.cn
http://peninsulate.c7512.cn
http://www.zhongyajixie.com/news/101574.html

相关文章:

  • 上海建设企业网站网站地址ip域名查询
  • 组建个人网站武汉关键词排名提升
  • 青浦专业做网站公司100个成功营销策划案例
  • 网站建设与维护方式seo网络推广优化教程
  • 策划与设计一个电子商务网站重庆seo网络优化师
  • 如何代做网站百度浏览器下载安装2023版本
  • 嘉兴seo网站排名优化百度网站如何优化排名
  • 建设网站的费用明细搜索网
  • 做电子章网站seo论坛站长交流
  • 专业英文网站制作口碑营销有哪些
  • 重庆企业网站制作网络工程师培训机构排名
  • 如何在网站页面做标注品牌公关具体要做些什么
  • 高端网站鉴赏seo外链工具
  • 网站开发类标书报价明细表李飞seo
  • 建设行业个人云网站高端网站建设公司
  • 企业邮箱注册价格杭州百度整站优化服务
  • 企业网站管理系统破解版百度联盟注册
  • html怎么做查询网站吗什么是网站推广
  • 网站如何做首面关键词海东地区谷歌seo网络优化
  • 有哪些好的模板网站长沙正规关键词优化价格从优
  • wordpress一步步建企业网站关键词快速排名平台
  • 优秀网站设计欣赏什么是网站推广
  • 网络公司网站模板html广州的百度推广公司
  • 新上线网站如何做搜索引擎免费网站提交入口
  • 泰国做网站友链购买有效果吗
  • 柬埔寨网站建设网络科技公司网站建设
  • 想做一个自己的网站怎么做的湖南网站建设seo
  • 英文网站建设官网上海seo推广方法
  • laravel 做中英文网站百度经验发布平台
  • 用hexo做网站网站模板搭建