• Resolved g2lyon

    (@g2lyon)


    Google Drive Gallery works fine with block in the post content.

    For design convenience of a custom post I had like to make it work from a native custom field or ACF custom field.
    Just for a test I added the following in content.php
    print'<!-- wp:skaut-google-drive-gallery/gallery {"path":["My directory"]} /-->';
    Of course it doesn’t display anything!

    Is there a way to do this?
    The dream would be that I could include some code in template file
    content-mycustompost.php.
    For example something like this:

    function somefunction('gdrivedirectory'){
              some code to display the images located in the directory
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Marek Dědi?

    (@marekdedic)

    Hi,
    I’m not really familiar with custom fields (just skimmed their docs), so I may be talking nonsense.

    I see 3 ways to do something like that – Include a block like you did, include a shortcode, or call the PHP functions directly (see https://github.com/skaut/skaut-google-drive-gallery/blob/2.7.1/plugin/frontend/shortcode.php). Either way, you need to involve the PHP code in some way.

    From what I read in the docs, custom fields aren’t really meant for this, right? (not saying you can’t use them, but you’d probably be scratching your left ear with your right hand…)

    I’m afraid I can’t help any further as I don’t really understand this functionality of WP…
    Marek

    Thread Starter g2lyon

    (@g2lyon)

    Hello Marek,
    Thanks for answer.
    Blocks or short code let the user locate the gallery anywhere in the post while I want the gallery to stay only at the bottom of the post, and only one gallery per post.

    In the mean time I found a way with a couple of php lines in the content.php template, just after the_content(); as follows :

    $folder_name = get_post_field('gdrive_folder_name');
    $shortcode ='[sgdg path="'.$folder_name.'"]';
    print 'My Gallery:'. apply_filters( 'the_content', $shortcode ); 

    It works like a charm.
    No need to enter the complete short code, only the folder name in the custom field.
    If the user hasn’t knowlegde of the short code he will not use it,
    and I disabled the block in the block manager.

    So far so good!

    Your idea of using google drive API+some kind of lightbox is very good for sites in low performance server (my case). Thanks for the work!

    • This reply was modified 5 years ago by g2lyon.
    • This reply was modified 5 years ago by g2lyon.
    • This reply was modified 5 years ago by g2lyon.
    • This reply was modified 5 years ago by g2lyon.
    • This reply was modified 5 years ago by g2lyon.
    • This reply was modified 5 years ago by g2lyon.
    • This reply was modified 5 years ago by g2lyon.
    • This reply was modified 5 years ago by g2lyon.
    • This reply was modified 5 years ago by g2lyon.
    Plugin Author Marek Dědi?

    (@marekdedic)

    Glad you found a workaround that solves your issue!

    Marek

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘google-drive-gallery in a field ??’ is closed to new replies.