[英]Using WordPress to control one page (blog/news feed) on website
I have built a bespoke website that has nothing to do with wordpress, the root directory looks something like this: 我建立了一个与wordpress无关的定制网站,其根目录如下所示:
domain.com/ // index.php
domain.com/about/ // about.php
domain.com/contact/ // contact.php
domain.com/news/ // news.php
etc...
However, I would like to use WordPress to control the content on one page within the site ( domain.com/news
) whilst keeping the current website design on this page. 但是,我想使用WordPress来控制网站(
domain.com/news
)内某一页面上的内容,同时将当前的网站设计保留在此页面上。
I have started by installing WordPress to a sub-directory here domain.com/_wp/
. 首先,我将WordPress安装到
domain.com/_wp/
的子目录中。 I am not too sure where to go next... 我不太确定下一步要去哪里...
I do not want WordPress to have anything to do with the pages on my site, apart from the domain.com/news
page, but as I am unfamiliar with WordPress, I do not have any idea how to do this. 除了
domain.com/news
页面,我不希望WordPress与我网站上的页面有任何关系,但是由于我不熟悉WordPress,所以我不知道该怎么做。
I have looked around the web at particular forums, but none of them really make sense to me: 我曾在特定的论坛上浏览过网络,但对我来说,没有一个真正有意义:
I will write the code to retrieve the 'News Feeds' from the WordPress database on the domain.com/news/
, but in the meantime I would like to know the following: 我将编写代码从
domain.com/news/
上的WordPress数据库中检索“新闻提要”,但与此同时,我想了解以下内容:
I apologize for all of the above questions, WordPress is a little more complicated than I originally thought it would be. 对于上述所有问题,我深表歉意,WordPress比我原本想的要复杂一些。 I have tried to solve all of the above myself, but sadly have not had any success, and I hope all I need now is just a pointing in the right direction
我已经尝试解决上述所有问题,但可惜没有取得任何成功,我希望我现在所需要的只是指向正确方向的指示
From the WordPress documentation , to display posts only: 从WordPress文档中 ,仅显示帖子:
<?php
require('/the/path/to/your/wp-blog-header.php');
$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
foreach ($posts as $post) : start_wp(); ?>
<?php the_date(); echo "<br />"; ?>
<?php the_title(); ?>
<?php the_excerpt(); ?>
<?php
endforeach;
?>
Now to trim the irrelevant sections in WP default themes ( /wp-content/themes/YOURTHEME/
), you may either comment them out in the misc .php included templates, or using theme management. 现在,要修剪WP默认主题(
/wp-content/themes/YOURTHEME/
)中不相关的部分,您可以在杂项.php包含的模板中将它们注释掉,或者使用主题管理。
Considering how you don't wish to integrate much in WordPress, only displaying posts would make the most sense. 考虑到您不希望在WordPress中进行太多集成,仅显示帖子才是最有意义的。
The most simple way is to install Wordpress to a subfolder called news, and have it set up there. 最简单的方法是将Wordpress安装到名为news的子文件夹中,并在那里进行设置。
So you will have: 因此,您将拥有:
index.php
about.php
contact.php
news.php
and a folder named news 和一个名为news的文件夹
Since the links you have domain.com/news/
are probably rewritten through apache, apache will now to get first the folders and if none found, then make the rewrite. 由于您具有
domain.com/news/
的链接可能是通过apache重写的,因此apache现在将首先获取文件夹,如果找不到,则进行重写。 So it will work from the start. 因此它将从一开始就起作用。
a very simple way of doing is making a iframe for you site that would just pull the wordpress site into your news page. 一种非常简单的方法是为您的网站制作一个iframe,只需将wordpress网站拉到您的新闻页面即可。
<div style='width: 900px; Height: 300px; Overflow: hidden;'> <iframe style='width: 918px; Height: 300px;' src="https://www.wordpress.com/" frameBorder="0" scrolling="no"></iframe> </div>
you could also use margin controls to just display a small part of the page. 您也可以使用边距控件仅显示页面的一小部分。
margin-top: -50px;
for example would cut off the head. 例如会割断头部。
However this would slow down your site slightly as it having to run a whole subpage on your page, but if its just for one page it might be ok. 但是,这会稍微降低您的网站的速度,因为它必须在页面上运行整个子页面,但是,如果仅用于一页,则可能没问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.