Skip to:
Content
Pages
Categories
Search
Top
Bottom

Making User Blogs Part of the Main Theme


  • Henry
    Participant

    @henrybaum

    Maybe this is blatantly obvious, don’t know. I want to make it so users are able to blog directly on the main site, rather than creating a totally separate blog. And some users would have the ability to write posts for the homepage, while others would only add content to the “blog.”

    Here, temporary URL: http://www.diymusicreview.com

    It’s separated into “Magazine” (the front page) and “Blog” (Not the front page). I’ve imported posts from the old WP.org site, but I can’t find where those users can add new posts without making them an administrator.

    Everyone else, I’d like them to be able to stay within the confines of the main site and have their entries in the blog section.

    Is this perfectly easy or perfectly impossible?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Contributors, Authors, Editors and Administrators can all write blog posts.

    https://codex.wordpress.org/Roles_and_Capabilities

    The tricky part is only allowing admin-authored posts in the homepage loop. Not sure how to do that. Perhaps with a conditional or a custom query? I’m not enough of a coder to answer that. Goggle is your friend :) If there will be only ONE admin however (you?) then it could be as simple as this (note: change “1” to whatever your author id is).

    <?php query_posts('author=1'); if (have_posts()): while (have_posts()): the_post(); ?>

    yay. my posts.

    <?php endwhile; else: ?>

    oops. no posts.

    <?php endif; wp_reset_query(); ?>

    You can use the same idea to display only posts from a certain category (i.e…. featured)… but I’m pretty certain you can’t restrict what categories a person can post in based on user level. So that probably wouldn’t help you.


    Xevo
    Participant

    @xevo

    You could fake this offcourse, make a wp theme that looks exactly like your buddypress theme.

    So you would only allow users to post in one blog or the other or both. That would work I guess. Not as fun as trying to set up a custom query for your homepage loop however. LOL.


    Henry
    Participant

    @henrybaum

    For future reference, I figured out how to do this: I’m using the plugin

    https://buddypress.org/forums/topic/groupblog-v13-adding-members-instantly-thanks-boone

    So long as people join the group associated with the main site, they’re able to add blogs to the site. I make everyone a contributor so their blogs aren’t published automatically and I can then add them to the category – Member Blogs.


    Xevo
    Participant

    @xevo

    @ Henry: That’s ok for a small community, but for a big one you’ll need an automated process.

    I guess that would work. Seems like a very round about method however and you’re creating lots of blogs and database tables and such that you don’t need if all you want to do is have only YOUR posts show up on the homepage. It that’s the goal… just your posts on the homepage (and it sounds like that based on your last post)… then this is very simple. The solution is already above. Just add that query before the WordPress loop on your home.php file. So simple:

    <?php query_posts('author=1'); ?>

    and reset the query at the end of the loop:

    <?php wp_reset_query(); ?>

    This assumes that your admin account had an author ID of 1… which is safe to assume.

    Here is a slightly more complete example. But really… this is an extremely simple loop. You’ll probably want more stuff in there… like tags, dates, categories, etc. But this loop will work to show only posts by author ID 1. I just figured it would be good to see what I’m talking about in more context.

    <!-- custom query -->
    <?php query_posts('author=1'); ?>

    <!-- the loop -->
    <?php if (have_posts()): while (have_posts()): the_post(); ?>
    <h3><?php the_title(); ?></h3>
    <p><?php the_content(); ?></p>
    <?php endwhile; else: ?>
    <p>No posts.</p>
    <?php endif; ?>

    <!-- reset the query -->
    <?php wp_reset_query(); ?>


    Henry
    Participant

    @henrybaum

    I may not be following b/c I’m not so php literate, but my goal is to not only have my posts on the frontpage, it’s other authors as well. And this gives me the ability to front-page member blog posts by selecting the category “features.”

    By “add blog” I mean add blog posts, not an entirely new blog, if it makes a difference. I’m just allowing people to write a new post.

    I’m not sure why this isn’t scalable for a larger community.

    Gotcha. Before you had said you only wanted posts from the Administrator on the homepage… which would be you… so that’s where I was coming from.

    The solution is almost the same however. If you’d like to do this without any plugins… just one little line of code… you could do this in the “loop” on your home.php file.

    <?php query_posts('category_name=Featured'); ?>

    [your wordpress loop here]

    <?php wp_reset_query(); ?>

    The loop by the way is simply a bit of code that iterates through all the posts for a particular page and displays them. So on the homepage… the loop shows ALL posts by default (up to whatever number you have configured in the dashboard… so the 5 most recent perhaps). If you click on a tag… then the “loop” shows all the posts with that tag. By setting up a custom query on the homepage… you are simply modifying the collection of posts that the loop will iterate through. So that little line of code simply limits the posts that the loop will iterate through as being posts from the category named “Featured”.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Making User Blogs Part of the Main Theme’ is closed to new replies.
Skip to toolbar