#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2015
    Posts
    1
    Rep Power
    0

    Help to create gallery with counter


    I'm needing to create a photo gallery with a heart counter like the example below. Does anyone know how to do this?[IMG][/IMG]

    I actually have the WP-PostRatings plugin. It is nice. I can insert it into a post and on the gallery page but I need it to show on each photo.[IMG][/IMG]
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2014
    Posts
    41
    Rep Power
    2
    first you create plugins in under wp theme and put ths code :
    /*
    Plugin Name: plugin_name
    Plugin URI:
    Description: Your WordPress Gallery Plugin description.
    Version: 1.0
    Author: Your Name
    Author URI:
    */

    Add the code below to your main plugin file.

    <?php
    remove_shortcode('gallery');
    add_shortcode('gallery', 'parse_gallery_shortcode');
    ?>

    this function, namely use that function shortcode to any page: parse_gallery_shortcode.


    <?php
    function parse_gallery_shortcode($atts) {

    global $post;

    if ( ! empty( $atts['ids'] ) ) {
    // 'ids' is explicitly ordered, unless you specify otherwise.
    if ( empty( $atts['orderby'] ) )
    $atts['orderby'] = 'post__in';
    $atts['include'] = $atts['ids'];
    }

    extract(shortcode_atts(array(
    'orderby' => 'menu_order ASC, ID ASC',
    'include' => '',
    'id' => $post->ID,
    'itemtag' => 'dl',
    'icontag' => 'dt',
    'captiontag' => 'dd',
    'columns' => 3,
    'size' => 'medium',
    'link' => 'file'
    ), $atts));


    $args = array(
    'post_type' => 'attachment',
    'post_status' => 'inherit',
    'post_mime_type' => 'image',
    'orderby' => $orderby
    );

    if ( !empty($include) )
    $args['include'] = $include;
    else {
    $args['post_parent'] = $id;
    $args['numberposts'] = -1;
    }

    $images = get_posts($args);

    foreach ( $images as $image ) {
    $caption = $image->post_excerpt;

    $description = $image->post_content;
    if($description == '') $description = $image->post_title;

    $image_alt = get_post_meta($image->ID,'_wp_attachment_image_alt', true);

    // render your gallery here
    echo wp_get_attachment_image($image->ID, $size);
    }
    }
    ?>
    now you can activate that plugin and adjust your html.
    thank you.

IMN logo majestic logo threadwatch logo seochat tools logo