0
votes

I am building a custom theme from scratch and come across a slight problem that I need some help with.

So I have on my front-page a list of the 3 latest blog posts showing the 'title', 'Excerpt' & a 'more...' link which both the title and more link take you to single.php.

I am generating the post content in a file named 'content-post.php' which is the following:

<div class="clearfix">

    <?php echo get_the_post_thumbnail( $post_id, $size, $attr ); ?>
    <header class="title">

            <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    </header>

    <ul class="info">

        <li><?php the_category(', '); ?> | <?php the_time('F Y'); ?></li>
        <!--<li>Written By: <a href="<?php bloginfo('siteurl') ?>/about/"><?php the_author(); ?></li>-->

    </ul>

    <div class="excerpt">

        <p><?php if(is_single()): ?>

            <?php the_content(); ?>
            <?php comments_template(); ?>

        <?php else: ?>

            <?php the_excerpt(); ?>
            <a class="post-link" href="<?php the_permalink(); ?>">More...</a></p>

        <?php endif; ?>
    </div>
</div>

This builds the posts out to front-page.php just fine. I am having the problem when you go into the blog page which is using the same post content and the layout is the same. Is there a way I can specify how it shows on the front-page and how it appears on the blog page?

The post is being displayed on front-page.php like this:

<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

<?php get_template_part( 'content', 'post' ); ?>

<?php endwhile; endif; ?>

And on the blog page like this:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <?php get_template_part( 'content', 'post' ); ?>


    <?php endwhile; else: ?>

    <p>There are no posts to display or pages here</p>

    <?php endif; ?>
1

1 Answers

0
votes

If I understand your question, try this:

<?php if (is_page(page id)){your query}

Good luck! ;)

PS.. or on your way:

<?php if (is_page(page id)): ?> your query <?php endif; ?>