show page content custom home template

Community Forums Forums Design Tips and Tricks show page content custom home template

This topic is: not resolved

This topic contains 6 replies, has 3 voices, and was last updated by  braddalton 4 months, 2 weeks ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #75624

    dmcleod87
    Participant
    Post count: 50

    hi all,

    i have started building a new site and i’m having trouble with a custom home template i’ve created. i’ve put it together from various sources. the code i used below displays the homepage content, but also displays all the websites pages as posts below the page content.

    
    add_action('genesis_loop', 'custom_loop');
    function custom_loop() {
    	global $paged;
     
        $args = array('post_type' => 'page');
        // Accepts WP_Query args
        // (http://codex.wordpress.org/Class_Reference/WP_Query)
        
        genesis_custom_loop( $args );
    
    }
    

    i’ve tried adding this query but it seems to do nothing

    
    $query = new WP_Query( 'page_id=31' );
    

    can anyone point me in the right direction? thanks!

    http://grayking.dylanmcleod.net.au/
    #75646

    Summer
    Participant
    Post count: 738

    What happens when you scrap that template and just set that particular page to be your static front page in Settings > Reading?

    Seems that might be the easier course of action, unless there’s something else you were trying to achieve?


    #75647

    dmcleod87
    Participant
    Post count: 50

    that’s what it’s set to currently, but still shows the other pages as posts…all i want is the homepage content which is there, but without the other page content underneath…

    #75681

    braddalton
    Participant
    Post count: 7442

    What theme are you using?

    You could use a custom page template with widgets so the loop of posts is not displayed.


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #75750

    dmcleod87
    Participant
    Post count: 50

    i’m using the genesis sample theme with a custom template and widgets, but need to show page content as well. full code for template is below -

    <?php
    /*
    Template Name: Widget Template

    Created for three featured widget section, by Iniyan-tweaky
    */
    //Displaying posts on this page
    remove_action( ‘genesis_loop’, ‘genesis_do_loop’ );

    add_action(‘genesis_loop’, ‘custom_loop’);
    function custom_loop() {
    global $paged;

    $args = array(‘post_type’ => ‘page’);
    // Accepts WP_Query args
    // (http://codex.wordpress.org/Class_Reference/WP_Query)

    // $query = new WP_Query( ‘page_id=31′ );

    genesis_custom_loop( $args );

    }

    //Featured Widgets
    add_action(‘genesis_before_content’, ‘iniyan_template’);
    function iniyan_template() {

    echo’<div id=”tweaky-widgets”>’;

    genesis_widget_area( ‘home-featured’, array(
    ‘before’ => ‘<div class=”home-featured widget-area”>’,
    ‘after’ => ‘</div>’,
    ) );

    genesis_widget_area( ‘featured-one’, array(
    ‘before’ => ‘<div class=”featured-one”>’,
    ‘after’ => ‘</div>’,
    ) );

    genesis_widget_area( ‘featured-two’, array(
    ‘before’ => ‘<div class=”featured-two”>’,
    ‘after’ => ‘</div>’,
    ) );

    genesis_widget_area( ‘featured-three’, array(
    ‘before’ => ‘<div class=”featured-three”>’,
    ‘after’ => ‘</div>’,
    ) );

    echo ‘</div>’;

    }

    genesis(); // <- everything important: make sure to include this.

    #75763

    dmcleod87
    Participant
    Post count: 50

    nevermind figured it out. just had to remove custom loop and leave the widgets.

    
    <?php
    /* 
    Template Name: Widget Template
    */
    
    //Featured Widgets
    add_action('genesis_before_content', 'iniyan_template');
    function iniyan_template() {
    
    echo'<div id="tweaky-widgets">';
    
    genesis_widget_area( 'home-featured', array(
        	'before' => '<div class="home-featured widget-area">',
        	'after' => '</div>',
    ) );
    
    genesis_widget_area( 'featured-one', array(
           'before' => '<div class="featured-one">',
           'after' => '</div>',
       ) );
       
    
    genesis_widget_area( 'featured-two', array(
           'before' => '<div class="featured-two">',
           'after' => '</div>',
       ) );
       
    
    genesis_widget_area( 'featured-three', array(
           'before' => '<div class="featured-three">',
           'after' => '</div>',
       ) );
    
    echo '</div>';
    
    }
    
    genesis(); // <- everything important: make sure to include this. 
    
    #75821

    braddalton
    Participant
    Post count: 7442

    Don’t think that will work as you register widgets in your child themes functions file not a template file.


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.