• Resolved walkera65

    (@walkera65)


    At the moment the read more text links to the post in the current tab. I need to either hide the read more text completely or have the link open in a new tab using “target=’_blank'”.

    I’ve tried leaving the read more text blank, but this results in the plugin inserting the post title as the read more text. Any help would be gratefully received.

    https://wordpress.org/plugins/send-images-rss/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Robin Cornett

    (@littlerchicken)

    Yes, as you’ve found, the plugin does not want you to omit the read more text entirely. You can accomplish either of the suggestions you want by using a filter–you’ll need to add some code to your site, either in the functions.php file or a functionality plugin, etc. (just make sure you have a backup first)

    Here’s an example filter and you can just comment out or remove the line you don’t want:

    add_filter( 'send_images_rss_excerpt_read_more', 'add_filter( 'send_images_rss_excerpt_read_more', 'prefix_change_read_more_link', 10, 4 );
    function prefix_change_read_more_link( $output, $read_more, $blog_name, $post_name ) {
    	// option 1: remove link completely
    	$output = '';
    	// option 2: revise the read more link to open in a new window/tab
    	$permalink = get_the_permalink();
    	$output = sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $permalink ), esc_html( $read_more ) );
    
    	return $output;
    }

    If you choose option 2, the text will still be whatever you’ve put in on the settings page, so you will still be able to change that.

    It may be worth setting the link target to be a new window/tab by default; I’ll look into it. HTH

    ETA: I made a mistake in the original function–what’s currently posted here is now correct.

    Thread Starter walkera65

    (@walkera65)

    Cheers Robin.

    Thread Starter walkera65

    (@walkera65)

    Got it working but had to alter the add_filter syntax slightly. I ended up with:

    add_filter( 'send_images_rss_excerpt_read_more', 'prefix_change_read_more_link', 10, 4 );
    function prefix_change_read_more_link( $output, $read_more, $blog_name, $post_name ) {
    	// option 1: remove link completely
    	   $output = '';
            // option 2: revise the read more link to open in a new window/tab
    	// $permalink = get_the_permalink();
    	// $output = sprintf( '<a href="%s">%s</a>', esc_url( $permalink ), esc_html( $read_more ) );
    	   return $output;
    }

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been damaged by the forum’s parser.]

    Tested both options and they work great. Thanks so much for the quick response.

    Plugin Author Robin Cornett

    (@littlerchicken)

    Ah, my apologies–my copy/paste powers failed me! Yes, what you posted is correct. The first line of my code above has add_filter duplicated in error and I can no longer edit that. Glad you got it sorted!

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

The topic ‘Hiding the Read More text’ is closed to new replies.