How to make last posting show in full

Hello

I like this theme but I want it to show the last post in full, all text and images and the older postings in brief underneath. As it is now it shows all posts in brief and you need to click Read More …

Is this possible to achieve ?

Website: www.fengshuinorge.no/blogg/

Thanks
Petter

Hello there,

To achieve it, you’ll need to edit the template-parts/content.php template file in child theme mode. Replicate the file hierarchy in your child theme, so you’ll have child_theme_folder/template-parts/content.php. Then replace this code block:

    <?php if ( is_single() ) : ?>
    <div class="entry-content">
    	<?php the_content(); ?>
    </div>
    <?php else : ?>
    <div class="entry-summary">
    	<?php the_excerpt(); ?>
    </div>
    <div class="read-more clearfix">
    	<a class="button post-button" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php esc_html_e('Read more', 'astrid'); ?></a>
    </div>
    <?php endif; ?>

with:

    <div class="entry-content">
    	<?php the_content(); ?>
    </div>

You might lose some configurations you’ve done in the customizer when child theme is active. Do not panic as it’s normal. Because WordPress system recognize child theme as a separate theme. To sync the previous settings, you can use the Customizer Export/Import plugin.

Regards,
Kharis

Hello and thank you fo your reply.

Your code makes it so that ALL the posts are opened and not only the latest one.
I want to that ONLY the latest (newest) post is showed opened and the rest on the page are showed in brief with a “Read More”.

Can you please give med the code for that ?

Thank you

Petter

Hello Petter,

Try replacing this code block:

    <?php if ( is_single() ) : ?>
    <div class="entry-content">
    	<?php the_content(); ?>
    </div>
    <?php else : ?>
    <div class="entry-summary">
    	<?php the_excerpt(); ?>
    </div>
    <div class="read-more clearfix">
    	<a class="button post-button" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php esc_html_e('Read more', 'astrid'); ?></a>
    </div>
    <?php endif; ?>

with:

    <?php if ( is_single() || get_the_ID() == 258) : ?>
    <div class="entry-content">
    	<?php the_content(); ?>
    </div>
    <?php else : ?>
    <div class="entry-summary">
    	<?php the_excerpt(); ?>
    </div>
    <div class="read-more clearfix">
    	<a class="button post-button" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php esc_html_e('Read more', 'astrid'); ?></a>
    </div>
    <?php endif; ?>

In the code above, replace 258 with ID number of your last post. I found it’s 1.

Regards,
Kharis

Hello again

I have changed the code according to your suggestion but it does not work.
Does not make any changes in how the posts are displayed.
Is it correct that the get_the_ID should be together with is_single ?
Does not that make the IF statement only happening if there is just a single post ??

I have tried with ID () == 1

I think this will not work.
I found the ID on the newest posting now and the ID is 1734
When I post a new article then the new article gets a new ID and the second newest article is still 1734.
When I post a new posting, THAT is the posting I want to be shown in FULL so the ID will change all the time when I post a new article.
Therefor the code were you have a static ID number will not work as intended.

Petter

Any new help or suggestions for me ?

Please try this code:

	<?php
	$index = $wp_query->current_post + 1;
	?>
	<?php if ( is_single() ) : ?>
	<div class="entry-content">
		<?php the_content(); ?>
	</div>
	<?php elseif ( $index == 1 && !is_single() ) : ?>
	<div class="entry-content">
		<?php the_content(); ?>
	</div>
	<?php else : ?>
	<div class="entry-summary">
		<?php the_excerpt(); ?>
	</div>
	<div class="read-more clearfix">
		<a class="button post-button" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php esc_html_e('Read more', 'astrid'); ?></a>
	</div>
	<?php endif; ?>

In the code above,

   $index = $wp_query->current_post + 1;

variable get the post count within loop.

  elseif ( $index == 1 && !is_single() ) :

check if the post is the latest;

and display special output if it isn’t single post.

Regards,
Kharis

Hi and thank you for your reply.

In what file do you want me to insert the code and were in the file ?

Regards

Petter

I found the place to insert the code myself and it works just as intended.

Thank you so much for your kind help.

Petter
Norway