Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End [SOLVED] Multiple Page Posts

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #28648
    noahgelman
    Participant

    I’m wondering if there is a way to choose which of your pages a post will appear on. Is there a snippet of code or a plugin that lets me do this?

    #73621
    TheDoc
    Member

    Most certainly. You’ll want to make sure to assign each post with the proper category. Then, depending on how your templates are set up, you can have a page show only certain categories.

    Let’s say you have 3 pages: Hockey, Cake, and Money.

    If they all use the same template (eg, page.php), then you’ll need to do something like:

    if page Hockey then > show posts from category "hockey";
    if page Cake then > show pasts from category "cake";
    etc.

    This is a slightly more complicated piece of code than what is below, so let me know which one you need before I attempt at explaining! haha

    If the are using different templates (eg, hockey.php, cake.php, money.php), then you simply need to run one single loop with a query like so (‘5’ is the category id, replace that number):

    Code:



    (that was from the snippets section, btw)

    #73626
    noahgelman
    Participant

    Thanks for the help. I missed that snippet when I looked through. I would have a separate page for each, so I do only need the one loop, and then just change it on each page.

    This made me think of a follow-up question though, how would you exclude a specific category if you don’t want it on a page?

    Again, thank you for the help.

    #73631
    TheDoc
    Member

    Remember, you’re not editing the pages themselves within WordPress, you’ll need to edit the actual template (which looks like, in your case, is page.php).

    Can you confirm that all pages you’d like to do this on are all using the same template?

    You can do all sorts of wonderful queries, including excluding a category. Check out the WordPress Codex for all of your answers on the matter:

    http://codex.wordpress.org/Function_Ref … uery_posts

    If the answer to your question above is "yes", then we can discuss exactly what you’d like to accomplish!

    #73581
    noahgelman
    Participant

    No, they all aren’t using the same template. Each page is a custom page.php. I can edit the loop on any of page the way I want.

    #73636
    TheDoc
    Member

    Excellent, that makes things even easier!

    Do you get how the query_posts function works?

    #73637
    noahgelman
    Participant

    Yes. I do. And thank you very much. That link was also very helpful too.
    :D

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Back End’ is closed to new topics and replies.