Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other How to insert each image of gallery in certain div? WordPress

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #244747
    gtw73755
    Participant

    I’m trying to reproduce this Masonry to show a gallery. I created a CPT for this. “CPT – Gallery”.

    First, I thought of creating a Custom Post Type to publish all images together.

    MY CPT:

    —>>> title <<<—
    —>>> image default – thumbnail <<<—
    —>>> cotent <<<—
    —>>>images<<<—
    —>>>images<<<—
    …..

    The first three sections (title, image default and content) is the basics. Is ready.

    After, I thought about using custom metabox and add each image URL. However, add url by url is nothing intuitive and a lot more work for the user, be it newbie or advanced. Furthermore, the amount will vary pictures can be 1, may be 5 may be 10 and so on….

    I saw that there is a plugin for wordpress, but the plugin not is full width and when I set the css of plugin to be full width, the Mansory gets several bugs in the viewport resize.

    Noting the functioning of the plugin and your code, I saw that in each post, the plugin uses the own gallery of wordpress editor. It take the generated shortcode (inside of the_content();) and displays the images within the Mansory classes.

    I’m trying to do this, but without success.

    Anyway, what I want to do?

    ->Catch the shortcode of wordpress gallery and display each image within the divs of my masonry <-

    Example logical:
    Shortcode of gallery: [gallery ids="1,2,3,4,5,6"]

    …. I take each image and display in the loop ….

    Practical example:

    Here I execute the loop with the divs of masonry.

    `&lt;?php
      $args = array( 'post_type' =&gt; 'gallery', 'showposts' =&gt; 1 );
      $wp_query = new WP_Query($args);
      if(have_posts()):
        while ($wp_query -&gt; have_posts()) : $wp_query -&gt; the_post();
    ?&gt;
    
    &lt;div class="item"&gt;
      &lt;figure style="margin: 0px !important" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"&gt;
          &lt;a href="&lt;?php IMAGE 1 OF GALLERY WP; ?&gt;" itemprop="contentUrl" data-size="1800x1200" data-index="0"&gt;
              &lt;img src="&lt;?php IMAGE 1 OF GALLERY WP; ?&gt;" class="image" itemprop="thumbnail" alt=""&gt;
          &lt;/a&gt;
      &lt;/figure&gt;
    &lt;/div&gt; `
    

    With the loop will appears all imagens in gallery.

    `&lt;div class="item"&gt;
      &lt;figure style="margin: 0px !important" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"&gt;
          &lt;a href="&lt;?php IMAGE 2 OF GALLERY WP; ?&gt;" itemprop="contentUrl" data-size="1800x1200" data-index="0"&gt;
              &lt;img src="&lt;?php IMAGE 2 OF GALLERY WP; ?&gt;" class="image" itemprop="thumbnail" alt=""&gt;
          &lt;/a&gt;
      &lt;/figure&gt;
    &lt;/div&gt; 
    
    &lt;div class="item"&gt;
      &lt;figure style="margin: 0px !important" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"&gt;
          &lt;a href="&lt;?php IMAGE 3 OF GALLERY WP; ?&gt;" itemprop="contentUrl" data-size="1800x1200" data-index="0"&gt;
              &lt;img src="&lt;?php IMAGE 3 OF GALLERY WP; ?&gt;" class="image" itemprop="thumbnail" alt=""&gt;
          &lt;/a&gt;
      &lt;/figure&gt;
    &lt;/div&gt;&lt;blockquote&gt;` 
    
     and so on.....
    

    How I can do this?

Viewing 1 post (of 1 total)
  • The forum ‘Other’ is closed to new topics and replies.