Forums

Best method to display a specific post in a seperate area of a theme (2 posts)

  1. gavinsmith
    Member
    Posted 3 years ago #

    Hi there,

    I'm using WordPress as a CMS, and there are a couple things I still haven't quite figured out. One is the best way to call a specific post into a specific area of a theme as cleanly as possible. I think the best way to go about this from what I know is to put the post I want to appear in this separate area in its own category, then call that specific category within the template, but I'm still not quite sure how to go about that.

    Alternatively, and actually ideally, I would like to use sidebar.php - I'm not currently using it in my theme. Thing is, though, I need the content of this area to be editable via the admin section in a WYSIWYG editor. I'm sure there must be a plugin to do this type of thing, allow editing of extra areas of the site?

    I hope that made sense, let me know otherwise and I'll try to clarify. I'd appreciate any suggestions and thank you in advance for any input!

    Gavin

  2. stvwlf
    Member
    Posted 3 years ago #

    Hi

    you can use get_post() to load one specific post, in a theme template file or in the sidebar or header or footer. This allows you to edit it in the WP editor and display it wherever you like.
    example usage

    <?php
    $post_id = 2; // substitute the actual post ID for "2"
    $my_post = get_post($post_id);
    echo "<p>$my_post->post_content</p>";
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.