Quantcast
Channel: Topic Tag: plugin | WordPress.org
Viewing all articles
Browse latest Browse all 26892

deborah64554 on "[Plugin: Page Links To] Link STILL doesn't open in new window"

$
0
0

Ok, for users who also have list-category-posts plugin and are seeing page-links-to opening in the same window, here's a brief summary of the cause and specific details on how to get things working so that the new window opens.

Cause: Page-Links-To sets the post url in the database, but uses a script to re-write the link tag if the "open in a new window" feature is checked for the post. List-Category-Posts gets the url from the database, but uses its OWN script to write the link tag - it never sees and can not implement the Page-Links-To script, which contains the "new window if box is checked" logic.

This means that in order to get List-Category-Posts to open posts in a new window, you have to create new functions that write the link tag with "target='_blank'" in it, create a List-Category-Posts template for it that calls those functions, and use that template when you want a new window. This method will work for a list of links that must open in a new window and for a list that does not, but you will not be able to have a mixed list (unless, that is, you create a brilliant solution on your own). I hope also that experienced php coders will forgive anything I am recommending here that may be redundant.

To get List-Category-Posts to make a list of links that open in a new window:

In CatList.php:

  • Find the function "get_category_link"
  • Copy and paste this function below the original
  • Re-name it to "get_category_link_new_win"
  • Change the line return '<a href="' . $cat_link . '" title="' . $cat_title . '">' . to return '<a href="' . $cat_link . '" title="' . $cat_title . '" target="_blank">' .
  • Find the function "get_the_post_thumbnail"
  • Copy and paste this function below the original
  • Re-name it to "get_the_post_thumbnail_new_win"
  • Change the line $lcp_thumbnail = '<a href="' . get_permalink($single->ID).'">'; to $lcp_thumbnail = '<a href="' . get_permalink($single->ID).'" target="_blank">';

In CatListDisplayer.php:

  • find the function "get_thumbnail"
  • Copy and paste it below itself
  • Re-name it to "get_thumbnail_new_win"
  • Change the line $info = $this->catlist->get_thumbnail($single, $lcp_thumb_class); to $info = $this->catlist->get_thumbnail_new_win($single, $lcp_thumb_class);
  • find the function "get_post_title"
  • Copy and paste it below itself
  • Change the line $info = '<a href="' . get_permalink($single->ID) . '">' . to $info = '<a href="' . get_permalink($single->ID) . '" target="_blank">' .

Open list-category-posts/templates/default.php and save it to (your template folder)/list-category-posts/new-window.php

  • Please note the new file must be in a NEW list-category-posts folder in YOUR template folder, not the plugin folder!
  • Change $lcp_display_output .= $this->get_thumbnail_mm($single); to $lcp_display_output .= $this->get_thumbnail_new_win($single);
  • Change $lcp_display_output .= $this->get_post_title_mm($single); to $lcp_display_output .= $this->get_post_title_mm($single);
  • Save that sucker.

Now in WordPress, in your shortcode to create a list that uses the new-window template, put template=new-window before the ending bracket.

Behold! If I have made no critical typos and you have copied and pasted with diligent accuracy, you should now have a list of posts that open in a new window.

Good luck! :)


Viewing all articles
Browse latest Browse all 26892

Trending Articles