• Resolved linux4me2

    (@linux4me2)


    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:

    1. Copy the image-gallery-formats.php from the Portfolio Press parent theme’s template folder to your computer for editing.
    2. 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.
      ?>

    3. 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 -->

    4. Save the file.
    5. Create a templates folder in your child theme’s directory.
    6. 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.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter linux4me2

    (@linux4me2)

    I’m just posting again to mark this as resolved.

    This worked very well for me. The only thing is, the “Older posts” navigation button doesn’t work anymore. It just reloads the same page. Any ideas on how to solve that?

    Thread Starter linux4me2

    (@linux4me2)

    Mine doesn’t either, but I didn’t notice it. I’m not sure it’s related. I will take a look at it when I get a chance and post back if I find anything.

    Thread Starter linux4me2

    (@linux4me2)

    I’m using the static home page to show a list of “featured works,” so I didn’t really need the “Older posts” there.

    I added the following to my child theme’s style.css to hide it just on the home page:

    .home #nav-below {
    	display: none;
    }

    Did you actually want the “Older posts” link to work on your home page?

    Thanks for your reply! I agree, now that I think of it, hiding the navigation is an even better option. Me too, I’m using the featured images just to show my latest projects. Which leads me to another question:

    I have the maximum number of posts shown set to 12. Would you know how to change this to 6, on this page (home) only?

    Thanks again, I appreciate it.

    Thread Starter linux4me2

    (@linux4me2)

    The number is normally set in Settings -> Reading -> Blog pages show at most, but if you just want to change the number of images in your featured section, I think you would be able to do so by adding to the arguments in the query_posts command.

    The argument you want to add is “posts_per_page”. The Codex for it is here. In fact, we could have used that parameter to prevent the “older posts” from showing up, but then the setting on the Settings -> Reading page wouldn’t have worked, and I think hiding the output with CSS is thus preferable unless you want a different number of blog posts on your blog page than you do images in your featured section.

    I am having the same problem – upon clicking “Older Posts” the page wants to load “https://supah.com/page/2/&#8221; and then it just reloads the index page.

    not sure how to fix this, but when I am in the site preview it functions.

    very frustrating.

    All solved on my end, “posts_per_page” worked. Thanks a lot.

    I added 81 posts per page just so the work didn’t vanish from access, but it’s a messy solution for me.

    Pam

    (@pamrollerdesign)

    Thank you SO MUCH for this tip! I spent way too much time trying to figure out adding text above the gallery before finding your post.
    Thanks again!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Add Content to Image and Gallery Posts Static Home Page’ is closed to new replies.