开发者

How can i use query_posts() in wordpress?

I want to use query_posts()Codex function of wordpress. But how can i use it, I am new to wordpress. Basically want to select record by post_title name

$titleName = "My Post title name";

query_posts("post_title=".$titleName);

while ( have_posts() ) : the_post();
     echo the_title();
开发者_Go百科endwhile;

Is the above syntax correct or am missing something?


It's not an exact answer but its an alternate. If you can't get it done by post name, You can get it by it's slug.

Show Post/Page by Slug

Display post by slug:

$query = new WP_Query( 'name=about-my-life' );

Display page by slug:

$query = new WP_Query( 'pagename=contact' );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜