Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Best Way to Show Upcoming Events + Latest Blog Posts on Homepage WordPress

  • SOLVED

So, here's the screenshot of what I'm wanting to do: [[LINK href="http://barefoot-webdesign.com/img/lifebridge-church.png"]]http://barefoot-webdesign.com/img/lifebridge-church.png[[/LINK]]

In the left column, I have links to 2 pages: one titled "Fifty-fifty", and the other titled, "Seventy-two".

In the center column, I need to know the cleanest way to <strong>automatically display events (sorted by date in order of next upcoming event, and limited to 3 or 4 event listings)</strong> that have been entered in the WP backend. I would also like the 'View All Upcoming Events' button to go to a page that lists all upcoming events entered in by the user. I guess that also poses another question... <strong>what would be the best way to allow me to enter in events (with date, time, title of events, description, etc.) so that it outputs a list of all upcoming events?</strong>

In the right column, I need to <strong>automatically list the last 2 blog posts (sorted by most recent, with date and excerpt displayed, but limited by a certain number of words, so that each excerpt is relatively the same height)</strong>. The user would click on the title of each blog post to read more of the post.

Thanks for your help, and may the best man win!



Answers (5)

2010-08-13

Ashfame answers:

Hi Spencer,

For events, you can use any plugin. I use this one - http://meandmymac.net/plugins/events/

And for upcoming posts, you can use this code on a theme page

<?php query_posts('showposts=2'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<span class="datetime"><?php the_time('j. F Y'); ?></span>
<?php ashfame_get_stripped_content(100); ?>
</p>
<?php endwhile;
else: ?><p>No future events scheduled.</p>
<?php endif; ?>


<em>Edited the above code, I thought you wanted to list upcoming posts</em>

Paste this in your functions.php file

function ashfame_get_stripped_content($limit)
{
$content = get_the_content();
$temp = " (<a title=\"Continue Reading..\" href=\"";
$temp = $temp.get_permalink();
$temp = $temp."\">Continue reading &#8594;</a>)</p>";
$content = str_replace('</p>',$temp, $content);
echo $content;
}


Also I can give you the line of code which will enable you to embed your events listing anywhere. Let me know if you want me to do so.


Spencer Barfuss comments:

Hey Ashfame, I do want to list the 3 or 4 upcoming FUTURE events in the center column, and then on the right column, I want to display the 2 most recent blog posts to automatically show up.


Spencer Barfuss comments:

So, the right column should display the 2 latest blog posts (past).


Ashfame comments:

Yes! Thats what the code does. It will show the last two posts.

For events, using that plugin and with a single line of code, you can have a listing too.


Spencer Barfuss comments:

This is the code that I copied and pasted, and it is not limiting the post.

<?php query_posts('showposts=2'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><a href="<?php the_permalink();?>"><?php the_title(); ?></a></h2>
<span class="datetime"><?php the_time('j. F Y'); ?></span>
<?php ashfame_get_stripped_content(20); ?></p>
<?php endwhile;
else: ?><p>No future events scheduled.</p>
<?php endif; ?>


I've attached a screenshot...