Skip Navigation

[Resolved] Opening post excerpt link in a separate tab

This support ticket is created 4 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 11 replies, has 2 voices.

Last updated by deepS 4 years, 6 months ago.

Assisted by: Nigel.

Author
Posts
#1355627

Hi, though this is a very basic level question to open a link in a new tab (I know about target="_blank" protocols), I couldn't do it with Post excerpt link as the mentioned protocols cannot be added. Now let me know how to do this in the following code.

[wpv-post-excerpt length="50" count="word" more="...<a href='[wpv-post-url item='@company-job.parent']'> read more</a>" item="@company-job.parent"]
#1355681

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

I would add the link manually immediately after the post excerpt, adding the attribute format="noautop" to the wpv-post-excerpt shortcode so that it is not wrapped in p tags so that the link you create appears on the same line, e.g.

[wpv-post-excerpt item="@company-job.parent" format="noautop"]<a href="[wpv-post-url item='@company-job.parent']">Read more</a>
#1355691

But this is not opening the link in a new tab. At the same, I haven't found any utility of format="noautop" in this case.

#1355697

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Then you can just add the target="_blank" to the link tag you are creating yourself, e.g.

[wpv-post-excerpt item="@company-job.parent" format="noautop"]<a href="[wpv-post-url item='@company-job.parent']" target="_blank">Read more</a>

The format="noautop" simply stops the excerpt being output within p tags, so that the link you add immediately after the excerpt isn't forced onto the next line.

I tested the above on my own site and it does exactly what's expected.

It displays an excerpt from the parent post, a "read more" link, which opens the parent post in a new tab.

That's what you were aiming to do?

#1355729
Screenshot_3.jpg

See I used this code

<h2>About [wpv-post-title item="@company-job.parent"]</h2>
<div id="co-excerpt">[wpv-post-excerpt length="50" count="word" more="...<a href='[wpv-post-url item='@company-job.parent']'> read more</a>" item="@company-job.parent"]</div>

to produce this excerpt from related post (see the creenshot).

You can see it in this url: hidden link

As soon as I put your code, it breaks the entire thing. Please have a look.

#1355767

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

That's the markup that you currently have, which generates what's in the screenshot, is that right?

Can you show me what you replaced it with, that doesn't work?

#1355777

I put your code below the existing one

[wpv-post-excerpt item="@company-job.parent" format="noautop" length="50" count="word"]<a href="[wpv-post-url item='@company-job.parent']" target="_blank">Read more</a>

And looks like this (url: hidden link)

#1355781

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

That hasn't added anything to the page, can I take a look at your site to see why?

Let me mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site.

#1356685

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

I'm not sure what you had done previously.

All I did was edit your template, comment out your existing section where you inserted the post excerpt and added what I had suggested above, and it works as expected, the read more link opens in a new tab.

#1358553
Screenshot_4.jpg

Hi Nigel,
Thanks for your support. You have almost met my requirements except the line break. The button is appearing below the line. I want the button on the same line as it was earlier (I have marked with an arrow). Hope you understood my point. Thanks

#1358621

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

The problem is that you have another plugin automatically inserting content at the end of the excerpt which forces a new line (see the screenshot, the div added by the AddThis plugin).

Is it possible to change the AddThis settings so that it doesn't add anything to the excerpts on these pages?

Otherwise you would need to add some CSS that changes the display property of that empty div to inline so that it doesn't break the flow.

#1358799

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.