Retrieve WordPress Photo' value to be placed in custom php page
P粉744691205
P粉744691205 2024-04-02 19:13:12
0
1
420

I need to create a WordPress website from existing HTML (more specifically from an asp.net website), so I create a template and target the php page using:

<?php
 /*
 Template Name: students
 */
 ?>

My question : How to insert an image in WordPress CMS\dashboard and how to retrieve its value (only the value of the image) . Here is a static example:

<div class="col-lg-6 img-grids mt-lg-0 mt-5 pl-lg-4">
    <img src="<?php echo get_template_directory_uri().'/assets/images/p1.jpg'; ?>" alt="" class="img-fluid radius-image" />
    <img src="<?php echo get_template_directory_uri().'/assets/images/p2.jpg'; ?>" alt="" class="img-fluid radius-image" />
    <img src="<?php echo get_template_directory_uri().'/assets/images/p3.jpg'; ?>" alt="" class="img-fluid radius-image" />
</div>

But if the website is static, the above method will work, but I need to be able to manage the images from the backend. Changing dynamic images.

Idea 1:

  1. I uploaded photos from my WordPress gallery in the post.
  2. Then <?php the_content(); ?> Display an ugly gallery as is, not just the value of the image.

Idea 2:

  1. In functions.php I could try to create a shortcode or a PHP function to retrieve the gallery value for a specific post ID, but then the post might be deleted.

P粉744691205
P粉744691205

reply all(1)
P粉916553895

To do this, you can first create a meta box that inserts the image into the page, and then insert the meta box value into your code. This way, every time the image in the page's meta box is changed, it will also change on the user side. General Example (WooCommerce Image Gallery)

My suggestion is to use the acf plugin, but you can also get it from this link.

You can also use this linkCreate a gallery

Of course you can encode all of this But I recommend using this plugin.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template