• YoChen

    (@piedro)


    Hi!

    I understand that I can give any look or even a span class to the <read more …> in the “the_content()”.

    But I have five languages and I don’t know where to change the behaviour of the <more>-tag globally for all posts.

    I want to accomplish three things:
    1. I want to add “…” behind the shortened text (not a link!),
    then add an empty line of text beetween the text and the “MORE”-link
    2. I like to add a CSS-class called “more_tag” to the “MORE”-link, to style it within my style.css
    3. It should be still translateable when adding “MORE”-translations to the language files.

    I guess I have to add a filter to my functions,php for the template but I don’t know how to do it right. (By the way: WHere is the original “more”-funcion defined?)

    thx for any help,
    piedro

Viewing 8 replies - 1 through 8 (of 8 total)
  • Chinmoy

    (@chinmoy)

    Thread Starter YoChen

    (@piedro)

    Hello chinmoy!

    I know this article. It doesn’t help with my questions.
    I understand that I can change some of the <more>-appearnace issues with the “the_content” individually. But I don’t understand, as stated above, how to change the behaviour globally.

    Also the article has no solution to the problem of having a “…” that is not a link and having the link text “read more” in a translateable form.

    Any help?

    thx,
    piedro

    Chinmoy

    (@chinmoy)

    Write the following code in your functions.php file:

    <?php
    function pwd_entry_post($number) {
    	$content = get_the_content();
    	$content = apply_filters('the_content', $content);
    	$content = preg_replace('@<script[^>]*?>.*?</script>@si', '', $content);
    	$content = preg_replace('@<style[^>]*?>.*?</style>@si', '', $content);
    	$content = preg_replace('|<img.*?src=[\'"](.*?)[\'"].*?>|i', '', $content);
    	$content = strip_tags($content);
    	$content = substr($content, 0, strrpos(substr($content, 0, $number), ' '));
    	echo $content;
    	echo "...";
            echo "<a href='".the_permalink()."'">More</a>";
    }
    ?>

    And call the function “pwd_entry_post(1000)” form your template file(index.php).

    Hope you want this type of functionality.

    Thread Starter YoChen

    (@piedro)

    hello chinmoy!

    thx for your code!

    I’m not sure yet whether that’s it because I have to admit I don’t really understand it exactly.

    But I inserted your code in th functions.php.

    Now in the loop:
    below
    <?php the_content() ?>
    I place
    <?php pwd_entry_post($number) ?>

    But now I get:

    Here is the content of my article,
    goes further and further (more)

    http://www.mydomain.com/events/article-titel/More

    (herein the “More” here is a link to
    http://www.mydomain.com/events)

    I tried to establish a version like

    Here is the content of my article,
    goes further and further …

    More

    Thread Starter YoChen

    (@piedro)

    Oh forgot:

    I had to take out the fourth ” in this line

    echo "<a href='".the_permalink()."'">More</a>";
    chnage to
    echo "<a href='".the_permalink()."'>More</a>";

    Was this incorrect on my part?

    p.

    Thread Starter YoChen

    (@piedro)

    One more:

    Maybe it’s not important to replace the more within the content.
    I can replace “more” with “…” according to the article with the the_content('...')

    And then use your function to have a second, css-styled “More”-Button underneath!

    If you could just help me to use your pwd_entry_post($number)-function correctly … that would be very nice!

    thx anyway,
    piedro

    Thread Starter YoChen

    (@piedro)

    hello again!

    I still don’t get the use of the

    pwd_entry_post($number)
    -function correctly working.

    Obviously

    <?php pwd_entry_post($number) ?>

    doesn’t do the trick… plz help someone!

    thx, piedro

    <?php pwd_entry_post(400) ?>

    400 means how many character show in the post. You can change this number.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘customize <more> globally?’ is closed to new replies.