WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Integrate recent post(s) of a category in a static page (4 posts)

  1. saphod
    Member
    Posted 7 years ago #

    Hi,

    I have already searched the forum, but I could not find a topic that matched my questions entirely. So I am sorry, but I have to create a new post. ;-)

    Here is my problem:

    I have a static "pages"-site in wordpress that will have some mostly static contents for things I find interesting and I want to write about (/pages/).

    Let's say I'd like to create a page "music" which is a subpage of the "pages"-site (e.g. /pages/music).

    First of all, there will be a "contents"-table that has links to all topics for that subpage (local anchors).

    Then, under the topic title "Recent Post(s)", I would like to integrate one or more recent posts of a specific category from my blog, which would be "music" in this example. They should exactly look the same way as in the blog (like, not cut to just the topic title, i.e. full text and maybe the comments, too). The user should then be able to click the topic which then directs him right to ALL the posts of the category (which is not so difficult with a link like e.g. "/category/music" and should not be the problem here).

    Then follows some more static content, like "My favorite bands", "My favorite lyrics" etc.

    I want to create that page right in the wordpress page editor.

    Now here is the problem:

    • I already know the "loop"-function. But how do I integrate it so that it will do what is mentioned above, and how do I put php-code in the page when I use the wordpress editor?
    • Do I have to create a new template for the subpage, or can I just use the one I always use for "pages"?

    Thank you very much in advance!

  2. saphod
    Member
    Posted 7 years ago #

    [UPDATE]

    Found a post here but I am not quite sure if it helps me for I am a php-newbie...

    My problem is how to include everything in "The Loop", for example the category, the number of posts to show etc...

  3. saphod
    Member
    Posted 7 years ago #

    [UPDATE]

    (Sorry, I would have liked to edit the last post instead of posting a new one, but it seems not possible...)

    So, I see that "The Loop" is triggered by the "have_posts()"-function - but how does this function detect which page I am on?

    For a better understanding:

    • When the main index template is used (main weblog page), only posts of my actual weblog are displayed (as it should be).
    • On my "/bookmarks" and any other page, I use an altered page template (that's what I guess... but I think I just copied the main template). I can write a post with the wordpress editor, too (with "edit page") - and only THAT single post is displayed (as it should be, because it is a page, somehow like a 'big' post, and not a new weblog entry).
    • "The Loop" is used in that altered template, too, and it is also triggered with the "have_posts()"-function... but how does that function know that it is supposed to show only the "page post" and not the whole weblog posts (and vice versa for the main weblog)?

    I hope I am not bothering anybody with these many posts, but it is really important for me. Thanks ;-)

  4. saphod
    Member
    Posted 7 years ago #

    [UPDATE]

    (OK, as no one is willing to answer ***just kidding*** ...)

    I found out the following things:

    • One can use the query_posts() tag to define which posts shall be displayed (e.g. just a special category or page).
    • PHP-Code will not work in posts (see "What Pages are Not"). Instead, one can use several plugins like RunPHP or Exec-PHP.

    I'll see if that works for my problem.

    So I declare this post "resolved". Anyone still interested can contact me via my website (see member profile).

Topic Closed

This topic has been closed to new replies.

About this Topic