Add Content to Image and Gallery Posts Static Home Page
-
I have a client who wanted to be able to enter content into a static home page and still use the Image and Gallery Posts template that comes with Portfolio Press.
I’m not sure my approach is the best, but it’s working for me, so I thought I’d share it in case someone else wants to do the same.
The first step is to create a child theme, either by downloading the one provided by Devin here, or to create your own.
Once you have a child theme working:
- Copy the image-gallery-formats.php from the Portfolio Press parent theme’s template folder to your computer for editing.
- Use your favorite text editor to find this:
get_header(); ?>
and paste the following on the line after it:
<?php // This section is the modification you added to get the content of the actual post to include it below. if (have_posts()) { while (have_posts()) { the_post(); $content = apply_filters( 'the_content', get_the_content() ); } } // End of modification for content. ?>
- Next, find this:
<div id="content" role="main">
and on the next line, paste this:
<!-- #begin mod for actual page content --> <div class="entry-content clearfix"><?php echo $content; ?></div> <!-- #end mod for page content -->
- Save the file.
- Create a templates folder in your child theme’s directory.
- Upload the modified file to the templates folder you just created.
That’s it. Now any content you add to your home page’s editor should show up on your static home page above the thumbnail images. I didn’t include the title because I didn’t want it, but you could easily add it if you do.
- The topic ‘Add Content to Image and Gallery Posts Static Home Page’ is closed to new replies.