我试图在一个小部件中添加一个自定义post类型的自定义循环。
在我将循环添加到our_team_section_after()
作用
但是,我找不到任何语法错误,每当我添加循环时,就会出现500个内部服务器错误。当我把它拿出来时,它工作得很好。
我使用的是Genesis框架,所以有些钩子是Genesis独有的。
我真的一直在网上搜索答案,但没有找到答案。任何帮助都将不胜感激!
<?php
//Register the widget areas
genesis_register_sidebar( array(
\'id\' => \'landing-section\',
\'name\' => __( \'Landing Section\', \'genesis\' ),
\'description\' => __( \'First Homepage Section.\', \'Bootstrap Genesis\' ),
) );
genesis_register_sidebar( array(
\'id\' => \'who-we-are-section\',
\'name\' => __( \'Who We Are Section\', \'genesis\' ),
\'description\' => __( \'Who We Are Homepage Section.\', \'Bootstrap Genesis\' ),
) );
genesis_register_sidebar( array(
\'id\' => \'creative-process-section\',
\'name\' => __( \'Creative Process Section\', \'genesis\' ),
\'description\' => __( \'Creative Process Homepage Section.\', \'Bootstrap Genesis\' ),
) );
genesis_register_sidebar( array(
\'id\' => \'services-section\',
\'name\' => __( \'Services Section\', \'genesis\' ),
\'description\' => __( \'Services Homepage Section.\', \'Bootstrap Genesis\' ),
) );
genesis_register_sidebar( array(
\'id\' => \'our-team-section\',
\'name\' => __( \'Our Team Section\', \'genesis\' ),
\'description\' => __( \'Our Team Homepage Section.\', \'Bootstrap Genesis\' ),
) );
genesis_register_sidebar( array(
\'id\' => \'case-studies-section\',
\'name\' => __( \'Case Studies Section\', \'genesis\' ),
\'description\' => __( \'Case Studies Homepage Section.\', \'Bootstrap Genesis\' ),
) );
genesis_register_sidebar( array(
\'id\' => \'worked-with-section\',
\'name\' => __( \'Who We\\\'ve Worked With\', \'genesis\' ),
\'description\' => __( \'Who We\\\'ve Worked With Homepage Section.\', \'Bootstrap Genesis\' ),
) );
//* Add the page widget in the content - XHTML
add_action( \'genesis_before_loop\', \'front_page_content\' );
function front_page_content() {
if ( is_front_page() ){
genesis_widget_area (\'landing-section\', array(
\'before\' => \'<div id="landing-section"><div class="container">\',
\'after\' => \'</div></div>\',
) );
genesis_widget_area (\'who-we-are-section\', array(
\'before\' => \'<div id="who-we-are-section"><div class="container">\',
\'after\' => \'</div></div>\',
) );
genesis_widget_area (\'creative-process-section\', array(
\'before\' => \'<div id="creative-process-section"><div class="container">\',
\'after\' => \'</div></div>\',
) );
genesis_widget_area (\'services-section\', array(
\'before\' => \'<div id="services-section"><div class="container">\',
\'after\' => \'</div></div>\',
) );
genesis_widget_area (\'our-team-section\', array(
\'before\' => our_team_section_before(),
\'after\' => our_team_section_after(),
) );
genesis_widget_area (\'case-studies-section\', array(
\'before\' => \'<div id="case-studies-section"><div class="container">\',
\'after\' => \'</div></div>\',
) );
genesis_widget_area (\'worked-with-section\', array(
\'before\' => \'<div id="worked-with-section"><div class="container">\',
\'after\' => \'</div></div>\',
) );
}
}
function our_team_section_before() {
$before = \'<div id="our-team-section">\';
$before .= \'<div class="container">\';
return $before;
}
function our_team_section_after() {
$after = \'</div>\';
$after .= \'<div class="container-fluid">\';
$after .= \'<div class="row">\';
$after .= \'<div class="col-lg-9 col-sm-8 col-xs-12">\';
$after .= \'<div class="owl-carousel">\';
$args = array(
\'post_type\' => \'team_post_type\'
);
$query = new WP_Query($args);
if( $query -> have_posts() ){
$query -> while( have_posts() ){
$query -> the_post();
$after .= \'<div>\';
$after .= the_post_thumbnail();
$after .= \'</div>\';
}
wp_reset_postdata();
}
$after .= \'</div>\';
$after .= \'</div>\';
$after .= \'<div class="col-lg-3 col-sm-4 col-xs-12">\';
$after .= \'<div class="homepage-cta">\';
$after .= \'<span>See Entire Team ></span>\';
$after .= \'</div>\';
$after .= \'</div>\';
$after .= \'</div>\';
$after .= \'</div>\';
$after .= \'</div>\';
return $after;
}