Return to Support

More Tag

Home Forums Graphene WordPress theme Support More Tag

Viewing 15 posts - 1 through 15 (of 26 total)
  • Author
    Posts
  • #1236
    sylvia
    Member

    When I use the <!–more–> tag in a post, it creates a button that says something like “Continue reading this entry>>”. How can I modify what it says inside that button as I would like it to say something else?

    Thanks

    #19593
    Luko
    Member
    #19594
    soapy
    Member

    Luko,

    I see you tried to reply….unfortunately your post isn’t showing anything…

    #19595
    Luko
    Member

    Sorry for empty post, I lost Internet access.

    You can change the text by editing themes loop.php, but all will be lost when you update the theme.

    I’m using codestyling localization so I simpy translated this in Croatian language, but if you want to change it without messing the theme files you have to add function in your child theme functions.php

    I’m PHP numb, so… try reading some of this articles:

    http://codex.wordpress.org/Customizing_the_Read_More#Designing_the_More_Tag

    #19596
    Josh
    Member

    You can add this to your child theme functions.php file:

    // Change "Read the rest of this entry" link Button
    function graphene_filter_readmore( $translated, $original, $domain ) {
    $strings = array(
    'Continue reading »' => 'My New Text »',
    );
    if ( ! empty( $strings[$original] ) ) {
    $translations = &get_translations_for_domain( $domain );
    $translated = $translations->translate( $strings[$original] );
    }
    return $translated;
    }
    add_filter( 'gettext', 'graphene_filter_readmore', 10, 3 );

    You can, of course, change “My New Text” to whatever you like.

    #19597
    soapy
    Member

    Thanks, I will try this when I get home.

    One other question Josh, I’m pretty good with HTML and CSS….and I use firebug to troubleshoot when I need to find the name of a CSS element to modify it.

    I don’t have much experience with PHP. My quesiton is….is there a way to determine the php code you need to modify when looking at something specific…just like there is with CSS and firebug??

    Thanks Josh

    #19598
    soapy
    Member

    Hey Josh,

    I added the code to my child functions.php file….but it didn’t change anything. Any ideas why?

    Here is my functions.php file:

    <?php
    function searchfilter($query) {

    if ($query->is_search) {
    $query->set('post_type',array('post'));
    }

    return $query;
    }
    add_filter('pre_get_posts','searchfilter');

    // Change "Read the rest of this entry" link Button
    function graphene_filter_readmore( $translated, $original, $domain ) {
    $strings = array(
    'Continue reading »' => 'My New Text »',
    );
    if ( ! empty( $strings[$original] ) ) {
    $translations = &get_translations_for_domain( $domain );
    $translated = $translations->translate( $strings[$original] );
    }
    return $translated;
    }
    add_filter( 'gettext', 'graphene_filter_readmore', 10, 3 );

    ?>

    #19599

    is there a way to determine the php code you need to modify when looking at something specific…just like there is with CSS and firebug??

    Interesting question. Since PHP generates HTML, you can’t really use Firebug or your browser’s “view source” function.

    What I do is to keep a copy of both Graphene and WordPress on my desktop, so I can search through those files whenever I like with a text editor I’m familiar with (I like notepad++ for windoze and macpad for mac).

    #19600
    soapy
    Member

    Thanks for you answer Ken. I need to start reading up on PHP to get familiar with it….then I’m sure it will all make sense.

    Do you know why the code Josh provided me won’t work? I wouldn’t even know where to start with PHP! lol

    #19601

    Have you tried changing this line

    'Continue reading »' => 'My New Text »',

    to something like

    'Continue reading »' => 'If you don't read this post a fairy will drop down dead »',

    or whatever you would like it to say.

    The reference is from Peter Pan; you’re dealing with a literature teacher here — 🙂

    #19602
    soapy
    Member

    LOL! I will try now….i just figured that with his code the words “My new text” would appear…but i’ll try now!

    #19603

    I wouldn’t even know where to start with PHP! lol

    The official PHP site is here: http://php.net/

    and the official PHP manual is here: http://php.net/manual/en/index.php

    But I like the w3schools php pages better: http://www.w3schools.com/php/default.asp

    But php.net has a very good (and very simple) tutorial here: http://php.net/manual/en/tutorial.php

    Cheers!

    #19604
    soapy
    Member

    Nope….it doesn’t change anything unfortunately…..

    #19605

    Nope….it doesn’t change anything unfortunately…..

    Just spent several minutes trying this out on my blog and it doesn’t work for me either. I have no ideas at the moment. Sorry.

    #19606
    Syahir Hakim
    Keymaster

    When using the function that Josh posted above, you need to write the string exactly as it appears in the original theme’s files.

    In case of this string:

    Continue reading »

    Its exact form in the theme’s file is this:

    Continue reading &raquo;

    So to reflect this in the function that Josh posted, it should be:

    // Change "Read the rest of this entry" link Button
    function graphene_filter_readmore( $translated, $original, $domain ) {
    $strings = array(
    'Continue reading &raquo;' => 'My New Text &raquo;',
    );
    if ( ! empty( $strings[$original] ) ) {
    $translations = &get_translations_for_domain( $domain );
    $translated = $translations->translate( $strings[$original] );
    }
    return $translated;
    }
    add_filter( 'gettext', 'graphene_filter_readmore', 10, 3 );

    FYI, &raquo; is the HTML entity for ». It ensures that the character can be read by all devices and not appear as the diamond character.

Viewing 15 posts - 1 through 15 (of 26 total)

You must be logged in to reply to this topic.