简体   繁体   English

在另一个网站上显示wordpress帖子

[英]displaying wordpress post on another site

I'm currently trying to find the best way to display posts saved in Wordpress on another site. 我目前正在尝试找到在另一网站上显示保存在Wordpress中的帖子的最佳方法。

I've found various options so far but the problem I'm getting which I can't seem to find any answers on is when the post is displayed, none of the formatting is kept, for example, in the main content of a post, the paragraphs, bullet points and font stylings aren't displayed. 到目前为止,我已经找到了各种选项,但是出现的问题似乎是我找不到任何答案,这是在显示帖子时,没有保留任何格式,例如,帖子的主要内容,则不会显示段落,项目符号点和字体样式。 Also if I add an image to the post that also appears to be left out. 另外,如果我在帖子中添加图片,但该图片似乎也被忽略了。

I'm hoping the best way will be PHP and MySQL, but looking throught the Wordpress files I'm unsure how they are structured. 我希望最好的方法是PHP和MySQL,但是在Wordpress文件中,我不确定它们的结构。 The Wordpress directory will be located in the same directory of my site (eg mysite/wordpress) Wordpress目录将位于我的网站的同一目录中(例如,mysite / wordpress)

This maybe something many other people have asked but I'm struggling to find the correct terminology inorder to search for the answer. 这也许是许多其他人问过的问题,但是我正在努力寻找正确的术语以寻找答案。

You don't need to connect directly to the blog database. 您不需要直接连接到博客数据库。 You can simply create a new file in your Wordpress directory and include the wp-blog-header.php file: 您可以在Wordpress目录中简单地创建一个新文件,并包含wp-blog-header.php文件:

Example: 例:

<?php
require('./wordpress/wp-blog-header.php'); // change this to fit your path
?>
<p>Recent Posts:</p>
<ul>
while (have_posts()) : the_post(); ?>
<li><?php the_title(); ?> </li>
<?php endwhile; ?>
</ul>

Hope that helps! 希望有帮助!

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

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