English 中文(简体)
获取 WordPress 的帖子
原标题:get post from wordpress

我有一个静态网站,我想从我的200篇WordPress文章中选取大约15篇文章,并以与博客非常不同的设计和事物的方式将其放入静态网站中。

我已经取得了那个代码。

<?php
$my_id = 1828;
$post_id = get_post($my_id); 
echo $post_id;
?>  

但如何告诉博客的地址,以及如何从帖子1828中获取数据库文本

最佳回答

这是我最终的工作代码。

<?php require( ../mywebsite.com/wp-load.php ); 

function getmypost($number)
    {
        query_posts( p= .$number);
        while (have_posts()) : the_post();
        echo  <div class="post"> ;
        the_title( <h1> ,  </h1> );
        the_content();
        echo  </div> ;
        endwhile;
    }
问题回答

Your working code is great if you only use it on your own site. If you do it often and on other sites or in plugins, this is worth a read: http://ottodestruct.com/blog/2010/dont-include-wp-load-please/





相关问题
Wrap stray text in <p> tags

Wordpress issue.. how do I wrap stray text in P tags? Example: Before- <div class = "content"> <img src = "hello.jpg"/> <h1>Introduction</h1> Hello! this is ...

Using jQuery Plugins with Wordpress

Having a bit of trouble using jQuery plugins (Superfish, jQuery UI, etc) using Wordpress. Everything works fine in my plain non-Wordpress site, but Wordpress seems to conflict with JQuery. There must ...

WordPress Data Storage Efficiency

I ve been asked to review a WordPress plugin of sorts and try to find ways of making it faster. The premise of this plugin is basically to store a bunch of users and shifts and appointments and ...

Why can t I properly style a blockquote in Wordpress?

On the design I just created for my website, I have a blockquote styled with two quote images using the span technique in css: blockquote { background-image: url(images/openquote.jpg); background-...

How does the WordPress <!--nextpage--> tag actually work?

What happens? I m guessing that somehow the post or page is parsed before displaying, and then just split into two methods? I can t seem to find any documentation on how the underlying <?php ...

Wordpress Plug-ins: How-to add custom URL Handles

I m trying to write a Wordpress Plug-in but can t seem to figure out how you would modify how a URL gets handled, so for example: any requests made for: <url>/?myplugin=<pageID> will ...

热门标签