• Resolved mxalpinestar

    (@mxalpinestar)


    Ok so i found the tutorial to add the lastest post on my homepage which is :

    <?php
    // Include WordPress
    define('WP_USE_THEMES', false);
    require('./wordpress/wp-load.php');
    query_posts('showposts=1');
    ?>

    and the code for the body where i want it displayed is:

    <?php while (have_posts()): the_post(); ?>
     <center><h3><?php the_title(); ?></h3></center>
     <?php the_excerpt(); ?>
    <a href="<?php the_permalink(); ?>" target="_new">Read more..</a>
    <?php endwhile; ?>

    So what im trying to find out, is what coding do i need to add/change to so it will only display like the first sentence of the post and not the full post. So that i can have the read more link at the bottom and really have them click it and read more. cause right now its displaying the full post and it is pointless to have the read more link.

Viewing 8 replies - 1 through 8 (of 8 total)
  • All post contents will display now? I saw you wrote the_excerpt() which only display the first 55 wordpress.

    You can replace it with the_content() and add <!–more–> in each posts(after the first sentence as you would like to display only the first sentence.)

    Thread Starter mxalpinestar

    (@mxalpinestar)

    And how would i know where to stop for the sentence? since im posting this only on the page outside of the word press blog? its on a seperate page. or would i just make the code this:

    <?php while (have_posts()): the_post(); ?>
     <center><h3><?php the_title(); ?></h3></center>
     <?php the_content(); ?>
    <a href="<?php the_permalink(); ?>" target="_new"><!--more-->Read more..</a>
    <?php endwhile; ?>

    would that work?
    the page i have this code on is : https://www.jessicadurrant.com/blog.php

    and my wordpress blog is at: https://www.jessicadurrant.com/wordpress/

    If the post in question was created within WordPress and is being pulled out of the database via WordPress. it will know when to “stop” the teaser display.

    Thread Starter mxalpinestar

    (@mxalpinestar)

    Nope the php is what im putting on my page to display the posts. i didnt add any coding to the wordpress post that i created. So your saying i have to add php code in the post on wordpress in order for the teaser i am displaying on the homepage to show only part of the post?

    So your saying i have to add php code in the post on wordpress in order for the teaser i am displaying on the homepage to show only part of the post?

    Perhaps you need to look at Integrating_Wordpress_with_Your_Website.

    Thread Starter mxalpinestar

    (@mxalpinestar)

    no i think you need to reread my first post on here. I have done that already and it works just fine. Thats not what im trying to get at now. Im trying to find a way to no display the full post on the homepage. as of right now the coding they tell you to input on the homepage to display the posts it displays the full post and then links read more. But there is no point in having that if it shows the full post already. I want it to only display the first sentence and then the read more part would be useful.

    Thread Starter mxalpinestar

    (@mxalpinestar)

    lgkevincc, knows what im talking about and he had the right info that i need, i just need to know where to place the <!–more–> and if i replace the <?php the_excerpt(); ?> to <?php the_content(); ?> how much of the post will it display?

    Thread Starter mxalpinestar

    (@mxalpinestar)

    Oo i found it out! a way that works. So on my page i added this php function:

    <?php
    function new_excerpt_length($length) {
            return 12;
    }
    add_filter('excerpt_length', 'new_excerpt_length');
    ?>

    So then in my body where i wanted it to display the post i just keep it:

    <?php while (have_posts()): the_post(); ?>
    <center><h3><?php the_title(); ?></h3></center>
    <?php the_excerpt(); ?>
    <?php endwhile; ?>

    And now it only displays the first 12 words of the post and displays: …Read More –> with a working link.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘wordpress display lastest post on homepage’ is closed to new replies.