Community Forums › Forums › Archived Forums › Design Tips and Tricks › Open Read More in a new tab News Pro Theme
- This topic has 28 replies, 2 voices, and was last updated 9 years, 4 months ago by Erik D. Slater.
-
AuthorPosts
-
June 11, 2015 at 8:26 pm #155923CDMMember
Hi.. does anyone know where to put the code and what the code looks like? I saw something about opening read more in a new Window but it was marked as "resolved" and the php file was not identified.
Thanks
http://hcvadvocate.org/wordpress/June 11, 2015 at 9:02 pm #155924Erik D. SlaterMemberThis works:
add_filter('the_content_more_link', 'eds_the_content_more_link', 10, 2); function eds_the_content_more_link($more_link, $more_link_text) { return str_replace('<a ', '<a target="_blank" ', $more_link); }
You can place it in your functions.php file (although really, it ought to go into a plugin for reuse whenever you switch themes).
Erik D. Slater: Digital Platform Consultant • LinkedInJune 11, 2015 at 9:28 pm #155926CDMMemberHi Erik.. should this be "read_more_link" since I'm using the expression "read more...."?
But I'll give it a go while I'm waiting to hear back from you
CD
June 11, 2015 at 9:43 pm #155929CDMMemberDefinitely does not work
CDM
June 11, 2015 at 9:48 pm #155930Erik D. SlaterMemberNope. Code doesn't work like that, I'm afraid 🙂
the_content_more_link is the name of the WordPress hook as defined within WordPress Core. The name itself acts as a reference that encapsulates certain functionality. We then use that reference for purposes such as ... well ... your situation here 🙂
eds_the_content_more_link references the code you need that will fulfill your request. I could have called it reading_more_is_groovy_man ... but I'm just not that silly 🙂
You can click here to "read more" (pun intended) about this particular topic 🙂
Erik D. Slater: Digital Platform Consultant • LinkedInJune 11, 2015 at 9:51 pm #155931Erik D. SlaterMemberDefinitely does not work
O ...K ... what isn't working? Assuming you pasted it in correctly, are you getting an error message? Did you clear down any caching? What did you do? And what is it doing?
Erik D. Slater: Digital Platform Consultant • LinkedInJune 11, 2015 at 9:54 pm #155932Erik D. SlaterMemberSORRY I gave you the wrong code. My bad. In fact ... wrong discussion entirely!!
Hang on a sec ...
Erik D. Slater: Digital Platform Consultant • LinkedInJune 11, 2015 at 9:58 pm #155933CDMMemberOkay.. I'm hanging. I put the code exactly as you sent it into the functions.php of my news pro theme.. I uploaded it and refreshed the text pages.. and NADA, ZILCH, BUBKAS!
CDM
June 11, 2015 at 9:59 pm #155934Erik D. SlaterMemberOK. I stand corrected. That is the correct code ... and I did paste into the right conversation 🙂
Sorry about that. I just happen to be talking to someone else on Skype about something similar ... and I thought I got my wires crossed there.
That code should definitely work. I actually tested it before I gave it to you ... honest I did 🙂
Erik D. Slater: Digital Platform Consultant • LinkedInJune 11, 2015 at 10:02 pm #155935CDMMemberHmm. well it doesn't.. I could try it again and clear my cache..again I'll let you know
CD
June 11, 2015 at 10:08 pm #155936CDMMemberJust cleared cache a few times in Chrome. Nope.. The Weekly Special Topic and the Showcase on the Home page still open on the same home page. I want them to open in a new tab
CD
June 11, 2015 at 10:09 pm #155937Erik D. SlaterMemberSomething puzzles me about your blog page.
Under Resources, you have this:
Hepatitis C Community and Events Attending support groups and events can help you and others live your life to the fullest. In this section, find … More...
while below that - under Treatment - you have this:
Welcome to the HCV Advocate's Hepatitis C Treatment Page. This page includes information about the current drugs to treat hepatitis C, … Read more...
In other words, you have two different ways to define your "read more" link. Are you adding these yourself?
Erik D. Slater: Digital Platform Consultant • LinkedInJune 11, 2015 at 10:13 pm #155938Erik D. SlaterMemberI see the problem now.
These are coming from the Genesis - Featured Posts widget ... and I have an extra bit if code for that.
Erik D. Slater: Digital Platform Consultant • LinkedInJune 11, 2015 at 10:17 pm #155941CDMMemberHi Erik.. Yes.. I am adding the "Read more..." or "More..." myself.. So, I shouldn't be doing this... Okay.. I don't mind sticking with one.. "Read more..." is the one I prefer.. Yes I'm doing this myself, and yes it is a Genesis Featured Posts widget.
CD
June 11, 2015 at 10:30 pm #155943Erik D. SlaterMemberYeah. I had adapted the code I currently use myself for the solution here. It will work for regular blog posts ... and is designed to work together with
<!--more-->
... which you would add inside your post at the appropriately-strategic position of your choosing.If you're adding the read more link by hand inside your posts, you would need to use the
target="_blank"
attribute inside your link, e.g.<a href="blah url" target="_blank">text</a>
.With the Genesis – Featured Posts widget, anything you enter into that More Text (if applicable): box usually takes priority.
I'm just testing something out with the widget and will get back to you post haste ...
Erik D. Slater: Digital Platform Consultant • LinkedInJune 11, 2015 at 11:08 pm #155944CDMMemberHi Erik.. Yes I know how to add the html code .....a href="blah url" target="_blank" text /a but there is no option here to do that. I use that code manually elsewhere tons..
Anyhoo: I'm exhausted and going to bed.
I hope you find a workaround...it would be great.
Thanks muchly
CD
June 12, 2015 at 1:19 am #155949Erik D. SlaterMemberThe solution I provided earlier depends on the use of the
<!--more-->
quicktag ... which works really well, but you probably don't want to trawl through all your posts to add it in.Since there is no reliable way to directly intercept the "read more" link from the Genesis - Featured Posts widget, the following code might be the best solution for you here:
add_filter('excerpt_more', 'eds_excerpt_more', 10, 1); function eds_excerpt_more($more) { return '<a class="more-link" href="'.get_permalink().'" target="_blank">ADD YOUR TEXT HERE</a>'; }
This replaces the default [...] thingy when displaying posts using the excerpt option. Now, "excerpt" in this case refers to the automatic 55-word excerpt generated by WordPress ... not the manual excerpt feature available to you in your edit post page ... which doesn't add a "read more" link by default.
Erik D. Slater: Digital Platform Consultant • LinkedInJune 12, 2015 at 11:04 am #155989CDMMemberGood morining Erik!
I pasted the code into my functions.php and my Dreamweaver protested and said there were 2 syntax errors.
CD
June 12, 2015 at 11:17 am #155990Erik D. SlaterMemberI just copied and pasted the code from this thread (just to make sure I didn't paste something erroneous) ... switched the Content Archives setting in Genesis -> Theme Settings to Display post excerpts ... and all appears to be working.
Since I can't see your screen, can you shed some light on the Dreamweaver protests?
Erik D. Slater: Digital Platform Consultant • LinkedInJune 12, 2015 at 11:49 am #155991CDMMemberHi Erik.... Can you post me where I can send you the file?
I don't know how to send you the code with the wrong colors and the dreamweaver comments.. Just that they are the wrong colour and I get a syntax error for this line
function eds_excerpt_more($more) {
For the next line I get "Dynamically related files cannot be discovered because there is no site definition" but this is just a warning
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.