- This topic has 13 replies, 2 voices, and was last updated 3 years, 9 months ago by David.
-
AuthorPosts
-
May 14, 2020 at 6:13 pm #1284989Janani
Hi
In my archive page, how do I make the link to the post open in a new page?
Warm regards,
May 14, 2020 at 6:59 pm #1285012LeoStaffCustomer SupportHi there,
Try this solution:
https://generatepress.com/forums/topic/force-open-all-wordpress-blog-posts-in-new-tab-target_blank/#post-612849May 15, 2020 at 6:33 pm #1286596JananiDear Leo
Thanks. Apologies, but I am a beginner, so wanted to check with you where I would add this code. This does not seem to be a normal CSS code.
May 16, 2020 at 7:27 am #1287181DavidStaffCustomer SupportHi there,
that code is Javascript.
To add that to your site you would:1. Create a new hook element.
https://docs.generatepress.com/article/hooks-element-overview/
2. Add the code to the hook content.
3. Select theWP_Footer
hook
4. Set the Display Rules for the pages where you need this could to be fired.May 23, 2020 at 3:42 am #1297817JananiDear David
Thanks I tried it but it did not work. Pls let me know what I did wrong.
I chose wp_footer, ticked on execute shortcodes, execute PHP, priority 10.
Below is this is the script I used:
<script type=”text/javascript”>
//<![CDATA[
jQuery(document).ready(function($) {
$(‘h2.entry-title a’).each(function() {
var a = new RegExp(‘/’ + window.location.host + ‘/’);
if(!a.test(this.href)) {
$(this).click(function(event) {
event.preventDefault();
event.stopPropagation();
window.open(this.href, ‘_blank’);
});
}
});
});
//]]>
</script>May 23, 2020 at 9:47 am #1298274LeoStaffCustomer SupportYou don’t need to check to execute shortcodes and execute PHP but I do think you need to load jQuery like this:
https://generatepress.com/forums/topic/shortcode-does-not-show-in-front-end/#post-475755Adding PHP: https://docs.generatepress.com/article/adding-php/
May 25, 2020 at 7:20 pm #1301364JananiDear Leo
Do you suggest I install a plugin for this purpose? Is there no way I can do this without a plugin?
Warm regards,
May 26, 2020 at 6:21 am #1301907DavidStaffCustomer SupportHi there,
try this Javascript instead:
<script> jQuery(document).ready(function($){ $('.entry-title a').attr('target', '_blank'); }); </script>
May 26, 2020 at 7:23 pm #1302868JananiDear David
This is perfect. It worked! Thank you very much.
May 27, 2020 at 1:27 am #1303113DavidStaffCustomer SupportYou’re welcome
July 3, 2020 at 7:23 pm #1351184JananiHi David,
This issue was resolved, but recently I noticed that the post does not open on a new page. Could there be any reason for this?
Warm regards,
July 4, 2020 at 1:42 am #1351371DavidStaffCustomer SupportI cannot see the code added to your site.
Where did you add it? If it is using a Hook – make sure it is still published and the display rules are correctJuly 4, 2020 at 3:13 am #1351431JananiThanks David. I guess the hook got modified accidentally. This issue is resolved.
July 4, 2020 at 8:26 am #1351774DavidStaffCustomer SupportGlad to hear that
-
AuthorPosts
- You must be logged in to reply to this topic.