我正在用WordPress从头开始开发我的自定义主题。现在,当我使用我的博客页面时,它没有显示任何帖子,我已经更改了我的“index.php”页面,但我认为我的“functions.php”页面中肯定缺少了一些函数,因此我的帖子没有显示。我已经搜索了很多,但没有找到任何好的解决方案。请告诉我我能做什么<这是我的索引。php页面:
<?php
/**
* The main template file
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* e.g., it puts together the home page when no home.php file exists.
*
* Learn more: {@link https://codex.wordpress.org/Template_Hierarchy}
*
* @package WordPress
* @subpackage customtheme
* @since 2016
*/
get_header(); ?>
<div class="fullContainer">
<div class="innerContainer2">
<?php if ( have_posts() ) : ?>
<?php if ( is_home() && ! is_front_page() ) : ?>
<header>
<h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
</header>
<?php endif; ?>
<?php
// Start the loop.
// var_dump(the_post());
// exit;
while ( have_posts() ) : the_post();
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( \'content\', get_post_format() );
// End the loop.
endwhile;
// Previous/next page navigation.
the_posts_pagination( array(
\'prev_text\' => __( \'Previous page\', \'customtheme\' ),
\'next_text\' => __( \'Next page\', \'customtheme\' ),
\'before_page_number\' => \'<span class="meta-nav screen-reader-text">\' . __( \'Page\', \'customtheme\' ) . \' </span>\',
) );
// If no content, include the "No posts found" template.
else :
get_template_part( \'content\', \'none\' );
endif;
?>
</div>
</div><!-- .content-area -->
<?php get_footer(); ?>
以及我的职能。php页面:
<?php
/**
* customtheme functions and definitions
*
* Set up the theme and provides some helper functions, which are used in the
* theme as custom template tags. Others are attached to action and filter
* hooks in WordPress to change core functionality.
*
* When using a child theme you can override certain functions (those wrapped
* in a function_exists() call) by defining them first in your child theme\'s
* functions.php file. The child theme\'s functions.php file is included before
* the parent theme\'s file, so the child theme functions would be used.
*
* @link https://codex.wordpress.org/Theme_Development
* @link https://codex.wordpress.org/Child_Themes
*
* Functions that are not pluggable (not wrapped in function_exists()) are
* instead attached to a filter or action hook.
*
* For more information on hooks, actions, and filters,
* {@link https://codex.wordpress.org/Plugin_API}
*
* @package WordPress
* @subpackage custometheme
* @since 2016
*/
/**
* Set the content width based on the theme\'s design and stylesheet.
*
* @since 2016
*/
function customtheme_setup() {
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( \'title-tag\' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* See: https://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
*/
add_theme_support( \'post-thumbnails\' );
set_post_thumbnail_size( 825, 510, true );
// For adding Menus
register_nav_menus( array(
\'primary\' => __( \'NavMenu\', \'Primary Menu\' ),
\'PFooter1\' => __( \'Product Footer1\', \'Product Footer1\' ),
\'PFooter2\' => __( \'Product Footer2\', \'Product Footer2\' ),
\'CFooter1\' => __( \'Company Footer1\', \'Company Footer1\' ),
\'CFooter2\' => __( \'Company Footer2\', \'Company Footer2\' ),
\'ContactUs\' => __( \'ContactUs\', \'ContactUs\' ),
) );
add_theme_support( \'html5\', array(
\'search-form\', \'comment-form\', \'comment-list\', \'gallery\', \'caption\'
) );
/*
* Enable support for Post Formats.
*
* See: https://codex.wordpress.org/Post_Formats
*/
add_theme_support( \'post-formats\', array(
\'aside\', \'image\', \'video\', \'quote\', \'link\', \'gallery\', \'status\', \'audio\', \'chat\'
) );
// Setup the WordPress core custom background feature.
add_theme_support( \'custom-background\', apply_filters( \'custometheme_custom_background_args\', array(
\'default-color\' => $default_color,
\'default-attachment\' => \'fixed\',
) ) );
}
add_action( \'init\', \'customtheme_setup\' );
/**
* Register our sidebars and widgetized areas.
*
*/
if ( function_exists(\'register_sidebar\') ){
register_sidebar( array(
\'name\' => \'Footer Icons Bar\',
\'id\' => \'home_right_1\',
\'before_widget\' => \'<span class="footerIcons">\',
\'after_widget\' => \'</span>\',
// \'before_title\' => \'<h2 class="rounded">\',
// \'after_title\' => \'</h2>\',
) );
register_sidebar( array(
\'name\' => \'Footer CopyRight\',
\'id\' => \'home_right_2\',
\'before_widget\' => \'<span class="footercopyright">\',
\'after_widget\' => \'</span>\',
// \'before_title\' => \'<h2 class="rounded">\',
// \'after_title\' => \'</h2>\',
) );
}
//function customtheme_widgets_init() {
//
// register_sidebar( array(
// \'name\' => \'Footer Icons Bar\',
// \'id\' => \'home_right_1\',
// \'before_widget\' => \'<span class="footerIcons">\',
// \'after_widget\' => \'</span>\',
//// \'before_title\' => \'<h2 class="rounded">\',
//// \'after_title\' => \'</h2>\',
// ) );
//
//}
//
//add_action( \'widgets_init\', \'customtheme_widgets_init\' );
// register_sidebar( array(
// \'name\' => \'Footer Copyright\',
// \'id\' => \'home_right_2\',
// \'before_widget\' => \'<span class="footercopyright">\',
// \'after_widget\' => \'</span>\',
//// \'before_title\' => \'<h2 class="rounded">\',
//// \'after_title\' => \'</h2>\',
// ) );
// add_action( \'widgets_init\', \'customtheme_widgets_init\' );
?>