Tagged: ,

Viewing 18 posts - 1 through 18 (of 18 total)
  • Author
    Posts
  • #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

    #312166

    Hey 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,
    Ismael

    #312565

    Perfect! Thank you.

    Is there a way to make this also work on the blog element? when viewing as “grid”?

    Thanks again.

    #312910

    Hey!

    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,
    Yigit

    #313162

    Thanks 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”

    #313276

    Hi!

    Can you post the link to your website please?

    Regards,
    Yigit

    #314233

    http://www.automatedtrans.com

    If 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…

    #314953

    Hey!

    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!
    Yigit

    #319533

    Thanks 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

    #319685

    Hey!

    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!
    Ismael

    #361757

    Ismael, 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
    #361950

    Hey!

    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,
    Ismael

    #362249
    This reply has been marked as private.
    #362256

    FYI – 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…

    #362680

    Hey!

    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!
    Ismael

    #363211

    OK; Thanks.

    M

    #363212

    OK; Thanks.
    Can I use another element to achieve what I need? Open posts of link type to the destination url?

    M

    #364000

    Hi!

    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

Viewing 18 posts - 1 through 18 (of 18 total)
  • You must be logged in to reply to this topic.