• Resolved kidznc

    (@wsp-kk)


    Hello!

    I’m presently working on a site (offline on XAMPP – sorry, no link) that displays all our blog posts, downloads, and events in a single feed, using a query created with FacetWP.

    This said, I’ve been able to display each MaxGallaria gallery as a post just fine, except there is no text output from ?php the_excerpt();. That’s when I looked through the PHP of the plugin and realized that the description inserted in the gallery code is custom:

    if ($options->get_description_enabled() == 'on' && $options->get_description_position() == 'above') {
    			if ($options->get_description_text() != '') {
    				$output .= '<p class="mg-description">' . $options->get_description_text() . '</p>';
    			}
    		}

    Is there a way I can call on get_description_text() from outside of the plugin? I have been unsuccessful applying the code in various forms to the display code for the blog. I’m also open to using the default text/visual editor for each gallery post, but it looks as if this isn’t possible in MaxGalleria.

    Do let me know if there are any options that would work for me here. Your plugin is the absolute first to do everything we need. Granted, I’ll need to get the Pro version for albums, but after trying out about 15 other plugins to no avail, I’m calling this one a win.

    Thanks!

    -KK

    • This topic was modified 7 years, 4 months ago by kidznc.
    • This topic was modified 7 years, 4 months ago by kidznc.
    • This topic was modified 7 years, 4 months ago by kidznc.
    • This topic was modified 7 years, 4 months ago by kidznc.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author AlanP57

    (@alanp57)

    The gallery description is stored in the postmeta table with the key, ‘maxgallery_description_text’. So you can use

    get_post_meta( $gallery_id, 'maxgallery_description_text', true);

    where $gallery_id is the ID number of the current gallery.

    Thread Starter kidznc

    (@wsp-kk)

    Dear Alan:

    Thank you very much.

    I went ahead and tried it as follows, though it doesn’t seem to be pulling anything; the description remains blank.

            <?php if ( is_search() || !is_single() ) : // Only display Excerpts for Search ?>
                <div class="entry-summary">
                  <?php get_post_meta( $gallery_id, 'maxgallery_description_text', true); ?>
                    <p class="read-more"><a href="<?php the_permalink(); ?>"><?php esc_html_e('Read More &raquo;','photolite'); ?></a></p>
                </div><!-- .entry-summary -->

    (FYI: Usually <?php the_excerpt(); ?> sits in its place, I just swapped it for the test rather than make an if statement).

    I’ll try echoing the output of the $gallery_id to see if it’s finding the gallery with get_post_meta or not.

    -KK

    • This reply was modified 7 years, 4 months ago by kidznc.
    • This reply was modified 7 years, 4 months ago by kidznc.
    Thread Starter kidznc

    (@wsp-kk)

    FYI, was just able to get it to work with a slight modification to that code. It looks as if $post->ID did the trick:

    <?php echo get_post_meta( $post->ID, 'maxgallery_description_text', true); ?>

    This is the final code I used, with an if/else conditional. I realize that I could stack the code without the conditional and get the same result, but that’d be just be sloppy, IMHO.

    It’ll also display a gallery description on the blog even if I don’t enable it on the gallery, which happens to work well for the site I’m working on right now:

    <?php if ( is_search() || !is_single() ) : // Only display Excerpts for Search ?>
        <div class="entry-summary">           
    	<? if ($post_type == 'maxgallery'): ?>
    		<p><?php echo get_post_meta( $post->ID, 'maxgallery_description_text', true); ?></p>
    	<? else: ?>
    		<?php the_excerpt(); ?>
    	<? endif; ?>
        <p class="read-more"><a href="<?php the_permalink(); ?>"><?php esc_html_e('Read More &raquo;','photolite'); ?></a></p>
    </div><!-- .entry-summary -->

    Thanks again!

    -KK

    • This reply was modified 7 years, 4 months ago by kidznc.
    • This reply was modified 7 years, 4 months ago by kidznc.
    • This reply was modified 7 years, 4 months ago by kidznc.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Get / echo the gallery description for a blog post’ is closed to new replies.