• Resolved snakedevil88000

    (@snakedevil88000)


    Hello,

    What is the code to call the function for the release date of movie please ?

    Exemple : <?php echo get_the__date…

    Thanks ^^

Viewing 11 replies - 1 through 11 (of 11 total)
  • Hello there,

    Please use this function:

    masvideos_template_single_movie_release_year

    Hope this helps. Let us know if you have any other questions or need further help.

    Thanks,
    Ibrahim

    Thread Starter snakedevil88000

    (@snakedevil88000)

    I have tried

    <?php echo get_the_movie_release_date(); ?>

    But it doesn’t work, i would like only the year please ^^

    Thread Starter snakedevil88000

    (@snakedevil88000)

    Thanks !

    But does not work with the JustWatch script 🙁

    <div data-jw-widget
         data-api-key="BurbjmlQxxxxxxxxxxxxxxxxxx" 
         data-object-type="movie"
    	      data-title="<?php echo get_the_title(); ?>"
    	 data-year="<?php echo masvideos_template_single_movie_release_year(); ?>"
    	 data-offer-label="price"
    	 data-theme="dark"> 
    </div>

    Hello again,

    Thank you for getting back. The masvideos_template_single_movie_release_year function is a template function. If you only want the release date, then you can use this:

    global $movie;
    $movie->get_movie_release_date();

    The above code should be used within the loop only.

    Hope this helps. Let us know if you have any other questions or need further help.

    Thread Starter snakedevil88000

    (@snakedevil88000)

    I found an alternative through this function which is ok for me:

    /* Adds date to end of title 
     * @uses Hooked to 'the_title' filter
     * @args $title(string) - Incoming title
     * @args $id(int) - The post ID
     */
    function my_add_date_to_title($title, $id) {
    
        // Check if we're in the loop or not
        // This should exclude menu items
        if ( !is_admin() && in_the_loop() ) {
    
            // First get the default date format
            // Alternatively, you can specify your 
            // own date format instead
            $date_format = get_option('date_format');
    
            // Now get the date
            $date = get_the_date($date_format, $id); // Should return a string
    
            // Now put our string together and return it
            // You can of course tweak the markup here if you want
            $title .= ' (' . $date . ')';
         }
    
        // Now return the string
        return $title;
    }
    
    // Hook our function to the 'the_title' filter
    // Note the last arg: we specify '2' because we want the filter
    // to pass us both the title AND the ID to our function
    add_filter('the_title','my_add_date_to_title',10,2);

    But how to replace the creation date of the article by the release date of the movie? ^^

    Thanks again ♥

    Thank you for getting back. You can use the 2 lines of code that I’ve shared with you earlier. It gives you the release date. You can use that in any function that you wish.

    Thread Starter snakedevil88000

    (@snakedevil88000)

    Oh thanks !

    But how do I add it here?

    data-year=”?”

    function masvideos_get_the_movie_release_date() {
        global $movie;
        return $movie->get_movie_release_date();
    }
    
    data-year="<?php echo esc_attr( masvideos_get_the_movie_release_date() ); ?>"

    You can add the function to functions.php and then call the function in the attribute.

    Thread Starter snakedevil88000

    (@snakedevil88000)

    Thanks again!

    The code works fine but it displays: 1975-06-20T00:00:00+01:00

    How can I get only the year? (1975 here)

    Thank you!

    Please try this updated code instead:

    function masvideos_get_the_movie_release_year() {
        global $movie;
        return date( 'Y', strtotime( $movie->get_movie_release_date() ) );
    }
    
    data-year="<?php echo esc_attr( masvideos_get_the_movie_release_year() ); ?>"
    Thread Starter snakedevil88000

    (@snakedevil88000)

    Thanks, great support!

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

The topic ‘Get the release date’ is closed to new replies.