Skip to content

Instantly share code, notes, and snippets.

@Davidlab
Last active December 14, 2015 19:08
Show Gist options
  • Save Davidlab/5134013 to your computer and use it in GitHub Desktop.
Save Davidlab/5134013 to your computer and use it in GitHub Desktop.
Justified Image Grid Nextgen tags widget. Paste this in your functions.php with https://gist.github.com/Davidlab/5130772 (also creates shortcode, but includes needed function for tags widget). Within this snippet you will see an area where you need to include the page name or ID of your gallery page. This is to allow the widget to only load on t…
class justified_tagcloud_widget extends WP_Widget {
/** constructor */
function justified_tagcloud_widget() {
$widget_ops = array(
'description' => 'Display\'s a Tag Cloud based on Nextgen, used by Justified Image Grid '
);
parent::WP_Widget(false, $name = 'Justified Image Grid Tag Cloud', $widget_ops);
}
/** display widget */
function widget($args, $instance) {
//Change the page that it should be included in. Only should be loaded on your gallery page. Or what ever you named it.
$my_gallery_page = 'gallery';//change 'gallery' to your page name. You can also use ID of page.
if (is_page($my_gallery_page)) { ?>
<?php
global $post;
$slug = get_post( $post )->post_name;?>
<div class="featured-block">
<!-- this link inserts a link back to the same page to view all and resets the page again. -->
<a href="<?php echo esc_url( get_permalink( get_page_by_title( $slug ) ) ); ?>">View All</a>
<?php
$out = justified_tag_cloud('');
echo $out;
?>
</div>
<?php
}
}
}
// register cs_month_widget widget
add_action('widgets_init', create_function('', 'return register_widget("justified_tagcloud_widget");'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment