0

I have an HTML template which I convert to a Wordpress theme, but i can't add a "Read more" button to the home page.

I use the following code in functions.php:

function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
    $content = get_the_content($more_link_text, $stripteaser, $more_file);
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    $content = strip_tags($content);

    if (strlen($_GET['p']) > 0) {
        echo "<p>";
        echo $content;
        echo "</p>";
    }
    else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) {
        $content = substr($content, 0, $espacio);
        $content = $content;
        echo "<p>";
        echo $content;
        echo "...";
        echo "</p>";
    }
    else {
        echo "<p>";
        echo $content;
        echo "</p>";
    }
}

I also use the following code in index.php:

<div class="text_home"><?php the_content_limit(300); ?></div>

What can I do to solve my problem?

4
  • In what way can't you add a Read More button? Jul 23, 2016 at 19:52
  • Read More button is not appear in home page, i want add "read more" or "more .." to my posts in home page
    – Hazem
    Jul 23, 2016 at 19:55
  • What research have you done so far? What have you tried? Jul 23, 2016 at 20:00
  • i don't research except this cods (in my post)
    – Hazem
    Jul 23, 2016 at 20:05

1 Answer 1

0

You can make a basic link to the current post within the loop with

<a href="<?php the_permalink(); ?>">Read More</a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.