• I’m sure I’m missing somsething here, but I cannot figure out how to link to my main blog page. For instance, on my website (www.jimmyday.com), I’d like to link the menu item “journal” to a page which displays the five most recent blog posts, regardless of category.

    In other words, it should look exactly like my tag and category pages (https://jimmyday.com/category/education), but show ALL categories.

    Really appreciate any and all help.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Do you have a posts page set up?
    If not create a WP page on which the posts will be displayed and tell WP to display posts on it – Dashboard / Settings / Reading

    Since you want the page to come up on the Journal link it makes sense to call the page “Journal”. If the page slug is “journal” the URL will be https://jimmyday.com/journal/

    The page will by default use the index.php theme template to display the posts page. You can modify index.php to display only the 5 most recent posts. See this page:
    https://codex.www.ads-software.com/Function_Reference/WP_Query
    the setting is “posts_per_page”

    If you remove the paging links at the bottom of index.php the user will only see the most recent 5 posts with no access to older ones.

    Thread Starter jimday1982

    (@jimday1982)

    Thank you for your reply. I created the journal page, although as you can see from the link (https://www.jimmyday.com/journal), it isn’t currently displaying any posts.

    I checked and I do have an index.php template and as best as I can tell, it is coded to display posts, so I’m not exactly sure what the issue is. Are there any other settings I should check?

    Thanks again for your help.

    Did you do this part?

    create a WP page on which the posts will be displayed and tell WP to display posts on it – Dashboard / Settings / Reading

    set Static Posts / Posts Page to Journal

    Thread Starter jimday1982

    (@jimday1982)

    I did try that, however while Dashboard / Settings / Reading DOES give me the ability to set a post page, it forces me to select a page as my font page which I do not want to do since I want to keep my existing front page as is.

    That being said, when I do choose my Journal page as my post page, the Journal page displays absolutely perfectly. Unfortunately, that option does not allow me to keep my current front page.

    Is there some way I can set my post page without losing my current home page layout?

    You can make a pseudo-posts page by overriding the default WordPress query for the loop on the Journal page. The instructions are on the Codex page I linked you to earlier.

    The alternative is the same thing in reverse, to make a custom page template for the homepage and copy the existing home page code onto this custom page template.

    You will probably find #1 easier.

    Try putting this before the WordPress loop in your theme’s page.php template file:

    <?php if ( is_page('journal') ) {
       wp_query('posts_per_page=5');
    } ?>

    It might need another parameter or two but I think that will do.
    See the Codex page I linked you to above for more details.

    Thread Starter jimday1982

    (@jimday1982)

    In the following code:

    <?php if ( is_page('journal') ) {
       wp_query('posts_per_page=5');
    } ?>

    The first and last lines work without issue, however the wp_query call is giving me an undefined function call error message.

    Any ideas?

    That’s because I spaced out

    <?php if ( is_page('journal') ) {
       query_posts('posts_per_page=5');
    } ?>
    Thread Starter jimday1982

    (@jimday1982)

    Thank you so much for all your help! That did the trick!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to link to main blog page?’ is closed to new replies.