0

How would I include a post from a specific category on my homepage in buddypress?

Example I have a category 'Homepage Banners' with an ID of 3.

In the admin I create a post and assign the 'Homepage Banners' category to it.

I then need this to show up on the homepage (the latest post).

I am new to WP/BP, any help appreciated.

Thanks.

3 Answers 3

1

You can also use a new query (with php enabled) so show a single post by ID, i.e. the post with ID 101:

<?php $my_query = new WP_Query('p=101'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
<?php the_title(); ?><?php the_content(); ?></a>
<?php endwhile; ?>

This can be used multiple times inside the WP loop without conflict.

Use Exec-PHP « WordPress Plugins or others.

1

Thanks to Simon Forster:

I had to slightly edit your code to end up with:

global $wp_query;

$args = array('cat'=>3,'posts_per_page'=>1);
$my_query = new WP_Query($args);
while($my_query->have_posts()):
    $my_query->the_post();
    the_title();
    the_content();
endwhile;

Thanks for the help :)

0

You could use the inline posts plugin http://aralbalkan.com/wordpress

Or a plugin called ggis-InlinePost (http://wordpress.org/extend/plugins/ggis-inline-post/) gives authors an easy way to insert a post within a page or another post. Simply add [ggisinlinepost id=”%id”] to your post. There are a few attributes to control the display of the inlined post’s title, content, metadata, and separators.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.