Hi,
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.
Please advise!
Amanda
<?php
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’);
setup_postdata(get_page($page_for_posts_id));
?>
<div id=“post-<?php the_ID(); ?>” class=“page”>
<div class=“entry-content”>
<?php the_content(); ?>
<?php edit_post_link(‘Edit’, ‘’, ‘’, $page_for_posts_id); ?>
</div>
</div>
<?php
rewind_posts();
endif;
?>
Hello there,
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.
Best Regards,
Support
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
Amanda
<?php
/**
- 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.
-
-
@link https://codex.wordpress.org/Template_Hierarchy
-
-
@package Shapely
*/
get_header(); ?>
<?php $layout_class = shapely_get_layout_class(); ?>
<div class=“row”>
<?php
if ( ‘sidebar-left’ == $layout_class ) :
get_sidebar();
endif;
?>
<div id=“primary” class=“col-md-8 mb-xs-24 <?php echo esc_attr( $layout_class ); ?>”>
<?php
while ( have_posts() ) :
the_post();
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() ) :
comments_template();
endif;
endwhile; // End of the loop.
?>
</div><!-- #primary -->
<?php
if ( 'sidebar-right' == $layout_class ) :
get_sidebar();
endif;
?>
</div>
<?php
get_footer();