Je développe mon thème personnalisé dans WordPress à partir de zéro. Maintenant, quand je travaille avec ma page de blogs, elle ne montre aucune publication, j'ai changé ma page "index.php" mais je pense qu'il doit y avoir une fonction qui manque dans ma page "functions.php" à cause de quoi ne sont pas visibles. Je l'ai beaucoup cherché, mais je n'ai trouvé aucune bonne solution. S'il vous plaît dites-moi ce que je peux faire.
Voici ma page index.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(); ?>
et ma page functions.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' );
?>
Problème résolu . comme je faisais mon thème personnalisé à partir de zéro, il n'y avait donc pas de fichier content.php inclus dans mon thème personnalisé qui affiche les titres des messages et le contenu que j'ai ajouté. et cela peut aussi être résolu si vous ajoutez cette ligne dans votre page index.php.
the_content();
ou
the_title();
tout ce dont tu as besoin. ça peut être comme ça dans la boucle while:
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() );
the_content();
the_title();
// End the loop.
endwhile;