Post Full-Text/Summary Question
-
I am running a child theme in WordPress 4.5.4 and have my Setting>Reading set to Summary (excepts) for my front page posts.
I would like to have selected posts full-text and was wondering if there was a way to add a script to each post that would make it full-text? Note:There is a Script section in the Post editor that says “Page Specific Scripts”
I searched for this in the forum but could not find a solution – seems like it would be a common question.
Appreciate the help,
Jim
-
That script section is not part of the default WP edit screen, it’s from either your theme or a plugin. You’d likely need to get an answer from the author of whatever entity is responsible for putting it there.
What you want can be achieved with default WP with a bit of extra code on the template page responsible for the output. To find it, start with the parent theme’s index.php, which more than likely loads a template part. Whatever template part is loaded may have the code you need, or there could be even another template part loaded.
You need to create some way to distinguish full text posts from the others. A custom field, tag, category, etc. The added code would check for this property and if it exists, the full text is output, otherwise output the excerpt.
If you need more specifics, we’d need to know your theme, the type of excerpt you’re using (separate field, more tag, or auto-generated) and how you would distinguish full text posts from others.
Hi bcworks,
Yeah – unfortunately the developer of the theme I am using is not interested in helping so I am on my on here.
Would appreciate the help.
I will be glad to give you login info on my WP site so you can take a look. I have a Welcome post at the top that I would like to go full-text so the video shows up.
Give me your email address and I will send you the login information.
Thnx for your help,
Jim
I’m sorry, these forums are not for that level of support. Everything is done right here in public and you shouldn’t give anyone here privileged access to your site. If you are uncomfortable with those terms, consider hiring help from somewhere like jobs.wordpress.net
bcworkz,
ok – let’s do it in public – do you have a suggestion to a solution or the next step?
Jim
All righty then 🙂
It’s too bad about the script box, there’s possibly potential there, but knowing nothing about it means we need to do it with only core techniques. Maybe it’s just as well because this could then be used in any WP installation.
Like I said initially:
If you need more specifics, we’d need to know your theme, the type of excerpt you’re using (separate field, more tag, or auto-generated) and how you would distinguish full text posts from others.
By theme, I mean your parent theme, unless you already know exactly where to put the if ( condition ) echo excerpt else echo full-text logic.
When you say front page, is this the post index front page or a “static” front page?
-
This reply was modified 9 years, 5 months ago by
bcworkz. Reason: one last question
Hi bcworkz,
ok – will do my best to answer your questions. It is a Genesis theme with a MemberSonic child theme and all I did was set my Settings>Reading settings as follows
Front page displays Your Latest Posts
For each article in feed, show Summary
See site at http://theimlifestyle.com
Hope this helps,
Jim
Thanks for the extra information. That was helpful, but not in the way I was hoping. We’re unable to help people who use commercial themes because we do not have access to the source code. I was hoping to be able to tell you where to place the code, but that’s just not possible. All I can tell you is it goes inside the Loop where each post’s content is output. You’re on your own for finding the right template and location.
I’ll assume you will designate full text posts by adding a custom field named “full_text” with a value of “yes”. Any post without that field or with a value other than “yes” will only have it’s excerpt output.
This code that you add will be lost anytime the theme is updated, so keep a backup copy somewhere safe for reference in editing the newly revised theme template. It’d be better to do a template swap from within a plugin, but I couldn’t explain how to accomplish that with a Genesis based theme.
if ( 'yes' == get_post_meta( get_the_ID(), 'full_text', true )) { $post = get_post(); if ( post_password_required( $post ) ) echo get_the_password_form( $post ); else echo $post->post_content; } else { // theme's original excerpt output goes here }bcworkz,
ok – is there something else I can provide that would give the information you need to tell me where the right template and location is? ie template names of the child theme?
otherwise – thank you for your help.
Jim
I’m afraid not, sorry. The best I can offer is some hints on how to find the right place. You need to be able to recognize The Loop on templates. Recognize when you need to use <?php ?> tags when inserting code (when surrounding content is plain HTML) and when not to, because nesting blocks of PHP code like we do with HTML is not permitted. Know that content is usually output with the_content() or the_excerpt(), but themes could have their own method.
You can verify you’re in the right place by placing temporary, arbitrary output and see where it appears, or if it appears. Something like
echo '***** TEST OUTPUT *****';If “echo” appears in the output, you should have enclosed the line in <?php ?> tags. You can verify functions do what you think they do by temporarily making them into a comment with/* */syntax. If doing so makes just the excerpt disappear, you’ve found the right function.Do not use the built in theme editor to do this. A simple innocent syntax error could crash the site, preventing access to the editor to fix it. You need to do this through FTP or your hosting account’s file manager. Always have a clean, unaltered version of any file you alter ready to upload in case your edits result in a crash.
With that knowledge, you can start searching for the right spot. Start with the parent theme’s index.php, which more than likely loads a template part. Whatever template part is loaded may have the code you need, or there could be even another template part loaded. If the child theme has a template of the same name, use the child version instead of the parent’s.
Initially, you are looking for The Loop. Verify you’re on the right template by adding arbitrary output inside the loop. If your output appears with every post, you’re on the right track. If not, try another promising template or loop. Once you’ve found the right loop and template, identify the function that outputs the excerpt. Once you find that, add my code just above it and move the excerpt function to its position within my code.
Unless you’ve already added the custom field, you should not notice any difference in the output. Once the custom field is added to selected posts, they will be displayed with full text.
Good luck!
-
This reply was modified 9 years, 5 months ago by
The topic ‘Post Full-Text/Summary Question’ is closed to new replies.