[resolved] Quick Page/Post Redirect Plugin - read more tag doesnt open in new window (5 posts)

  1. stemie
    Posted 4 years ago #

    When I set this plugin to open in a new window, The read more tag at the end of the excerpt does not open in a new window. If I click the post title it does.

    So in short the open in new window option is not working for all permalinks for a redirected post, in particular the read more link. Any ideas how I can over come this?

  2. Don Fischer
    Posted 3 years ago #

    Are you still having this issue?
    Let me know if you are - I can give you a few suggestions.

    Warm regards,
    Don Fischer

  3. stemie
    Posted 3 years ago #

    Yes it is still and issue for me.
    Its just the read more tags that wont open in a new window. The other links work.

    Thanks Don

  4. Don Fischer
    Posted 3 years ago #

    You can try filtering the read more link by adding the following to your functions.php file: [ edited code - was incorrect (Don) ]

    //make more link open in new window
    function add_blank_to_link($link) {
    	$pos = strpos($link, 'a href');
    	if ($pos) {
    		global $post;
    		global $redirect_plugin;
    		$global_new_window_setting = $redirect_plugin->get_value('ppr_newindow'); //check the individual item to see if there is a new win setting.
    		$qpprp_newwin = get_post_meta($post->ID,'_pprredirect_newwindow',true); //get global override of new win setting if there is one.
    		$hastarget = strpos($link,'target='); //check to see if it already has a target.
    		if(($qpprp_newwin == 1 || $global_new_window_setting == 1) && $hastarget === false){
    			//if individual setting says yes, or global setting says yes, AND it does not already have a traget, add one.
    			$link = substr_replace($link, 'a target="_blank" href', $pos, 6);
    	return $link;
    add_filter('the_content_more_link', 'add_blank_to_link');

    This will filter the link and add the new window target attribute if either the individual page/post new window box is checked or the global new window box is set AND it does not already have a target set up.

    I have not tested this - but it should work fine. If you have a problem, please let me know.

    Warm regards,

  5. stemie
    Posted 3 years ago #

    Thanks Don that seems to have done the trick :)

Topic Closed

This topic has been closed to new replies.

About this Topic