Wordpress - 从类别显示帖子 [英] Wordpress - Display Post from categories

查看:30
本文介绍了Wordpress - 从类别显示帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要显示来自特定类别的有限帖子,但带有页面标题,页面的少量描述以及阅读更多链接提到它,我得到这个的过程是什么或指导我一些关于 wordpress 编码的细节,因为我对此很陌生.

I need to display a limited post from a specific category but with a page title , little description of page and also a read more link mention it, whats the procedure to i get this or guide me some details about the wordpress coding because i am very new in it.

我不需要在 page.php 中粘贴代码,我只需要在一个特定页面上显示它.

I dont need to paste code in page.php i need to display this only on one specific page.

基本上我想在页面上制作一个自定义新闻专栏,我需要从类别新闻中获取帖子但限制为五个,当新帖子添加到主页上的类别自动显示时,我尝试了很多插件,但我仍然没有'始终无法获得准确的解决方案,这就是为什么我需要进行适当且永久的编码.

Basically i want to make a custom news column on page and i need to get post from category news but limit of five and when the new post added in category automatic display on home page i try lots of plugins but i still didn't get the exact solution all the time differs that's why i need to make a proper and permanent coding.

推荐答案

创建自定义页面模板,然后在其上添加 wp_query 应该可以工作.创建模板后,您可以创建一个页面,然后将模板设置为您创建的新自定义页面模板.例如:创建新闻页面模板.在您的主题中,创建 news-template.php 然后添加以下代码:

Creating a custom page template and then adding wp_query on it should work. After creating the template, you can create a page then set the template to the new custom page template you created. For example: create a News Page Template. In your theme, create news-template.php then add this code:

<?php
/**
 * Template Name: News Page Template
 *
 */

// add your markup here and wp_query

?>

这篇关于Wordpress - 从类别显示帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆