[英]How to pull content from a Wordpress Category/Archive page and set it up as the index of a subdomain?
I wanted to pull the contents (the whole page actually) of an archive/category page on Wordpress to show in an address which is a subdomain. 我想在Wordpress上提取存档/类别页面的内容(实际上是整个页面)以显示在一个子域名的地址中。
Here's what I want to see, the contents of this page: http://intorremolinos.co.uk/placecategory/accommodation/ Here's the sample subdomain, where I want the previous to appear:catredi.intorremolinos.co.uk Here's the main domain:intorremolinos.co.uk 这是我想看的内容,这个页面的内容: http ://intorremolinos.co.uk/placecategory/accommodation/这是示例子域名,我希望以前出现在哪里:catredi.intorremolinos.co.uk这里是主要的域:intorremolinos.co.uk
Right now, all that is showing is the exact same thing the homepage has. 现在,所有显示的内容与主页完全相同。
I already have something though obviously it's not working. 我已经有了一些东西,但显然它不起作用。 Here's the code I'm using, it's on an index.php file on the subdomain folder.
这是我正在使用的代码,它位于子域文件夹上的index.php文件中。
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
$_GET['placecategory_id']=56;
/** Loads the WordPress Environment and Template */
require('../wp-blog-header.php');
I have very limited PHP knowledge as you can imagine, hope someone can help. 我有非常有限的PHP知识,你可以想象,希望有人可以提供帮助。
You should write in the template file in the index.php and this looks like a core file: 您应该在index.php中的模板文件中写入,这看起来像一个核心文件:
So go to your template and there are several ways of getting what you want. 所以转到你的模板,有几种方法可以获得你想要的东西。 If you read the codex a bit, this code should go in the loop cause it is a query to a category
如果您稍微阅读了codex,则此代码应该在循环中,因为它是对类别的查询
Conditional statement with if your URL is like that then display the placecategory_id=56 条件语句,如果您的URL如此,则显示placecategory_id = 56
<?php
$host = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if($host == 'intorremolinos.co.uk/placecategory/accommodation/') {
query_posts("cat=56");
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.