How would I modify one of the .php files to be able to show static text at the top of my blog posts’ page.
I saw this article here, that suggests I add this code below… but I’m not sure that will work with Shapely, nor do I know which .php file to add this to.
I mostly want to show the Page’s “Title” and if possible a brief intro/paragraph above the posts. As you probably are aware, when we select a “Page” to be the 'blog-post page" for all posts, this page’s content no longer appears. I’d like to adjust this, and I think I need to do that in one of the theme files.
if ( ‘page’ == get_option(‘show_on_front’) && get_option(‘page_for_posts’) && is_home() ) : the_post();
$page_for_posts_id = get_option(‘page_for_posts’);
<div id=“post-<?php the_ID(); ?>” class=“page”>
<?php the_content(); ?>
<?php edit_post_link(‘Edit’, ‘’, ‘’, $page_for_posts_id); ?>
I hope you are doing well today.
If you are going to do this please use the following plugin to create and activate a child theme to contain the changes made to the theme:
In order to add the code, go to Appearance >Editor > Single page and add it there.
Thank you for your help!
I’m on the page.php (via your instructions: Appearance >Editor > Single page). Where would I insert the code above? Do I just put it below “get_footer();”, or does it need to be nested in “get_header():”. I’ve copied the existing page.php text below, WITHOUT adding any modified code to it.
Thank you again for your help. I really love this theme, and would love to get this working
- The template for displaying all pages.
- This is the template that displays all pages by default.
- Please note that this is the WordPress construct of pages
- and that other ‘pages’ on your WordPress site may use a
- different template.
<?php $layout_class = shapely_get_layout_class(); ?>
if ( ‘sidebar-left’ == $layout_class ) :
<div id=“primary” class=“col-md-8 mb-xs-24 <?php echo esc_attr( $layout_class ); ?>”>
while ( have_posts() ) :
get_template_part( 'template-parts/content', 'page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
endwhile; // End of the loop.
</div><!-- #primary -->
if ( 'sidebar-right' == $layout_class ) :