【发布时间】:2014-11-14 20:36:37
【问题描述】:
我想从 wordpress 帖子中获取所有帖子的标题并插入到自定义表中,但它总是插入空值,为什么
<?php
global $post;
$args = array( 'numberposts' => -1 );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) :
setup_postdata( $post );
insert_p_now(the_permalink());
endforeach;
wp_reset_postdata();
function insert_p_now($a)
{
global $wpdb;
$wpdb->insert('wp_posttable', array('post_title' => $a), array('%s'));
}
?>
【问题讨论】:
-
你想在数据库中存储标题或超链接?