我对php知之甚少,我试图通过这种方式解决问题但是没有任何地方。
我需要这个下拉列表显示所有帖子,现在它只显示5个帖子。
谢谢
编辑:这是代码的唯一其他部分
ob_start();
class externalUrlToPostThumbnail
{
function externalUrlToPostThumbnail(){
try{
add_action('admin_menu', array(&$this,'ext_add_pages'));
}
catch(Exception $e){
echo "Caught Exception".$e->getMessage();
}
}
// action function for above hook
function ext_add_pages(){
add_menu_page(__('Post Featured','mymenu'), __('Featured Image','mymenu'), 'manage_options', 'external-url-post-thumbnail', array ( & $this,'uploadImage'));
}
function uploadImage(){
include_once('external-url-to-post-thumbnail.php');
}
function get_all_post()
{
$options_pages = array();
$options_pages_obj = get_posts('post_type=post');
$options_pages[''] = 'Select a Post:';
foreach ($options_pages_obj as $page) {
$options_pages[$page->ID] = $page->post_title;
}
return $options_pages;
}
}
$newObj = new externalUrlToPostThumbnail();
?>
答案 0 :(得分:2)
尝试使用以下函数替换函数get_all_post()。
function get_all_post(){
$options_pages = array();
$args= array(
'posts_per_page' => -1,
'post_type' => 'post',
);
$options_pages_obj = get_posts($args);
$options_pages[''] = 'Select a Post:';
foreach ($options_pages_obj as $page) {
$options_pages[$page->ID] = $page->post_title;
}
return $options_pages;
}