将Wordpress的最新帖子整合到现有网站中 [英] Integrate Wordpress recent posts into existing website

查看:130
本文介绍了将Wordpress的最新帖子整合到现有网站中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有一个静态网站,我想将wordpress网站(博客)集成到现有网站中.只是指出我是Wordpress新秀,所以我仍在寻找了解Wordpress工作方式的方法.

I already have a static website and I want to integrate wordpress site (blog) into existing one. Just to point out that I am Wordpress rookie, so I'm still finding my way to understand the way wordpress works.

这是我要实现的目标:

当wordpress网站位于子目录中时,我想在index.php页面上显示最近的帖子.

I want to show recent posts on my index.php page, while wordpress site is sitting in sub directory.

我遵循了本指南: https://codex.wordpress.org/Integrating_WordPress_with_Your_Web站点

并将以下代码添加到index.php的开头

And added following code to the start of index.php

<?php
// Include Wordpress
define('WP_USE_THEMES', false);
require('wordpress/wordpress/wp-blog-header.php');
?>

现在在我的index.php的正文部分中,我想显示来自wordpress网站的最新帖子,因此我添加了以下内容:

Now in body section of my index.php i want to show recent posts from wordpress site, so I added following:

<?php
$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
foreach ($posts as $post) : setup_postdata( $post ); ?>
<?php the_date(); echo "<br />"; ?>
<?php the_title(); ?>    
<?php the_excerpt(); ?> 
<?php
endforeach;
?>

现在,即使我从wordpress默认主题正确链接了style.css文件,我仍然设法将原始文本输出到我的index.php,而没有应用任何样式修饰,并且帖子中也没有图像.

Now I managed to output raw text to my index.php, without any styling beeing applied to it and images are missing from my posts, even though i linked properly style.css file from wordpress default theme.

如何将默认的wordpress主题样式应用于最近发布的帖子?当然也可以从帖子中获取那些图像?

How to get default wordpress theme styling to be applied to those recent posts? and of course to get those images from posts to show up as well?

我还观看了本教程,在那里他设法实现了我的目标,但是并没有确切说明如何实现.

I also watched this tutorial where he managed to achieve my goal, but it's not explained exactly how.

https://www.youtube.com/watch?v=TUWu3J359AY& ; t = 559s

也不确定,因为它是旧视频,所以在新版本的Wordpress中可能有所更改.

Also not sure, since it is old video, maybe something changed in newer versions of Wordpress.

我为此花了很多时间,我希望有人可以帮助我,或者至少将我指出正确的方向.

I've lost so much time on this and I'm hoping that someone could help me out, or at least to point me out to the right direction.

如果这是重复的帖子,我事先表示歉意,但是我找不到.

I apologize in advance if this is duplicate post, however I was unable to find one.

谢谢.

推荐答案

使用Ajax调用来完成此操作或简短的方法,请使用iframe并进行一些样式设置.一切都可以立即使用.

Use Ajax call to do this or the short way, use the iframe and style a little. things will be ready to use immediately.

这篇关于将Wordpress的最新帖子整合到现有网站中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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