Now what I'm trying to do is make it so the image I insert in the HTML editor (post_content) will link to 1 and the attachments from the plugin will apply to the rest. However, depending on the number of attachments I have, should reflect on the numbers outputted.
Example (Let's say I have 4 attachments) Process: 1 (post_content image) 2 3 4 5 (attachment images)
Here is the code I have so far that reflects the attachments. What I need help with is how to display the URL of the post_content image to apply to 1.
I believe I have solved this. Not exactly sure if it will work overall since I only tested on one page. Perhaps more advanced WP developers can chime in.
@wolfcry911 What that does is give the permalink to the post not the image file (which is what I need). The following code below is what I believe to be the issue however I don't know how to call the image I inserted inside the editor.
In case anyone doesn't understand. ALL I need is to get the URL of the image I inserted into the HTML editor in the backend. I believe in order to get that, I need to use wp_get_attachment_src however I'm not sure how to go about getting the ID dynamically.
Using a function, I believe I have solved the issue.
I placed this code in my functions.php file that allows me to grab the very first image in a post.
// CREATES A FUNCTION TO GRAB FIRST IMAGE OF A POST function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = $matches [1] [0];
Result: Process: 1 2 3
Now what I'm trying to do is make it so the image I insert in the HTML editor (post_content) will link to 1 and the attachments from the plugin will apply to the rest. However, depending on the number of attachments I have, should reflect on the numbers outputted.
Example (Let's say I have 4 attachments)
Process: 1 (post_content image) 2 3 4 5 (attachment images)
Here is the code I have so far that reflects the attachments. What I need help with is how to display the URL of the post_content image to apply to 1.
Here is the following code:
End result:
I placed this code in my functions.php file that allows me to grab the very first image in a post.
From there I can echo the URL using the following
The end result would look like this