Mysql 查询将 WP 帖子标题替换为 all_in_one seo 帖子标题
我想用 seo 标题替换帖子标题(如果存在)
我想包含 $wpdb->wp_postmeta.meta_value WHERE $wpdb->wp_postmeta.meta_key = aioseop_title
在下面的查询中。
我不确定的是使用什么代码来查找它是否存在。
对于某些帖子,没有 aiooseop_title。
理想情况下,我希望每次都列出 post_title,并包含 $wpdb->wp_postmeta.metavalue
(如果每个帖子的 meta_key = aioseop_title
)。
这是做什么的:下面是查找帖子 ID 来构建 Google 新闻站点地图。
我上面的建议将使用 seo 标题而不是 WordPress 中的默认帖子标题。
$rows = $wpdb->get_results(
"SELECT
$wpdb->posts.ID
, $wpdb->posts.post_date_gmt
, $wpdb->posts.post_title
FROM $wpdb->posts
WHERE $wpdb->posts.post_status='publish'
AND (DATEDIFF(CURDATE(), post_date_gmt)<=30)
$includeMe
ORDER BY $wpdb->posts.post_date_gmt DESC
LIMIT 0, 1000"
);
I want to replace the post title with seo title if it exists
I would like to include $wpdb->wp_postmeta.meta_value WHERE $wpdb->wp_postmeta.meta_key = aioseop_title
in the query below.
What I'm unsure about is what code to use to find if it exists or not.
For some posts, there is no aioseop_title.
Ideally, I'd like to list the post_title everytime, and include the $wpdb->wp_postmeta.metavalue
if the meta_key = aioseop_title
for each post.
What this is doing: Below it's finding the post id to build a google news sitemap.
What I'm proposing above will use the seo title instead of the default post title in wordpress.
$rows = $wpdb->get_results(
"SELECT
$wpdb->posts.ID
, $wpdb->posts.post_date_gmt
, $wpdb->posts.post_title
FROM $wpdb->posts
WHERE $wpdb->posts.post_status='publish'
AND (DATEDIFF(CURDATE(), post_date_gmt)<=30)
$includeMe
ORDER BY $wpdb->posts.post_date_gmt DESC
LIMIT 0, 1000"
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
阅读评论澄清后,也许是这样的?
接下来是 php 中的条件,以确定 aioseop (可能是 $row['metavalue'])列是否为空。我还没有深入研究 WordPress 来了解确切的列名称,但从您所提供的内容来看,这可能就是您正在寻找的内容。 (顺便说一句,您也可以更轻松地为“FROM $wpdb->posts”部分添加别名。
After reading the comments to clarify, something like this perhaps?
Followed by a conditional in php to determine if the aioseop (probably $row['metavalue']) column is null or not. I've not delved deep enough into wordpress to know the exact column names but from what you've put up this is probably what you're looking for. (As an aside it would probably be easier for you to alias the 'FROM $wpdb->posts' part as well.