• alexfromlindsaylovespets

    (@alexfromlindsaylovespets)


    Hi, I’m trying to show photos from a Google Photos album that are filtered to a single date. In this case, I have a custom post type called “pupdates” and I’m pulling the album ID from the author meta, and the date from the post meta. The albums display, but they are not filtered. They display from the most current and show the entire contents. I think I have the correct syntax. Can you point me in the right direction? Thank you! LOVE Photonic!! 🥰

    //———————————————————-
    // function that runs when shortcode is called
    function photoniclovenote() {
    // Use [g_album_lovenote];

    // Get current post author ID
    global $post;
    $user_ID = $post->post_author;
    $post_date = $post->post_date;
    
    if ($user_ID == 0) {
        // The user ID is 0, therefore the post has no author
        return; // escape this function, without making any changes
    } else {
        global $wpdb;
        $album_id = $wpdb->get_results("SELECT meta_value FROM wplh_usermeta WHERE meta_key = 'g-album-id' AND user_id = $user_ID");
    
        // Format the post date to Y/n/j (without leading zeroes)
        $formatted_date = date('Y/n/j', strtotime($post_date));
        $previous_date = date('Y/n/j', strtotime('-1 day', strtotime($post_date)));
        $date_filter = $previous_date . '-' . $formatted_date; // From day before to the post date
    
        if (!empty($album_id[0]->meta_value)) {
            // If album ID is not empty, display shortcode based on the existing logic
            $data = "[gallery type='google' view='album' date_filters='".$date_filter."' crop_thumb='crop' thumb_size='150' main_size='1200' layout='random' count='2' album_id='".$album_id[0]->meta_value."']";
        } else {
            // If album ID is empty, check user role
            $user_info = get_userdata($user_ID);
    
            if (in_array('wpamelia-customer', $user_info->roles)) {
                // If user role is "wpamelia-customer", display a specific shortcode
                $data = "";
            } else {
                // If user role is not "wpamelia-customer", display a fallback shortcode
                $data = "";
            }
        }
    }
    
    // Output needs to be return
    return $data;

    }

    // register shortcode
    add_shortcode(‘g_album_lovenote’, ‘photoniclovenote’);

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter alexfromlindsaylovespets

    (@alexfromlindsaylovespets)

    Well, I got the date filter seemingly working but it’s strangely showing a blank thumbnail instead of the first image. The filtering was the big issue, but this one is rather strange. I’ve tried just using the single date but I get the same blank thumbnail issue.

    BTW, I ❤️ Photonic. HUGE fan!

    Plugin Author Sayontan Sinha

    (@sayontan)

    I couldn’t determine which of your galleries was a Photonic gallery – all of them seem to be native WP galleries. Which gallery is being generated by Photonic?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Date_filters Issue’ is closed to new replies.