gpt4 book ai didi

php - 如何从 WordPress 中的另一个数据库获取帖子元

转载 作者:行者123 更新时间:2023-11-29 15:35:44 24 4
gpt4 key购买 nike

我需要从 WordPress 外部的数据库获取自定义字段;我可以获取帖子,但我不知道如何获取它们各自的帖子元。

function seconddb() {
global $seconddb;
$args = array('post_type' => 'post',
'show_posts' => '10',
'paged' => $paged
);
$the_query = new WP_Query($args);
$seconddb = new wpdb('aaa', 'bbb', 'ccc', 'ddd');
$rows = $seconddb->get_results("SELECT ID FROM K1nG_posts");
foreach ($rows as $obj) :
echo $obj->ID;
endforeach;

// Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo get_post_meta( get_the_ID(), 'post', true);
}
}
}
add_action('init', 'seconddb');

任何人都可以帮助我获取在 WordPress 数据库中找到 post_meta 的相应自定义字段吗?

最佳答案

关于php - 如何从 WordPress 中的另一个数据库获取帖子元,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58258292/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com