WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin] One post + some titles on homepage (4 posts)

  1. Digitalminds
    Member
    Posted 5 years ago #

    I'm looking for a plugin that will help me getting the follow result:

    - Show 1 complete post on the homepage
    - Show the titles of last 10 posts, linking to the complete post page.

    Do you know a plugin like this?

  2. moshu
    Member
    Posted 5 years ago #

    You don't need any plugin for that. That is a theme design/coding issue.
    And there have been posts in the forum describing how to do that.

  3. mores
    Member
    Posted 5 years ago #

    you might get lucky by searching for "featured post" too.

    Basically, you edit your index.php. the simplest would be to add a counter and display the first post differently.

    Basically your loop goes like this:

    <?php
    if (have_posts()) : while (have_posts()) : the_post(); ?>
    	<h1><?php the_title(); ?></h1>
    	<p><?php the_content(); ?></p>
    <?php endwhile; ?><?php endif; ?>

    Change it to

    <?php
    $postnum = 1;
    if (have_posts()) : while (have_posts()) : the_post(); ?>
    	if ($postnum==1) { ?>
    		<h1><?php the_title(); ?></h1>
    		<p><?php the_content(); ?></p>
    	<?php } else { ?>
    		<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    	<?php } ?>
    	<?php $postnum++; ?>
    <?php endwhile; ?><?php endif; ?>

    Display content only on first post, show the rest of the posts only in headline 2 with link.

  4. Digitalminds
    Member
    Posted 5 years ago #

    It seems not to work. When I place the code above in the index.php file nothing is changed at my homepage but my full-post page doesn't work anymore. So I thought it was code to place the code in the home.php file, but then my homepage doesn't work anymore. Can someone help me?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.