• Hi, I don’t know why it is not working. I have function where I change class according to category. And this function I need insert into more link of post in category. But class in link isn’t display. There is code:

    function custom_color(){
    	if (in_category('exterier'))
    		{echo 'green';}
    	elseif (in_category('interier'))
    		{ echo 'cyan';}
    	else echo 'default';
    
    }
    
    function modify_read_more_link() {
        return '<a class="more-link' . custom_color() . '" href="' . get_permalink() . '">?íta? viac</a>';
    }
    add_filter( 'the_content_more_link', 'modify_read_more_link' );

    Thanks for help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi, @17mark. Change each echo in your custom_color function to return instead.

    Also, you’re probably going to want to add a space just after more-link in the modify_read_more_link function, like so:

    '<a class="more-link '

    (unless you actually want to end up with single class names like more-linkgreen instead of two separate class names like more-link green)

    Thread Starter 17Mark

    (@17mark)

    Thanks it is working but I have little problem. `function modify_read_more_link() {
    return ‘<a href=”‘ . get_permalink() . ‘”><div class=”more-link ‘ . custom_color() . ‘”>?íta? viac</div></a>’;
    }
    add_filter( ‘the_content_more_link’, ‘modify_read_more_link’ );`
    When I have this code, link is duplicated. There is picture

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem with more link’ is closed to new replies.