Tagged: date, post, postslider
-
AuthorPosts
-
February 17, 2019 at 7:48 pm #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?
February 18, 2019 at 1:41 pm #1068351Hey 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,
VictoriaFebruary 18, 2019 at 2:16 pm #1068366You 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.
February 18, 2019 at 2:25 pm #1068369For 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; }
- This reply was modified 5 years, 9 months ago by DigitalEssence.
February 18, 2019 at 2:44 pm #1068380by 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.February 19, 2019 at 10:37 pm #1069139Hi,
Let us know if it works properly if u do follow that.
Best regards,
BasilisFebruary 20, 2019 at 1:46 pm #1069453February 20, 2019 at 6:49 pm #1069619Hi 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 -
AuthorPosts
- You must be logged in to reply to this topic.