Support » Themes and Templates » Having Trouble With Customized Read More Link

  • Resolved DrowSserp


    I’ve styled my read more links as buttons but am having trouble making them right. I suspect the problem is with my php which I am pretty terrible with.

    My problem is this..

    <a class="more-link" href="http://www.mywebsite.zsz/mypost/">
    <div class="read-more-class">View Full Post</div>
    <a class="more-link" href="http://www.mywebsite.zsz/mypost/"></a>

    As you can see there are two links to the post and a div inside the first one.

    What I want to do is put the post link inside the a href which will be inside the div so that the html will look like this..

    <div class="read-more-class"><a href="http://www.mywebsite.zsz/mypost/">View Full Post</a></div>

    Also, I have no idea where this more-class class is coming from and would, if possible, like to get rid of it.

    Here is what I did in functions.php to get the result I’m seeing now..

     * Returns a "Continue Reading" link for excerpts
     * @since Twenty Ten 1.0
     * @return string "Continue Reading" link
    function twentyten_continue_reading_link() {
    	return '<div class="read-more-class"><a href="'. get_permalink() . '">' . __( 'View Full Post', 'twentyten' ) . '</a></div>';

    It should be noted what I have now has worked for months, the browsers don’t mind it but I am unable to properly style the link colour and underline as it takes the css styling from elsewhere.

    Any advice is greatly appreciated 🙂

Viewing 1 replies (of 1 total)
  • I’m going to close this but leave some info on it before I do that.

    1. It was actually in the loop.php file that I needed to adjust things as the ‘continue reading’ options in functions.php affected only the excerpts and I was looking at my index page posts. (I have excerpts currently displaying the same as index page posts in search results and dont rely on excerpts anywhere else on the site)

    2. I couldn’t figure out how to get a div to appear before the a href so what I did instead was get rid of the read more link by leaving the text area blank so instead of ‘read more..’ or in my case ‘View Full Post’ I lef tit as ”

    3. Rather than use the read more option to link to the post and as I need a button I added into the other posts of loop.php a link to the post page. The following is the code I have now..

    <div class="entry-content">
                                <?php the_content(''); ?>
    <div class="read-more-class"><a href="<?php the_permalink(); ?>">View Full Post</a></div>
                            </div><!-- .entry-content -->

    This way I get to style it as a div and play with it however I like rather than basic span and a link styling.

    4. I thought maybe that leaving the read more.. text area blank would leave me an anchorless tag in the html but it appears that doing this eliminates the read more link from showing up in the html.

    Anyways, just thought I’d follow up on that a bit as this will one day become and old post and someone will find it on google and otherwise wish for more info, no matter how jumbled (I’m half asleep).

Viewing 1 replies (of 1 total)
  • The topic ‘Having Trouble With Customized Read More Link’ is closed to new replies.