Skip to:
Content
Pages
Categories
Search
Top
Bottom

SNIPPET: Intelligent post page templates


  • @ChrisClayton
    Participant

    @chrisclayton

    Afew months ago Diaspora (the ruby-based social networking opensource project) released what they call ‘intelligent post page templates’ but did you know, it’s 10 times easier to implement in BuddyPress?

    This is a snippet that i’ve had in my snippets folder for a while and i only recently remembered it when i saw a post about diaspora’s update.

    Within members/single/permalink.php just replace “ with

    and then if you want a different template for single permalink views for BP Album photos, just create a new /activity/entry.php template called /entry-bp-album-picture.php and modify to your hearts content… All BP album photos will now use that template and others will just use /entry.php.

    Credits where credits due: This is based on Twenty Eleven’s Post-type Loop template_part. Thanks WordPress!

    EDIT: Note that str_replace just replaces the underscores inside the activity types to hyphens (works without the str_replace, but i like the consistent look with other templates that use hyphens to separate words)

Viewing 2 replies - 1 through 2 (of 2 total)

  • shanebp
    Moderator

    @shanebp

    Interesting… haven’t tried it yet.

    So, if get_template_part can’t find a different template for a particular activity type (because a different template doesn’t exist) it will revert to calling entry.php ?

    Note: I think you meant
    members/single/activity/permalink.php
    rather than
    members/single/permalink.php


    @ChrisClayton
    Participant

    @chrisclayton

    You’re right! Thanks, edited the original post.

    And Yes. It uses get_template_part which using the BP Albums example again, will search for the following templates and php require() the first it finds. In this priority.

    child-theme/entry-bp-album-picture.php
    child-theme/entry.php
    parent-theme/entry-bp-album-picture.php
    parent-theme/entry.php

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘SNIPPET: Intelligent post page templates’ is closed to new replies.
Skip to toolbar