Viewing 8 replies - 1 through 8 (of 8 total)
  • Adrian Houle

    (@adrian-houle)

    You can do it with CSS using a child theme css file (the best way to do things anyways, otherwise whatever you change will just be overwritten on update.

    You can use the :after selector to add the content you want, set the content to a certain size using pixeles, and then shrink the link size down very small and make it transparent so that all you can see is the added content. The reson you set you new content to a certain size is so that it does not scale down with the link.

    Thread Starter goatsontheroad

    (@goatsontheroad)

    Thanks for your reply

    I tried that but i want it to be there for all of the “read more” tags that appear on the category page and any that come in the future. Is it possible to do it in functions.php?

    Adrian Houle

    (@adrian-houle)

    Yeah, if you scroll down a bit in the child theme instructions there is instructions on how to customize the load loop. https://codex.wordpress.org/Child_Themes

    But all of those buttons have a span class=”continue-reading” so ussing the selector:

    span.continue-reading {
    }

    should apply to all.

    Or using Jquery:

    $(document).ready(function() {
    $("span.continue-reading a").text("Watch The Video");
    )};

    When the document is finished loading (ready), the function will execute.
    The function selects the link, and replaces its text with your desired text.

    Michael

    (@alchymyth)

    I added the code to my functions.php file and got a fatal error.

    that code was meant to go into index.php or any of the archive template.

    when adding code into functions.php, always be aware when you need to add php tags or not.

    to use some code in functions.php, try working with the filter 'the_content_more_link'

    see http://justintadlock.com/archives/2009/07/01/how-to-filter-a-wordpress-themes-more-link-text

    you can make that conditional for the ‘video’ category (post category or category archive);
    example:

    function category_video_more_link( $more_link, $more_link_text ) {
    	if( in_category('video') || is_category('video') ) :
    	return str_replace( $more_link_text, 'Watch the Video', $more_link );
    	else :
    	return $more_link;
    	endif;
    }
    Thread Starter goatsontheroad

    (@goatsontheroad)

    Hey guys,

    Really thank-you so much for all of the help. I’m going to need it in a bit more dummied down sorry I don’t dig into the code often.

    Alchymyth, am I to post the code you pasted above into the functions.php or the category.php or the archive.php? Also, the name of the category is Goat Shows and its ID is 38. Should i write it like this:

    function category_goat_shows_more_link( $more_link, $more_link_text ) {
    	if( in_category('goat_shows') || is_category('goat_shows') ) :
    	return str_replace( $more_link_text, 'Watch the Video', $more_link );
    	else :
    	return $more_link;
    	endif;
    }

    I tried that in the functions.php and it didn’t work but i think you meant for it to be in another file.

    Again thanks for all of the help.

    Michael

    (@alchymyth)

    the code goes into functions.php; tested in a child theme of Twenty Fourteen.

    https://codex.wordpress.org/Function_Reference/is_category
    https://codex.wordpress.org/Function_Reference/in_category

    for your category ‘Goat Shows’ you could either use:
    is_category('Goat Shows')
    or
    is_category('goat-shows') (this should be the category slug)
    or
    is_category(38)

    what theme are you using?

    Thread Starter goatsontheroad

    (@goatsontheroad)

    Thanks again,

    The site was designed by someone else but i believe it uses Twenty Twelve as it’s structure.

    So the code would be pasted to the bottom of functions.php as follows:

    function category_goat shows_more_link( $more_link, $more_link_text ) {
    	if( in_category('goat shows') || is_category('goat shows') ) :
    	return str_replace( $more_link_text, 'Watch the Video', $more_link );
    	else :
    	return $more_link;
    	endif;
    }

    Note that i also changed the first line to: function category_goat shows_more_link

    Is that correct?

    Thread Starter goatsontheroad

    (@goatsontheroad)

    Hello again,

    Just wondering if anyone can help me overcome this issue. Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Custom Read More Text For Specific Category’ is closed to new replies.