Trying to create a page template that replicates the functionality of my home page.

  • Unknown's avatar

    I am currently using the cubic theme and ran into some trouble with template creation. I have multiple sections on my site and am trying to replicate the functionality of my home page onto another page where ideally the home page would display featured articles and another page for urban exploration would be able to display posts about urban exploration in the same format. I.e. Images with nicely displayed titles in rows of three link to posts I have created.

    So far this is what my template looks like:

    <?php /* Template Name: Page Directory */ ?>
    <?php get_header(); ?>
    <?php the_content(); ?>
    <div id=’primary’ class=’content-area’>
    <main id=’main’ class=’site-main’ role=’main’>

    </main><!– .site-main –>
    <?php get_sidebar( ‘content-bottom’ ); ?>
    </div><!– .content-area –>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    This allows me to display the header with the integrated side bar and footer, but I cannot figure out how to replicate cubic’s home page functionality. Any help would be greatly appreciated.

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar

    I imagine the PHP function would have to query for tags in order to place the post on the page, then look for a post’s featured image and title to display it as a square image covering 1/3 of the page. If this information would help anyone more knowledgeable?

  • Unknown's avatar

    Update: I found you can use WP_Query to create a loop to pull information then display it using get_template_part as a means of formatting the post information. I can now display the images for my posts however the formatting is off because of the way content.php is written. [Do any users of cubic (a child theme in WordPress) know how the homepage is constructed and how I might be able to reference that file so I can recreate its format on a different page in WordPress?]

    <?php /* Template Name: Page Directory */ ?>
    <?php get_header(); ?>
    <?php the_content(); ?>
    <main id='main' class='site-main' role='main'>
    
    <?php
        $postid = new WP_Query( array( 'tag' => 'featured' ) );
        if( $postid->have_posts() ):
            while( $postid->have_posts() ): $postid->the_post(); ?>
                <?php get_template_part('content',get_post_format()); ?>
            <?php endwhile;
        endif;
    ?> 
    
    </main><!-- .site-main -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
  • The topic ‘Trying to create a page template that replicates the functionality of my home page.’ is closed to new replies.