问题描述
我正在为我的雇主在一个网站上工作,但是“博客存档”页面遇到了一些麻烦。就目前而言,它不会在页面上发布任何帖子。但是,如果用户单击类别链接之一,则它将填充具有该类别的帖子列表。我希望默认的博客/存档页面填充所有博客文章。我添加了一个查询以获取所有帖子,但不会返回任何内容。通常,我会在-> the_post();之后告诉查询要填充的内容,但是该站点是基于Genesis构建的,我感到非常困惑。将该查询放在哪里以确保它会吐出所有帖子?该查询确实为每个帖子返回一个字符串(或我输入的任何内容),因此它可以正常工作。这是模板的代码:
<?PHP
/**
* Template Name: Blog
*
* Overwrite Genesis' Blog template
*
*
* @package XXXXXXXXXX
* @author XXXXXXXXXX
* @link XXXXXXXXXX
*/
// ADD BODY CLASS
add_filter( 'body_class','genesis_sample_add_body_class' );
function genesis_sample_add_body_class( $classes ) {
$classes[] = 'blog';
return $classes;
}
//* MOVE BREADCRUMBS
remove_action('genesis_before_loop','genesis_do_breadcrumbs');
add_action('genesis_before_content','genesis_do_breadcrumbs');
//* MOVE SIDEBAR
remove_action( 'genesis_after_content','genesis_get_sidebar' );
add_action( 'genesis_before_content','genesis_get_sidebar' );
//* Add class to .sidebar-wrap
add_filter( 'genesis_attr_sidebar-primary','sidebar_class_addon' );
function sidebar_class_addon( $attributes ) {
$attributes['class'] = $attributes['class']. ' one-third first';
return $attributes;
}
//* Add class to .content
add_filter( 'genesis_attr_content','content_class_addon' );
function content_class_addon( $attributes ) {
$attributes['class'] = $attributes['class']. ' two-thirds';
return $attributes;
}
add_action( 'genesis_before_sidebar_widget_area','genesis_page_archive_content',1 );
function genesis_page_archive_content() {
add_action( 'genesis_before_sidebar_widget_area',1 );
?>
<section class="browse">
<?PHP
$heading = ( genesis_a11y( 'headings' ) ? 'h2' : 'h4' );
$sitemap .= sprintf( '<%2$s>%1$s</%2$s>',__( 'browse By Category:','genesis' ),$heading );
$sitemap .= sprintf( '<ul>%s</ul>',wp_list_categories( 'sort_column=name&title_li=&echo=0' ) );
echo $sitemap;
?>
</section>
<?PHP
}?>
<?PHP $wpb_all_query = new WP_Query(array('post_type'=>'post','post_status'=>'publish','posts_per_page'=>'10')); ?>
<?PHP if ( $wpb_all_query->have_posts() ) : ?>
<?PHP while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post();?>
Each post should go here
<!-- Wrap Header and COntent in their own div -->
<?PHP
add_action( 'genesis_entry_header',function() {
echo '<div class="entry-wrap">';
},2 );
add_action( 'genesis_entry_content',function() {
echo '</div>';
},999 );
// Add Featured Image above Header
remove_action( 'genesis_entry_content','genesis_do_post_image',8 );
add_action( 'genesis_entry_header',function() {
$image = genesis_get_image( array(
'size' => 'thumbnail','attr' => array(
'class' => 'alignleft'
)
) );
echo '<a href="'.get_permalink().'">'.$image.'</a>';
},1 );
?>
<?PHP
wp_reset_postdata(); ?>
<?PHP endwhile; endif?>
<?PHP
// Remove Entry Footer
remove_action( 'genesis_entry_footer','genesis_entry_footer_markup_open',5 );
remove_action( 'genesis_entry_footer','genesis_entry_footer_markup_close',15 );
remove_action( 'genesis_entry_footer','genesis_post_Meta' );
genesis();
这个创世纪的主题是如此令人困惑!!任何帮助将不胜感激。谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)