Opened 20 years ago
Closed 19 years ago
#1656 closed defect (bug) (wontfix)
Need more customization of more-link markup
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 1.5.2 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description ¶
Hi,
My issue is sort of similar to the problem described in #178 in that I'm concerned with validating markup, but my situation is slightly different. I'm not interested in breaking a post in the middle of a block or list and having WordPress figure out how to fix my markup. On the contrary, I want complete control over my markup (for example, I have disabled the auto-paragraphing filter). I always insert the <!--more--> token between blocks so that the post will break cleanly.
At first I set up my the_content tag like this:
the_content('<div class="morelink"><p>Continue reading <q>' . the_title('', '', FALSE) . '</q></p></div>');
Then I realized that this left me with anchor tags outside the div and p tags, which is absolutely not valid code. I fiddled around with different permutations in templates and entry text but couldn't figure out anything that would get me the markup I wanted, since a) the "more" options are folded into the_content and b) any tags I opened before the <!--more--> token would not be closed.
Eventually I solved my problem by hacking template-functions-post.php and tacking two parameters onto the_content and get_the_content: more_link_before and more_link_after. I am happy with this solution for myself, but I wanted to raise this issue for wider consideration.
The patch I created is here if you care to look at it. It works for me, but the problem could probably be solved more elegantly.
Thanks,
Laura
Pull Requests
- Loading…
Change History (3)
#2
@
20 years ago
Mark,
Neat solution. I like it. Yours is certainly more easily turned into a plugin than mine, which requires direct code editing.
The weakness I see is that it searches for a string that could appear in the text of an entry and (given Murphy's law) will appear at least once. By that time I will, of course, have forgotten all about this code and have no clue what went wrong. Great fun! The problem is easily solvable, but only at the expense of a little elegance. Oh well.
Laura,
This is an issue I've also grappled with. I eventually settled upon a regex filter to look for the "read more" link and then reformat it. Here is my code:
Note that it looks for (more...), which is the default text for the_content()... so you have to make sure your template doesn't pass a parameter to the_content(), or it won't work. Other than that, just change the $replacement string, using %linkstart% to designate where <a href="[your permalink]"> goes.
Hope this helps.