WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: NextGEN Gallery] Short code anywhere outside of post loop? (6 posts)

  1. mariostella
    Member
    Posted 5 years ago #

    Hi,

    This seemed pretty trivial, but I am struggling a lot.
    I am trying to get an NGG gallery to show outside the canonical post place in my template. Therefore the shortcode won't work, so I tried with:

    <?php echo do_shortcode('[slideshow=255]'); ?>

    (yes I am using NGG prior to 1.x)

    and also tried modifying this one which I am successfully using:

    <?php
    $gal = get_post_meta($post->ID, 'gallerypopup', true);
    $gal = apply_filters('the_content', $gal );
    echo $gal;
    ?>

    both to no avail. How do I call the shortcode in my template outside the post? If this can help, I am also using the above $gal variable within the loop for other purposes, so if this simplifies things, there you go.

    Thanks for any help.

  2. mariostella
    Member
    Posted 5 years ago #

    Anyone on this? Alex?

  3. mariostella
    Member
    Posted 5 years ago #

    I tried new strategies but so far nothing worked out. It seems like there is no way to achieve this? Any help, as usual, is greatly appreciated.

  4. brinck10
    Member
    Posted 4 years ago #

    This question bothers me as well, and so far I had no luck either. Anyone?

  5. goto10
    Member
    Posted 4 years ago #

    Hi guys,

    I'm using Nextgen v1.3.5 and I'm able to make gallery calls outside of the actual post. (I know mariostella is using an older version of NGG though).

    Anyhoo, I'm just doing this in the header of my WordpPress template file:

    <?php
    echo do_shortcode('[nggallery id=3 template=my_cool_template]');
    ?>

    Note: the template parameter is referencing my /wp-content/themes/my_cool_theme/nggallery/gallery-my_cool_template.php file

    I've just got started messing with this. My gallery template is actually just outputting a xml path (generated using NGG tags), but it does get at NGG outside of the post. Also, I'm doing this on a "page". Not sure if that makes a difference, or even if this info is going to help, but I ran into this post while researching something else, and figured it might be relevant to your interests.

  6. illwill79
    Member
    Posted 4 years ago #

    goto10 - thank you so much! I was beating myself up trying to figure out a simple way to get shortcode to work in non-post locations (theme sidebar, etc) and this did the trick.

    Just as a heads up on what I was trying to do: I wanted new users' blogs to be able to display an image that they upload (sort of like an avatar). I wanted the image to be dynamic based on each users' blog (so id 1 for each blog would be a different picture obviously).

    Using your above method I was able to insert:

    <div class="side_box">
       <h3><?php _e('My Image','monochrome'); ?></h3>
       <ul><?php echo do_shortcode('[singlepic id=1 w=100]');?></ul>
       </div>

    Works wonderfully. Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.