简体   繁体   English

在wordpress循环上长时间运行以显示某些帖子

[英]Running a long conditional on the wordpress loop to display certain posts

I'll try and keep this simple. 我会尽量保持简单。

I need to write a conditional that allows the user to either have 3 posts from one CPT or 1 from each CPT displaying on the homepage. 我需要编写一个条件,允许用户在首页上显示一个CPT的3条帖子,或每个CPT的1条帖子。

I have 3 CPT's and 1 taxonomy in each one. 我每个人都有3个CPT和1个分类法。 Each taxonomy has 3 terms -> homeone, hometwo, homethree 每个分类法都有3个术语-> homeone,hometwo,homethree

these will be what the user selects to make that post appear on the homepage. 这些就是用户选择的以便使该帖子显示在首页上的内容。

display post in the first loop | 在第一个循环中显示帖子| homeone = first loop homeone =第一个循环
display post in the second loop | 在第二个循环中显示帖子| hometwo = second loop hometwo =第二循环
display post in the third loop | 在第三循环中显示帖子| homethree = thirdloop homethree = thirdloop

So far to achieve wanted result I've written this but am yet to debug or test it as my knowledge of php is still lacking. 到目前为止,要达到想要的结果,我已经编写了此文件,但是由于我仍然缺乏对php的知识,因此尚未对其进行调试或测试。

http://pastebin.com/R9g38eRq http://pastebin.com/R9g38eRq

The website I'm working on the 3 images with text underneath are what I'm going to be changing 我正在处理下面带有文字的3张图片的网站是我将要更改的网站

http://goo.gl/lLGI3 http://goo.gl/lLGI3

我建议使用WP_Query来微调查询http://codex.wordpress.org/Class_Reference/WP_Query,而不要使用if语句并输出默认的wordpress循环。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM