229 reputation
18
bio website
location
age
visits member for 2 years, 8 months
seen Jul 28 at 1:25

Apr
10
awarded  Popular Question
Feb
17
awarded  Yearling
Mar
10
awarded  Tumbleweed
Jul
8
comment Check if first paragraph is an image, then show custom code right after it?
+1 Nice solution! Much simpler than my second attempt.
Jul
8
revised Check if first paragraph is an image, then show custom code right after it?
Updated answer with a better solution.
Jul
5
comment Check if first paragraph is an image, then show custom code right after it?
@Bainternet To parse just the first paragraph, I explode the content like so $parts = explode( '</p>', $content, 2 ); then I parse only the first item in the $parts array, i.e. the first paragraph.
Jul
5
comment Check if first paragraph is an image, then show custom code right after it?
@AahanKrish I'm sorry, unfortunately I don't have access to my main computer at the moment, so I haven't been able to use my local server or access the function I had written. However, I should be able to get it back, and add the edit within a few days.
Jul
4
awarded  Commentator
Jul
4
comment Check if first paragraph is an image, then show custom code right after it?
@AahanKrish I altered the function so that the DOMDocument would only parse the first paragraph, then tested the execution time against the original. I would agree that the speed difference is negligible (on my local machine, I'm not sure if the difference would be greater on a web server). Here are my results, Original: 0.00034-0.00049 seconds, New Function: 0.00018-0.00026 seconds, If you would like, I can edit my answer to include the new function.
Jul
4
answered Check if first paragraph is an image, then show custom code right after it?
Jul
4
answered Set default text for the_search_query();
Jun
25
awarded  Teacher
Jun
25
answered Checking url from plugin
Jun
25
awarded  Editor
Jun
25
revised How to query post by user role?
deleted 10 characters in body
Jun
25
answered How to query post by user role?
Jun
10
comment Make custom post type display as a page
This works perfectly, thanks for your help!
Jun
10
accepted Make custom post type display as a page
Jun
10
comment Make custom post type display as a page
I'm actually not looking to list multiple items of a custom post type, but rather when the user is viewing one, /post-type/permalink/ it will display not as a post, with the date and author, but as a page with just the title and content.
Jun
9
asked Make custom post type display as a page