• Hi,

    I have an non wordpress website, and use wordpress for the latest news section only. This works great on the latest news page, but I want to pull in the most recent 2 excerpts onto the homepage also. All my wordpress files are located on the server under a directory named ‘news’.

    I can pull the 2 excerpts into the home page using this code

    <?php query_posts('showposts=2'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <em><?php the_date(); ?></em><br/>
    <?php the_excerpt (); ?>
    <?php endwhile;?>

    However, I need to either change the ‘read more’ link to the direct URL of my latest news page, or remove it altogether and add my own link…

    I gather I may need to amend the code in the post_template.php file however after multiple experiments I just can’t get it to work. Im sure its quite straightforward but its becoming very frustrating now.

    All help greatly appreciated,

    thankyou!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You can filter the excerpt links, like so;

    function new_excerpt_more($more) {
           global $post;
    	return '<a href="'. get_permalink($post->ID) . '">Read the Rest...</a>';
    }
    add_filter('excerpt_more', 'new_excerpt_more');

    Source: https://codex.www.ads-software.com/Function_Reference/the_excerpt

    Thread Starter roxette cassette

    (@roxette-cassette)

    Thanks, I have read the source but still a bit confused, but how do i amend this relevant to my situation?

    I added this to function.php as stated in the source

    function new_excerpt_more($more) {
           global $post;
    	return '<a href="https://MYURLHERE.com">Read more...</a>';
    }
    add_filter('excerpt_more', 'new_excerpt_more');

    However I get this error,

    Fatal error: Call to undefined function add_filter()

    ?

    Thread Starter roxette cassette

    (@roxette-cassette)

    Does anyone have any advice for me on this? Still trying to work it out ??

    Thankyou!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Simple 'read more' problem, probably a quick answer?!’ is closed to new replies.