• Hi,

    I’ve searched around the internet but unbelievably I cant seem to find an answer to a questions that I’m sure must have a really simple answer.

    I’m using Genesis as my parent theme and I’ve created a child theme.
    I created a custom page template so that one page in particular will have a different page structure and layout.
    The only thing happening in my page template is genesis();
    I have 8 posts created, some with categories assigned, others without.
    I have created a page and have specified that it should use my newly created page template.

    When I view the page it is blank, not showing any posts. It’s just a blank page with all the default page structures (i.e. header, sidebar, footer, etc).

    How do I make all posts appear on the pages that use this template?

    It’s so strange that I can’t find a simple answer to this online!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Please post the URL of the page with the problem. Next, please post the page template file on postie.org and paste the link here.

    Thread Starter theclarkofben

    (@theclarkofben)

    Here’s the page template:

    <?php
    
    //* Template Name: People
    
    genesis();
    
    ?>
    Thread Starter theclarkofben

    (@theclarkofben)

    Here’s what a page using that template looks like: https://s1.postimg.org/o7sqwwrjz/Screen_Shot_2015_08_28_at_14_40_15.png

    Thread Starter theclarkofben

    (@theclarkofben)

    Here’s my functions.php:

    <?php
    // This will bring in the Genesis Parent files needed:
    require_once( TEMPLATEPATH . '/lib/init.php' );
    
    // Setup Child Theme
    define( 'Child_Theme_Name', __( 'Shell Global', 'shellglobal' ) );
    define( 'Child_Theme_Url', 'localhost' );
    define( 'Child_Theme_Version', '1.0' );
    
    // Add HTML5 markup structure from parent Genesis framework
    add_theme_support( 'html5' );
    
    // Add HTML5 responsive recognition from parent Genesis framework
    add_theme_support( 'genesis-responsive-viewport' );
    
    // Include jQuery script when building pages
    if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 1);
    function my_jquery_enqueue() {
       wp_deregister_script('jquery');
       wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js", false, null);
       wp_enqueue_script('jquery');
    }
    
    // This will bring the CSS across from parent Genesis theme:
    add_action( 'wp_enqueue_scripts', 'my_child_theme_scripts', 2 );
    function my_child_theme_scripts() {
        wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' );
        wp_enqueue_script( 'global-js', get_stylesheet_directory_uri() . '/global.js');
        if (is_page_template( 'login-page.php' )) {
           wp_enqueue_style( 'custom-login-css', get_stylesheet_directory_uri() . '/custom-login.css');
           wp_enqueue_script( 'custom-login-js', get_stylesheet_directory_uri() . '/custom-login.js');
       }
    }
    
    // Remove the wp-admin bar at top of browser when logged in for everyone on all pages
    show_admin_bar(false);
    
    // Remove the Genesis site header on all pages
    remove_action( 'genesis_header', 'genesis_header_markup_open', 5 );
    remove_action( 'genesis_header', 'genesis_do_header' );
    remove_action( 'genesis_header', 'genesis_header_markup_close', 15 );
    
    // Remove the Genesis site Footer on all pages
    remove_action('genesis_footer', 'genesis_do_footer');
    remove_action('genesis_footer', 'genesis_footer_markup_open', 5);
    remove_action('genesis_footer', 'genesis_footer_markup_close', 15);
    
    /*
    The below restricts access to the WordPress Admin Area to
     only users who we want to be there. When logging to wp-login.php this
     code will check if the user is an administrator and if they are not WordPress
     will redirect them back to the website home page. */
    function restrict_admin()
    {
      if ( ! current_user_can( 'manage_options' ) && '/wp-admin/admin-ajax.php' != $_SERVER['PHP_SELF'] ) {
                    wp_redirect( site_url() );
      }
    }
    add_action( 'admin_init', 'restrict_admin', 1 );
    
    ?>

    Thread Starter theclarkofben

    (@theclarkofben)

    I guess I just don’t understand what I need to write in a new page template in order for posts to be called and displayed on the page. I don’t know if it’s the same for Genesis as it is for vanilla WP?

    Thread Starter theclarkofben

    (@theclarkofben)

    Update:
    I have found that the following in the template.php file brings posts to the page.

    <?php
      /**
       * @author  Ben Clark
       * @link    https://www.clarkben.com
       */
    
      //* Template Name: People
    
      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
      query_posts(array('posts_per_page' => 5, 'paged'=>$paged,));
    
      genesis();
    
      ?>

    Now I’m trying to work out how this can be customised.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Genesis: posts not showing on page that uses custom page template’ is closed to new replies.