Since the answer to my last question came very quickly, I thought I would try my luck again.
I am trying to create a gallery within a custom post type that I have created. I want to be able to add images / galleries in the post through WordPress admin editor, then draw a function picture, wrap them in the divis and replace the existing gallery with new images.
I would like to do this because I want to fit the images in a grid of images of different sizes. For example, image 1 will be full width, image 2 half width, image will be 3 quarters and so on.
I have tried two ways, a get_children ()
$ featuredImage = get_post_thumbnail_id ($ post-> ID); $ ImageArgs = array ('numberposts' => 5, 'order' = & gt; 'DESC', 'post_mim_type' = & gt; 'image', 'post_perrent' = & gt; $ post- & gt; ID , 'Post_type' = & gt; attachment ',' exclusion '= & gt; $ special image); $ Attachment = Matching Object ($ imageArgs, ARRAY_A); $ Rekeyed_array = array_values ($ attachments); $ Child_image = $ rekeyed_array [0]; Echo '& lt; Div class = "project-img" & gt; & Lt; Img src = "'. $ Child_image [' guid ']." "Class =" project-image "& gt; & lt; / div & gt; & # 39; $ child_image = $ rekeyed_array [1]; echo '& lt; div class =" project-img w2 "& gt; & lt; Img src = "'. $ Child_image ['guid']. "" & Gt; & Lt; / Div & gt; '; $ Child_image = $ rekeyed_array [2]; Echo '& lt; Div class = "project-img w3" & gt; & Lt; Img src = "'. $ Child_image [' guid ']." "& Gt; & lt; / div & gt; 'echo' & lt; div class =" project-img w3 "& gt; & lt; img src =" '. $ Child_image ['guid']. "" & Gt; & Lt; / Div & gt; ';
and other get_post_gallery ()
$ gallery = get_post_gallery (get_the_ID (), incorrect); / * Loop through all the images and after them one by one * / foreach ($ Gallery ['src'] AS $ src) {? & Gt; & Lt; Div class = "project-img" & gt; & Lt; Img src = "& lt ;? php echo $ src ;? & gt; Alt =" gallery image "/> & lt; php}
< P> I have not made much progress with get_post_gallery ()
, but I understand that I have to use wp_get_attachment_url
-
I'm a bit confused about Array, so how do I select the first image in the array and wrap it in a div with the square "image-big" and then wrap another image in another div with "Image-Medium" class How about to go?
-
I How do I change the copy of the Lari / images which I have added to the new gallery / images via the editor? Right now, I get two examples of images, are added through the original editor, and the pictures obtained through the works.
Edit I found out 1 question, I think read on associative arrays and realized that you are the source of each image To get the URL echo $ galle Ry ['src'] [0];
Some questions are still confused about Question 2, though.
understand it.
Remove the original gallery function remover_first_gallery ($ output, $ attr) {$ output = '& lt ;! - Gallery 1 was here - & gt; '; // should be undefined return $ output; } Add_filter ('post_gallery', 'remove_the_first_gallery');
All galleries on that page were deleted. But since my new gallery is not technically a post_gallery, it was left alone.
Comments
Post a Comment