Tagged: link, Post Format
-
AuthorPosts
-
September 1, 2014 at 11:17 pm #312008
I created a child theme so that any customizations I make don’t affect my core theme files.
One of the things I want is for the links of posts with post “format = link” to open in a new window.I followed the instructions here: https://kriesi.at/support/topic/link-post-format/ and made the changes on the corresponding theme files in my child theme directory. Everything still opens up in the same window; SHould I be editing the “actual” theme files for this? Or should my child theme take over?
Thanks in advance
September 2, 2014 at 10:16 am #312166Hey frescova!
Thank you for using Enfold.
You can copy the whole post type link function on the child theme’s functions.php. Copy this one: http://pastebin.com/aRZjTdYT
Best regards,
IsmaelSeptember 3, 2014 at 12:33 am #312565Perfect! Thank you.
Is there a way to make this also work on the blog element? when viewing as “grid”?
Thanks again.
September 3, 2014 at 3:14 pm #312910Hey!
Please add following code to Functions.php file in Appearance > Editor
function add_custom_target(){ ?> <script> jQuery(window).load(function(){ jQuery('header.entry-content-header a').attr('target','_blank'); }); </script> <?php } add_action('wp_footer', 'add_custom_target');
Best regards,
YigitSeptember 4, 2014 at 2:29 am #313162Thanks Yigit;
After I add the code do I need to do anything else? Links are still opening in the same window…
Just to reiterate; I have a page where I added the “Blog Posts” element and have them showing in grid layout “Title Only”. All of the posts in this element are of post format “link”
September 4, 2014 at 11:29 am #313276September 6, 2014 at 1:37 am #314233If you look at the page there are two “magazine” elements on it. THe one on the left is labeled “newsletters” and the one on the right is labeled “Latest News” Items in the one on the right are of post format “link” those should actualy point to the actual “link” defined in the first line of the post, nt the actual “post.” And, I’d like them to open in a separate window.
Basically anything on this page with a format = “link” should open in a new window…
Everything else in the same window. The code you gave me:
function add_custom_target(){ ?> <script> jQuery(window).load(function(){ jQuery('header.entry-content-header a').attr('target','_blank'); }); </script> <?php } add_action('wp_footer', 'add_custom_target');
makes every link on the page open up in a new window…
Thanks in avance…
September 8, 2014 at 11:21 am #314953Hey!
Please change the code i gave you previously to following one
function add_custom_target(){ ?> <script> jQuery(window).load(function(){ jQuery('.av-magazine-format-link a').attr('target','_blank'); }); </script> <?php } add_action('wp_footer', 'add_custom_target');
Cheers!
YigitSeptember 16, 2014 at 2:51 am #319533Thanks Yigit, but It’s still not doing what I need…
It works perfect here:
https://www.driverlesstransportation.com/news
I want it to do the same exact thing for the posts of type link on my home page.
Thanks again for all the effort and support, very much appreciated.
M
September 16, 2014 at 9:26 am #319685Hey!
Which posts are you referring to? Please post a screenshot. Please try this:
add_filter('wp_footer', 'avf_add_target_blank', 10); function avf_add_target_blank() { ?> <script> (function($){ $(window).load(function() { $( "h3.av-magazine-title.entry-title a" ).each(function() { $(this).attr('target','_blank'); }); }); })(jQuery); </script> <?php }
Cheers!
IsmaelDecember 2, 2014 at 8:52 pm #361757Ismael, My apologies for taking so long to respond; I’ve been swamped with a couple of other projects.
I just tried the code above with no results…
if you go to this page: http://www.driverlesstransportation.com on the right column is a “magazine” widget under Latest news. That block is set up to display posts from the category “news.” pretty much 100% of the posts in that category are of “Link” type to an external URL. We want it set up so that when a user clicks the link it just sends them to the “external” url, NOT the wordpress post page.
Actually – no matter where a post of “link” type appears we want to send users to the designate link. never to the wordpress post. right now it takes our users two clicks to visit the designated url.
Does it make sense?
- This reply was modified 10 years ago by frescova. Reason: fixed typo
December 3, 2014 at 5:20 am #361950Hey!
I’m sorry, I made a mistake on the code, it has the wrong selector. I edited the code above. Please use it instead. Remove browser cache then reload the page.
Regards,
IsmaelDecember 3, 2014 at 5:04 pm #362249This reply has been marked as private.December 3, 2014 at 5:07 pm #362256FYI – i did get the site to come back with your code in it, but the only thing that was different was that the links now open up in a new tab. They still go to the post, and not the “external” url…
December 4, 2014 at 4:11 am #362680Hey!
I thought you only want to add a target attribute on the magazine title. I’m sorry but the magazine element does not support link post format at the moment. You might need to hire a freelance developer to configure the magazine element. For further modifications, please visit Envato Studio or Werkpress. You can also vote or request for the featured on our Feature Requests page.
If you have any further questions about the theme, we are more than happy to provide you with assistance on these inquiries. Thank you for your understanding.
Cheers!
IsmaelDecember 4, 2014 at 8:43 pm #363211OK; Thanks.
M
December 4, 2014 at 8:44 pm #363212OK; Thanks.
Can I use another element to achieve what I need? Open posts of link type to the destination url?M
December 6, 2014 at 2:53 am #364000Hi!
You can use the Blog Posts element. Set the blog style to Grid Layout. Replace the code with this in order to open the link on another tab:
add_filter('wp_footer', 'avf_add_target_blank', 10); function avf_add_target_blank() { ?> <script> (function($){ $(window).load(function() { $( ".avia-content-slider .slide-entry-title a" ).each(function() { $(this).attr('target','_blank'); }); }); })(jQuery); </script> <?php }
Cheers!
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.