jrmyp
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Pages Not Showing Up in DashboardFigured it out, some code in my functions.php file throwing things off. Kids, always be sure to reset your queries!
wp_reset_query();Forum: Fixing WordPress
In reply to: Pages Not Showing Up in DashboardI’ve narrowed it down to being something in my custom Theme though I can’t seem to narrow it down any further just yet.
Posting the code solution for anyone else who needs to do something similar.
First, you’ll need to go into your functions.php file and add the following function:
function my_alm_query_args_date_after($args){ if(isset($args['the_date'])){ $date = date('Y-m-d H:i:s', $args['the_date']); // Get date timestamp and convert to readable format $args['date_query'] = array( array( 'before' => $date, ), ); } return $args; } add_filter( 'alm_query_args_date_after', 'my_alm_query_args_date_after');Then, in single.php, the shortcode:
<?php $current = get_the_ID(); $postDate = get_the_date('Y-m-d H:i:s'); $date = strtotime($postDate); echo do_shortcode('[ajax_load_more id="date_after" custom_args="the_date:'. $date .'" exclude="'.$current.'"]'); ?>Works like a charm.
- This reply was modified 9 years, 4 months ago by jrmyp.
Thanks for all your help @dcooney, I was able to remove the current post by using the get_the_ID(); function and storing that as a variable as your excluding posts example showed.
Any suggestions on how to filter out any posts that are newer than the current single post?
Fantastic, thank you so much for that Darren.
One tip I’d add for anyone who else who comes across this, just be sure to include the “offset” parameter in your shortcode to avoid showing the current post in the loop, e.g.:
echo do_shortcode('[ajax_load_more offset='1']');