Custom Theme Blog page not showing Posts

I am developing my custom theme in WordPress from scratch. Now when i am working with my blogs page its not showing any of the posts i have changed my “index.php” page but i think there must be some function that is missing from my “functions.php” page due to which my posts are not showing . i have searched for it a lot but didn’t found any good solutions. please tell me what i can do.
this is my index.php page:

<?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(); ?>

and my functions.php page:

<?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' );



?>

1 Answer
1

Problem solved .
as i was making my custom theme from scratch so there was not content.php file included in my custom theme that displays the posts titles and contents i have added that.
and it can also be solved if u add this line in you index.php page.

the_content();

or

the_title();

whatever u need.
it can be like this in the while loop :

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;

Leave a Comment