Skip to:
Content
Pages
Categories
Search
Top
Bottom

Adding static featured blogs with dynamic authors avatar on home page?

  • @jwack

    Participant

    I have a static list of featured blogs on my home page. I would like to dynamically pull in some items from each, like so…
    Blog Name
    Blog Author
    Blog Author’s Avatar
    Latest Post

    Can someone point me in the right direction, thanks!

Viewing 16 replies - 1 through 16 (of 16 total)
  • @jwack

    Participant

    i still can’t find what I am looking for, can anyone assist?

    @pcwriter

    Participant

    @rogercoathup

    Participant

    @jwack – you’ll hit some performance problems –

    You’ll need to use switch_to_blog(blog_id) to change to each blog, and extract the post, author, etc. details.

    Each call to switch_to_blog incurs a performance overhead.

    Your alternative is to store the information you need in the activity stream when a post is saved:

    Most of the information you need is already stored there for you. Take a look at the function: bp_blogs_record_activity()

    You can then code a custom activity loop on your home page, that loops through activity items for new blog posts and checks whether they are in your list of featured blogs: https://codex.buddypress.org/developer-docs/custom-buddypress-loops/

    @jwack

    Participant

    @rogercoathup Thank you! Finally a place to start from! hopefully I can pull this off, I am not a programmer at all.

    @pcwriter thanks, I did check the codex but couldn’t find what I was looking for

    @rogercoathup

    Participant

    @jwack – it won’t be easy as a non-programmer.

    Your best route is probably to make use of switch_to_blog(); and use a ‘standard’ WordPress posts loop on each blog in turn.

    Search ‘wordpress loop’ in Google. You’ll also need to call functions to fetch the author, etc.

    You may be able to figure out your loop code from the examples on the WordPress codex… if not, there’s no short cut and you should book up on the PHP programming language.

    @jwack

    Participant

    @rogercoathup Is there a way to reuse the same code that is used on the blog directory page? (blog-loop.php) I just realized that page does exactly what I want, almost. Instead of returning every blog, I would only want, say blogs with the id 1, 2, 3 and 4 (my featured blogs).

    Or am I wrong on this?

    @rogercoathup

    Participant

    In theory that should work. However, I can’t see any simple template tag to get the blog ID of the current blog inside the blog loop – am I missing something obvious??

    @jwack

    Participant

    since i know what blog IDs i want to use there has to be a way to limit the loop to only get the specific info for those blogs?

    @rogercoathup

    Participant

    yes, you know your IDs. But, I couldn’t see any obvious template tag to find the ID of the blog you are currently processing inside the bp_has_blogs() loop. You’ll need that ID to compare against your list of featured blog IDs.

    I’ve asked it as a separate forum question for you: https://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/how-do-i-find-the-blog-id-of-the-current-blog-inside-a-bp_has_blogs-loop/

    @mercime

    Participant

    @rogercoathup

    Participant

    @mercime – that may give a solution for @jwack.. Although the original post was asking featured blogs, not for specific featured posts

    @jwack

    Participant

    Thanks guys, I will have a look through this tonight and see if I can come up with something.

    @jwack

    Participant

    @mercime that plugin would be perfect if it were featured blogs and not posts

    @mercime

    Participant

    @jwack

    Participant

    O my! Now that is more like it :-)

    @mercime

    Participant

    Search term which got it = featured blogs list wordpress = first in the list ;-)

Viewing 16 replies - 1 through 16 (of 16 total)
  • The topic ‘Adding static featured blogs with dynamic authors avatar on home page?’ is closed to new replies.
Skip to toolbar