Displaying Wordpress further in the input footer

here is what i want to do:

I have a blog post that I only want to display at a certain point. Therefore, in the message I put

<!--more-->

      

in the correct position.

My content.php looks like this:

<div class="entry-content">
    <?php the_content('read more'); ?>
</div><!-- .entry-content -->

<footer class="entry-footer">
    <?php mytheme_entry_footer(); ?>
</footer><!-- .entry-footer -->

      

The read more link is displayed immediately after the content, where it should be. But how can I display it inside the footer with a "Comment" link?

Is there a shutter speed solution?

<?php the_excerpt(); ?>

      

I think it would be even better, because I didn't have to put a line in every message.

+3


source to share


2 answers


You can remove 'read more' using the following filter in functions.php

:

add_filter( 'the_content_more_link', 'remove_more_link', 10, 2 );

function remove_more_link( $more_link, $more_link_text ) {
    return;
}

      

Now you can create your own side link inside footer:

<footer class="entry-footer">
    <a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>">Read more</a>
    <?php mytheme_entry_footer(); ?>
</footer><!-- .entry-footer -->

      

Edit:



The following question was asked in the comments below:

I used the_excerpt () instead of the_content (). Is it possible to only show the link if the post is actually too long?

You can do this by checking if the excerpt is different from the content. If so (which is why there is more content than the excerpt shows), then you can show the link to the link:

<?php if ( get_the_content() != get_the_excerpt() ){ ?>

    <a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>">Read more</a> 

<?php } ?>

      

+2


source


I am using one workaround:

//REMOVE 'MORE' LINK AND HARDCODE IT INTO PAGE - TEASER JUST PLAIN ELLIPSIS
function modify_read_more_link() {
    if ( is_front_page() ) {
        return '...';
    } else {
        return '</div><footer class="clearfix"><a class="mg-read-more" href="' . get_permalink() . '">Continue Reading <i class="fa fa-long-arrow-right"></i></a>';
    }
}
add_filter( 'the_content_more_link', 'modify_read_more_link' );

      

Explanation: For the first page, I have an overview that can only be clicked in the header of the post. And for the blog list (after else

in the above function.php

):



<article>
  <header></header>
  <div>
    <?php the_content(); ?>
  </footer>
</article>
      

Run codeHide result


In which you can notice missing div

closures and footer

opening tags. It's a bit messi, but it brings the original Wordpress Teaser to the next division.

Thanks for reading.

0


source







All Articles