我想从不同页面的一个自定义字段以及页面标题中获取内容,我使用以下代码:
<?php
$mypages = get_pages( array(
\'sort_order\' => \'ASC\',
\'sort_column\' => \'post_title\',
\'hierarchical\' => 1,
\'exclude\' => \'\',
\'include\' => \'\',
\'meta_key\' => \'\',
\'meta_value\' => \'\',
\'authors\' => \'\',
\'child_of\' => 53,
\'parent\' => -1,
\'exclude_tree\' => \'\',
\'number\' => \'\',
\'offset\' => 0,
\'post_type\' => \'page\',
\'post_status\' => \'publish\'
) );
foreach( $mypages as $page ) {
$content = $page->post_content;
$new = $page->get_post_custom_values(\'new_file\');
if ( ! $content ) // Check for empty page
continue;
$content = apply_filters( \'the_content\', $content );
?>
<h2><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h2>
<a style="display:block; text-align: center;" title="Download Now" href="<?php $new; ?>"><img src="<?php bloginfo(\'template_url\'); ?>/images/new-file.png" alt="Download the File" /></a>
<?php
}
?>
我可以获取页面标题,但无法获取自定义字段值。请在这方面指导我。在这方面,我们将非常感谢您的帮助。