• SilkCharm

    (@lpapworth)


    Hi, I have Simple:Press forum as the front/Home Page. How do I add a “Blog” menu item on a custom menu when “static page as home page” has been chosen?

    Feels like it should be easy but I’m missing something. ??
    Thanks!

Viewing 15 replies - 1 through 15 (of 33 total)
  • vtxyzzy

    (@vtxyzzy)

    Just create an empty Page and assign it as the Posts page in Admin->Settings->Reading.

    What if you need to leave “Recent Posts” checked? I basically built my website around the initial main page posts (cut it to 3 posts), but would like to have a menu item that says “Blog” and has 10+ recent posts for people to search. How can I achieve that? My website is at https://www.derekmunson.com if you need to see what I’m talking about.

    Thanks for any help you can give! ??

    Sounds like you should make a copy of index.php into a custom template and assign it to a blank page to go in your menu.

    1. Make a copy of index.php and name it myblog.php
    2. Modify myblog.php by changing the first few lines into the code shown below.
    3. Create a blank Page titled ‘Blog’ and set the template to the ‘My Blog’ template.
    4. Add the ‘Blog’ page to your menu.

    Here is the code (UNTESTED!):

    <?php
    /*
    Template Name: My Blog
    */
    ?>
    
    <?php get_header(); ?>
    <?php $options = get_option('pb_options'); ?>
      <div id="middle-contents" class="clearfix">
    
       <div id="left-col">
       <?php global $query_string;
       query_posts($query_string . '&posts_per_page=10'); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    Wow, great advice! Thanks for the help! ??

    So, I’ve now got the blog page up (with it’s own template, as per your instructions), but no posts are showing up! I compared the code on my original index.php to the new template page to see what I might need to add; below the last line of code you gave me, I added the following:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    It seemed like what I’d need in order to make posts show up, but still I’ve got nothing. Any more ideas? I’m so thankful for your help! ??

    Okay, so the code I posted got moderated – BUMMER! Didn’t know the rules on that, so that’s my bad.

    So, just to be double-sure, I downloaded the original index.php for my theme (Piano Black), and added your “Template Name” PHP lines to the top of it to see if it would populate with posts – it didn’t. THAT is surprising to me; I would think that, if anything, the fresh untouched home page code would give me the result I was shooting for, but it didn’t – I get the same result.

    What should I try now? Thanks again.

    First, WordPress uses as specific template file for displaying the Blog Posts Index. You can’t name the template file any arbitrary name. You must name this template file home.php in order for WordPress to use it for the Blog Posts Index.

    Second, if you are displaying a Static Page on your Front Page, you need to do the following:

    1) Create the home.php template file (if necessary; it probably isn’t)
    2) Create a new Static Page, which can be any arbitrary title, e.g. “Home”, or “Blog” or “News” (or whatever you want it to be)
    3) Go to Dashboard -> Settings -> Reading
    4) Underneath the “Front Page Displays” setting, find the “Posts Page” setting, and in the dropdown list, select the Page you created in Step 2 (e.g. “Home” or “Blog” or whatever)

    Thanks for the reply, Chip!

    My ‘Home’ page isn’t a static page (I don’t think), because I have a small sample of 3 of my most recent posts populated on there. (When creating the site, I basically took the Main Index Template and re-arranged/CSS’ed it around the feed there.)

    So, my question would be this: to do what you’re suggesting, it sounds like I would need to create a new static Home page, right? Is there a safe/easy way to copy the current code? And with the news/blog feed, can I punch that in somewhere still?

    (Disclaimer: I’m not much of a PHP coder, but I do know my XHTML/CSS well enough to work things around.)

    Thanks for your time and patience! Looking forward to more help! ??

    @drumology2001: if your Front Page is set to display “Recent Posts”, then you shouldn’t need to do anything with template files.

    1) Go to Dashboard -> Appearance -> Menus
    2) Find the “Pages” metabox
    3) Ensure that the “View All” tab is selected
    4) The first checkbox should be “Home”. This should be your Front Page/Blog Posts

    Hmmm…okay, so I checked that box and hit the “Add to Menu” button, but I didn’t see any change in my site. Was I supposed to?

    Ultimately, when you go to the “Blog” page, I’d like the result to look something like this page: https://www.derekmunson.com/?m=201010, with maybe the latest 10 posts, in an abbreviated format like we see there.

    What am I missing, Chip? Have you visited my website to see the homepage and the way it’s set up? Not sure if that would help the discussion. Sorry if I’m coming off dumb as bricks…just trying to get things the way I need them with as little pain as possible. ??

    Hmmm…okay, so I checked that box and hit the “Add to Menu” button, but I didn’t see any change in my site. Was I supposed to?

    I see a “Home” link in your Header Navigation Menu.

    That’s always been there since day one, though. Making that checkbox change you suggested changed nothing about the site or the way it operates.

    That’s always been there since day one, though. Making that checkbox change you suggested changed nothing about the site or the way it operates.

    Then I’m confused about what you’re wanting? Can you clarify?

    Sure, no problem! I know it gets confusing. ??

    On the Home page (www.derekmunson.com), in the bottom left is a box called “Recent News”; when I started my WordPress site, I built the homepage around this box, and I used CSS to define the height, width, and background image of it. I made it so that it only showed 3 posts by giving it’s DIV container a setting of “overflow: hidden;”, effectively cutting off the rest of the list of posts that would, by default, normally show up on this Home page.

    Now, the Home page’s “Recent News” box only shows the 3 most recent Posts that I have created, but what I’d like to create a is a page called “Blog” that has 8 to 10 of my most recent posts, with pagination so that the user can go back further and read older Posts, if they like. This “Blog” page would be it’s own Page, clickable in the main menu bar at the top of the website. (I have created this page, but it currently has no content – just a disclaimer that it will be populated soon.) (I hope!) ??

    The reason I’d like to add this option is that if you’re on my site – say, on the “Gear” page – and you’d like to see some of my articles/posts from years past, you can just click on “Blog” and see a page full of them, rather than having to click “Home” and then only seeing the most recent 3 and having to navigate from there.

    Does this make sense? I hope so. I’m basically looking for another easy navigation option for users to get to my posts.

    @drumology2001: this issue appears to be entirely unrelated to this topic. In order to provide more accurate help, can you re-post your last post as a new topic?

    @chip Bennett, I think I was on the right track with the template file. I believe that what is needed is a ‘pseudo-blog’ to display the most recent blog posts.

    @Drumology, I didn’t mean to omit the code following what I posted. I only meant to change the first few lines of myblog.php to match what I posted and leave the rest unchanged. Is that what you tried?

Viewing 15 replies - 1 through 15 (of 33 total)
  • The topic ‘CUSTOM MENU: Add "Blog" menu item’ is closed to new replies.