Tagged: , ,

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1067964

    Hi,

    I am displaying both past and future posts on our site and I’d like to add an extra class to the $post_class on line 443 of /config-templatebuilder/avia-shortcodes/postslider/postslider.php if the date of the post is in the past.

    $post_class = "post-entry post-entry-{$the_id} slide-entry-overview slide-loop-{$post_loop_count} slide-parity-{$parity} {$last}";

    I’ve tried pulling the date using this within the foreach ($this->entries->posts as $entry) {

    $postdate = get_the_date( “Y-m-d”, $post_id );
    echo “Post ID ” . $the_id . ” was posted on ” . $postdate . “<br>”;

    It shows the ID’s of the posts but the date is the always the first posts date.

    Bit confused. Anyone had any luck with this?

    #1068351

    Hey DigitalEssence,

    You should be using the $the_id there too, not the $post_id, like this

    
    $postdate = get_the_date( “Y-m-d”, $the_id );
    echo “Post ID ” . $the_id . ” was posted on ” . $postdate . “<br>”;
    

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #1068366

    You should be using the $the_id there too, not the $post_id, like this

    Doh!

    That’s perfect thanks. I can now change the look of past events in the post slider.

    Please mark this as resolved and big thanks for your help.

    #1068369

    For anyone else who is interested in how I have achieved this and/or can see a better way of doing it.

    I’ve added the following to postslider.php

    // Detect if post is in the past and if so add a custom Class "oldpost"
    if (strtotime(get_the_date( "Y-m-d", $the_id )) < strtotime(date("Y-m-d"))) {
     $post_class = "post-entry post-entry-{$the_id} oldpost slide-entry-overview slide-loop-{$post_loop_count} slide-parity-{$parity} {$last}";
     }
    else {
     $post_class = "post-entry post-entry-{$the_id} slide-entry-overview slide-loop-{$post_loop_count} slide-parity-{$parity} {$last}";
     }

    I then uploaded postslider.php to child-theme/shortcodes/ (thanks @guenni007) and added the following to my functions.php file

    // Enable shortcodes to be loaded from child theme - used for postslider.php edits
    add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1);
    function avia_include_shortcode_template($paths)
    {
    	$template_url = get_stylesheet_directory();
        	array_unshift($paths, $template_url.'/shortcodes/');
    
    	return $paths;
    }
    #1068380

    by the way – you don’t need to hold the tree structure after /shortcodes
    so you can put in all edited ALB to the shortcodes folder itself – no need for subfolders.

    #1069139

    Hi,

    Let us know if it works properly if u do follow that.

    Best regards,
    Basilis

    #1069453

    Hi @basilis

    I’ve placed the file in /shortcodes as suggested by @guenni007 and it works fine.

    View post on imgur.com

    #1069619

    Hi DigitalEssence,

    Glad you got it working for you and thank you for sharing! :)

    If you need further assistance please let us know.

    Best regards,
    Victoria

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.