• Hi guys,

    Been searching this all day and although theres a few posts on how to do it I’m struggling to actually implement the suggestions.

    I have set my static home page here – https://www.completemuscleandfitness.com

    Underneath the content i want to add my most recent posts. I have read that i need to add a loop?

    Really struggling with this so i appreciate any help

Viewing 15 replies - 1 through 15 (of 16 total)
  • Have you reviewed multiple Loops?

    Thread Starter SCO7TY

    (@sco7ty)

    Yes, read through a couple of times but i cant get my head around it.

    I found the following in a post from someone trying to achieve something similar to me –

    <?php $my_query = "showposts=3";
    $my_query = new WP_Query($my_query); ?>
    <?php if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); ?>
    
    	<!-- standard tags to display blog post information like the_title() here -->
    
    <?php endwhile; // end of one post ?>
    <?php endif; //end of loop ?>
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<!-- standard tags to display the static page information like the_title() here -->
    
    <?php endwhile; endif; ?>

    I’m not sure where this needs to be placed in my template though, and if anything needs changing?

    How many recent posts do you wish to show?

    Thread Starter SCO7TY

    (@sco7ty)

    Just 5

    What theme are you using? Do you know what markup your theme uses on it’s main posts page?

    Thread Starter SCO7TY

    (@sco7ty)

    I’m using elegant themes Polished.

    I’m sorry but i’m not sure what you mean by what markup my themes uses? Still learning a lot.

    I’m sure i could find out though if you can tell me how?

    Thanks for your help..

    We do not support – or have access to – commercial themes here. You will need to seek any theme specific support from the theme’s developer/vendor: https://www.elegantthemes.com/forum/

    The following will work as a starting point – if you change:

    <?php
    $args= array(
    	'posts_per_page' => 5
    );
    $my_query = new WP_Query($args); ?>
    <?php if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <!-- standard tags to display blog post information like the_title() here -->
    <?php endwhile; // end of one post ?>
    <?php endif; //end of loop ?>

    But you need to replace <!-- standard tags to display blog post information like the_title() here --> with the actual markup and template tags that are appropriate for your current theme. Otherwise, the code will grab the most recent 5 posts but will not display them. Have you reviewed multiple Loops?

    Thread Starter SCO7TY

    (@sco7ty)

    Thanks again for your help. I’ve already posted in the elegant themes forum and had no response, i generally get better help from here.

    is this what the markup and template tags look like?

    <div class="postcontent">
    <?php $width = (int) get_option('polished_thumbnail_width_pages');
    	  $height = (int) get_option('polished_thumbnail_height_pages');
    	  $classtext = 'post_img';
    	  $titletext = get_the_title();
    
    	  $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext);
    	  $thumb = $thumbnail["thumb"]; ?>
    
    <?php if($thumb <> '' && get_option('polished_page_thumbnails') == 'on') { ?>
    	<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext , $width, $height, $classtext); ?>
    <?php }; ?>
    <?php the_content(); ?>
    <?php wp_link_pages(array('before' => '<p><strong>'.esc_html__('Pages','Polished').':</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>

    It looks about right as, as I said, we cant access the theme to check, so all I can suggest is that you try it.

    Thread Starter SCO7TY

    (@sco7ty)

    I can provide my blog template php

    https://pastebin.com/tjxQ8eyc

    Can you help from here? I still cant get them to show

    I’m sorry but we do not support commercial themes here as you paid for support when you bought the theme. It is not our place to keep theme vendors in business.

    Thread Starter SCO7TY

    (@sco7ty)

    Theres quite a few posts on this where people have helped out and they had commercial themes.

    I’m not asking to help keep themes vendors in business, i just want some personal help.

    Really wanted to get this sorted ??

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    If you have a query regarding a theme distributed on www.remarpro.com, let us know.

    Thread Starter SCO7TY

    (@sco7ty)

    Ok if I can’t get some help on my current commercial theme then maybe on the following.

    I have been trying for 6 hours now to get my recent posts on a static home page, it’s just not going to happen for me.

    Is there another way of setting a page as home page? Obviously as a normal page i can haven page content and the recent posts underneath no problem, and as soon as I set it to static home page the posts disappear.

    Any suggestions?

    Not without modifying your current theme’s template files, no.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘recent posts in static home page’ is closed to new replies.