ЧП Куликов Михаил Михайлович
Внимание!!! Заработал на 100% новый сервис.
Display WordPress content ouside of your blog
Оригинал статьи: http://www.corvidworks.com/articles/wordpress-content-on-other-pages
WordPress is a very powerful and flexible content management system (CMS) for blogs, and is among the first choices for anyone looking for a way to include dynamic content on their web sites. When using WordPress to power a news or blog section of an existing web site, authors will often want to display a list of headlines or the latest post on the front page of the site, outside of the WordPress-powered section. Using a bit of PHP and the WordPress API, this is easy to do.
This article assumes a basic familiarity with modifying WordPress templates, particularly the “loop” API.
In this, as well as all my tutorials, I use the domain name example.com to refer to your domain. When you see this, substitute your actual domain name. As well, in this article I will assume you have installed WordPress into a directory called /wordpress. If you use a different name for your WordPress folder, just replace “wordpress” in any paths below with whatever name you chose.
The key to gaining access to the power of WordPress from an outside page lies in the
Let’s add the latest post to the front page of our site. We’ve already got a blog at
The first thing we’ll do is pull in that all-powerful WordPress file, which we can do by adding this section to the very top of the page you want your post to appear on:
The first line of this block is simply a comment describing what we’re doing. The second line tells WordPress not to display your templates, and the third line grabs that file I told you about. The final line performs a database query to retrieve the content we want to display on this page. In this example, we want the single most recent post, but the
Now we’ll move down in our page and find a good spot for this post. Once you’ve figure out where to put it, we’ll add a WordPress loop which will display the single post retrieved above:
Once the loop is in place, we just have to decide what parts of the post to display, and write some HTML for them. Let’s say we want the post title and just an excerpt, followed by a link to the full article. We'd do something like this:
If you’ve been writing WordPress themes, you’ll immediately recognize the template tags used here. We’re using all the same functions for the title, excerpt, permalink, etc, that we do in a WordPress template. Including
You can even use this code to display blog posts on a completely separate web site, as long as it’s on the same server and you have filesystem access to the WordPress directory on the original site. Simply modify the
Note: PHP restrictions such as
Комментарии к посту «Display WordPress content ouside of your blog»
1 USD = 28.571↓ 28.169↑
1 EUR = 34.722↓ 34.130↑
1 RUR = 00.400↓ 00.360↑
Спонсоры...SP: LF: PP: