-
AuthorPosts
-
March 31, 2021 at 5:39 pm #1291604
Hi, i have a problem with that URL
When i use in the Blog the “link post type” which are external links, they should be straight opened in a new tab. So if you click on the title or read more button, the article should be opened and not the post itself. But only for post types “links”.
Can you help me?
I have this code here, but it’s only working for the grid layout and not for the one i use.
// OPEN BLOG POST TYPE “LINK” IN NEW TAB
add_action(‘wp_footer’, ‘ava_custom_script’);
function ava_custom_script(){
?>
<script type=”text/javascript”>
(function($) {
function a() {
$(‘.slide-entry-title a, .slide-image’).each( function() {
var site = document.location.host,
link = $(this).attr(‘href’);if(link.indexOf(site) !== -1) {
return;
} else {
$(this).attr(‘target’, ‘_blank’);
}
});
}a();
})(jQuery);
</script>
<?php
}April 3, 2021 at 9:32 am #1292070Hey ronaldalexander,
Please try this in your functions.php file:
function link_format_read_more_link_new_tab(){ ?> <script> jQuery(document).ready(function($) {; $('article.format-link .read-more-link a').attr('target', '_blank'); }); </script> <?php } add_action('wp_footer', 'link_format_read_more_link_new_tab');
Best regards,
RikardApril 5, 2021 at 12:08 am #1292382Hi,
thanks for the code. It works for the Read more link but not for the title. There is one problem, the subpage gets openen but not the final link. I dont want to open the article on the page, i want to open the final article / URL is put into the article.
Bests
- This reply was modified 3 years, 8 months ago by ronaldalexander.
April 5, 2021 at 6:27 am #1292422Hi ronaldalexander,
It won’t work because the permalinks point to a single post page and not to an external link.
You most likely will need a plugin for that, please try to check this article: https://firstsiteguide.com/link-posts-pages-external-url/
Hope it helps.Best regards,
Nikko -
AuthorPosts
- You must be logged in to reply to this topic.