Hi everyone,
I have a question about putting the first paragraph in a blogpost above the featured image. Is this possible to achieve without using plugins, and just make modification to functions.php or similar?
Unfortunately my programmingskills are limited so I hope someone her got the php-kungfu needed to help me.
Best Regards
Daniel
You can manually set the first paragraph at the top of any image by using for example Post template Style 5:
Thank you for the answer. But I have more than 2 000 articles and I can’t add the paragraph manually on each one.
Is there no other way to handle such issue?
Hi,
You could try something like this, try this function and see if it works properly
– https://napitwptech.com/tutorial/wordpress-development/display-first-paragraph-added-posts-via-wordpress/
The post template files are located in the main theme folder
– https://www.screencast.com/t/bfalqBLmR
Thanks
Thank you Simion for your answer, that looks almost like what I need.
Though, I might have been a bit unclear on my needs. I want to move my featured image between the first and second paragraph (with no manual editing).
Perhaps the code from your linked example, Simion, could be modified to make that work?
Hi,
I understand what you are trying to do. But the featured image is not included in the post content so it cannot be moved around, or positioned differently within the actual post content. You can see here for example how a post template structure looks
– https://www.screencast.com/t/a4b34gb9
That solution that I found will bring the first paragraph above the featured image
– https://www.screencast.com/t/zAFFoj0dg
But the paragraph will still be displayed where it normally does
– https://www.screencast.com/t/Eu4MwvqGScFZ
So maybe it could be hidden with a code like this, or similar
– https://www.screencast.com/t/9xxucZZDzUmB
.td-post-content p:nth-child(1) {
display:none;
}
Thanks
Thank you again for the answer,
Your last piece of code almost worked, I just had to change the (1) to (3) and that did the trick!
Before/After: https://imgur.com/a/jT6Er (embedding didn’t work)
.td-post-content p:nth-child(3) {
display:none;
}
(1) The first paragraph was removed from above the image and still shown below as normal.
(2) Nothing happened at all.
(3) First paragraph is shown above the image, and second paragraph is the first on below as I wan’ted it.
Thank you very much for the help. I hope my change to the code helps someone else with similar issue in the future.
-
This reply was modified 8 years by
tekniksmart.
