• I have a site which is a tourism guide for beaches. I want related content to appear on the sidebar on single entries, such as how to get to the beach or travel stories, while the main section of the article appears on the main column.

    The way I solved it is a bit intrincate, I use a custom tag on articles where I want the sidebar, which is checked by an if statement (get_post_meta) on sidebar.php. Then I use the get_a_post plugin (tweaked) to display the content of a separate post (marked private) with the slug name $post->post_name . “-sub”. (check at http://www.almanaqueazul.com/?p=37)

    This is an ugly hack, and too complicated for regular use.

    There must be an easier way, right? I’ve thought maybe there is a plugin that hides text between quicktags in an entry but then allows me to display only that text, if present, with a separate template tag. Or maybe there is another way?

Viewing 7 replies - 1 through 7 (of 7 total)
  • This doesn’t do quite what you’re asking:

    http://www.coffee2code.com/archives/2004/07/25/plugin-hide-or-cut-post-text/

    but considering the hack you described, I suspect you may be able to modify it to fit your needs.

    Thread Starter mir123

    (@mir123)

    Possibly… those preg_replace expressions are quite intimidating, though!

    How can I somehow split the entry text in two parts and then display one or the other?

    Hmmm. If you aren’t using the excerpt for anything, you could put the sidebar stuff there. Otherwise, you could paste a big chunk of text into a meta field and just grab that for the sidebar (granted, might not all be visible.

    What you almost want is something like [more] or [nextpage], but not show the rest of the content as the main body.

    But I think the excerpt thing would work well if you aren’t using it in your theme already…

    -d

    Using the excerpt field is an option, but keep in mind there can be unintended consequences of such a workaround (such as if displaying the excerpt in other portions of your blog; it can also appear in your feeds).

    Yeah… true. This is kinda tricky any way you slice it.

    An alternative would be to have a category of sidebar-posts that is hidden from the normal view. Then, in your main post, instead of trying to ‘auto-link’ using the post slug, just use the meta/custom field to specify the post-ID of the post to draw the sidebar content from. Yes, it’s a manual step to insert the ID instead of some auto-relation — you could also create two drafts at the same time, make the first one the body, the second the sidebar, and always use postnum+1 for the sidebar content… Just a thought.

    -d

    Thread Starter mir123

    (@mir123)

    The excerpt seems like the right option, I don’t use it in my template. Having all the text for an entry being actually in one entry is much better than what I am doing now. How does the excerpt end up in RSS feeds?

    Options > Reading, Syndication Feeds set to summary. Also, the RSS (but not the RSS 2) feed is limited to excerpts only, so that’s one you may wish to avoid pointing readers to.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Post content on sidebar?’ is closed to new replies.