WordPress.org

Ready to get started?Download WordPress

Forums

How do you put separate posts on a page in your header bar? (21 posts)

  1. thedailydoozy
    Member
    Posted 5 years ago #

    I've got my blog setup and wanted to know if it was possible to write blog posts and have them published on a page in the page menu below the header.

    Basically...I want to be able to write blog posts and be able to have them published in a page in my page menu instead of on the main page where all the other blog posts appear. Is this possible?

    If so... How do you do it?

  2. stvwlf
    Member
    Posted 5 years ago #

  3. thedailydoozy
    Member
    Posted 5 years ago #

    Thanks stvwlf. I'll check it out.

  4. thedailydoozy
    Member
    Posted 5 years ago #

    I took a look at the loop. It's too much code to deal with. I guess I'm just screwed.

  5. stvwlf
    Member
    Posted 5 years ago #

    what is the site url?

  6. thedailydoozy
    Member
    Posted 5 years ago #

  7. stvwlf
    Member
    Posted 5 years ago #

    what you want to do is not hard. You already have some of what is needed in place because you have posts assigned to categories, which is needed.

    Each horizontal menu item you want to add requires a WP page (not a post). Give it the title you want:

    News Entertainment Humor whatever

    The first step is making sure your theme is auto-adding these pages to your horizontal menu. Some do, some don't. If not they have to be added to the header.php file individually. If they are added and are in the wrong order, edit the page # of the page, on the editor page. Pages are ordered from lowest to highest page #. They don't have to be 1-2-3-4 you can leave gaps.

    The simplest way to tell WP what posts you want on a page is to create a custom page template for each page you want on the menu.

    copy the page.php file in your theme folder and make new files named things like page_news.php page_humor.php

    Add lines like this at the top of each of those pages:

    <?php
    /*
    Template Name: Humor Page
    */
    ?>

    now when you look at the page you made in the editor, you will see a section called Page Templates. Assign the Humor Page template to the page you created called Humor, etc etc.

    Now you have to add one line of code to each template page to tell it which post categories to include on that page.

    If you want categories 5, 9, 11, 15, and 23 to be on the humor page, your line of code looks like this:
    <?php query_posts('cat=5,9,11,15,23'); ?>

    You put that just before
    `<?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>`

    For each special page template you have made, change the query_posts statement to include the category codes for that page.

    If you only want one per page it looks like this
    <?php query_posts('cat=5'); ?>

    Its not very hard.

  8. thedailydoozy
    Member
    Posted 5 years ago #

    Thank you so much. I will try this now, and pray I get it right.

  9. thedailydoozy
    Member
    Posted 5 years ago #

    I think i understand all of this, but how do you create a php file?

  10. stvwlf
    Member
    Posted 5 years ago #

    copy the file page.php to a new one, such as page_humor.php

    you will either need an FTP program with FTP access to your website, or else to log into your hosting control panel and use the file management utility there.

    there is also a WordPress FTP plugin but I will leave it to you to find that if you feel that is helpful. I suggest another method.

    FTP will allow you to put new theme files you create on your local computer onto your webserver. Just make sure you are not overwriting any files with the same name on the webserver and you will be OK.

  11. thedailydoozy
    Member
    Posted 5 years ago #

    I'm using filezilla for ftp. But they don't have a function that allows you to open or edit php. Maybe I have to find a php editor? That's what I'm doing now. I'm lost, but hopefully that's what I need.

  12. stvwlf
    Member
    Posted 5 years ago #

    good

    do this

    download page.php to your computer

    change its name to page_humor.php (or whatever you want to call the page template.

    make the changes i suggested in the other post to that file.

    then drag the file back up to your theme folder

    MAKE SURE YOU HAVE CHANGED THE NAME to the new name before you load it on the server, so you don't write over your page.php file

    that is how you can create a new php file

    normally you just create a new text file and change its name from file.txt to file.php, and put your php code in it.

    you don't need a special PHP editor for the small amount of programming you are going to be doing. Even notepad will do just fine. Any text editor. Not a word processor.

  13. thedailydoozy
    Member
    Posted 5 years ago #

    Holy S**T!!!!!!! I got it to work. You are the greatest ever. I've been browsing the forums trying to figure this out for a month and know one knew what they were doing except for you.

    This just brightened the hell out of my day!!!

  14. stvwlf
    Member
    Posted 5 years ago #

    good for you!!!

    NOW, if you are gonna make one page per category, you are going to have to look into drop down menus pretty quickly, because you have a LOT of categories! way too many for a single row of horizontal menu choices

    keep at it, this stuff is not all that hard

  15. thedailydoozy
    Member
    Posted 5 years ago #

    I actually only need about 3 pages, so this will work really well. Just one more question... How do I prevent posts from going to my main page and only going into their category?

  16. stvwlf
    Member
    Posted 5 years ago #

    to keep posts off the main page, put this line before the loop

    <?php query_posts('cat=-5,-9,-11'); ?>

    the minus signs mean "exclude this category"

    your main page is probably driven by index.php, unless you've set up a static home page. if you have you will have to figure out which file to add that line to, by trial & error

    i was reading about you on your site. good for you, is what i say. just keep trying stuff, such as this. and your ventures. you will find your own way to do stuff - you have the right attitude.
    take care

  17. thedailydoozy
    Member
    Posted 5 years ago #

    Thanks for the encouragment.

  18. thedailydoozy
    Member
    Posted 5 years ago #

    When you say put it before the loop, do you mean put it at the top of the loop page, or find the loop in the index.php file and put it before there?

  19. thedailydoozy
    Member
    Posted 5 years ago #

    i figured it out. Thanks for everything. I'm done now. Thanks for your patience especially.

  20. reuabyor
    Member
    Posted 5 years ago #

    I got everything in there and it works...sort of. My posts don't show up as posts, but as plain static text. There is no way to comment. Any help with what I could have done wrong?

  21. 5starunited
    Member
    Posted 5 years ago #

    I hope this comes in a plugin soon! Great post!

    " Holy S**T!!!!!!! I got it to work. You are the greatest ever. I've been browsing the forums trying to figure this out for a month and know one knew what they were doing except for you.

    This just brightened the hell out of my day!!!"

    I have been looking all over for something. I believe it to be common place to build a page and the post and article or "post" to a category and have that post appear in the page.

    This allows for easy administration and understanding without having to be a super php wiz kid... I still love WordPress over Drupal...

Topic Closed

This topic has been closed to new replies.

About this Topic