wordpress:如何获取给定网址的帖子标题? [英] wordpress: How to Get post title for given url?
本文介绍了wordpress:如何获取给定网址的帖子标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个单独的 wordpress 表,其中只有 post url.
I have a separate wordpress table where there is only post url in that.
现在,我想要来自该网址的帖子标题.
Now, I want post title from that url.
试过<?php $postid = url_to_postid( $url );?>
似乎效果不佳.对某些网址返回 0.
Tried <?php $postid = url_to_postid( $url ); ?>
Doesn't seem to be working good. Returns 0 to some of the urls.
有什么想法/建议吗?
推荐答案
尝试以下查询:
$post_title=$wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE guid='$url'");
或者
post_url 是列名
post_url is a column name
$tbl_new='table name where post urls are stored';
$post_title=$wpdb->get_var("SELECT post_title FROM $wpdb->posts a JOIN $tbl_new b on a.guid=b.post_url WHERE guid='$url'");
这篇关于wordpress:如何获取给定网址的帖子标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文