dlishus
Forum Replies Created
-
Forum: Plugins
In reply to: [Events Manager - Calendar, Bookings, Tickets, and more!] datepicker problemCan you please tell me where you found the call? I’m having the same issue and having a hard time finding the culprit. Thank you!
Forum: Hacks
In reply to: Add Pagination to querystrI took another look and played around with the original code you supplied. I removed the lines in bold and it’s working perfectly! My posts are sorted by date of event and paginated.
<?php
//Get today date
$today = strtotime(“now”);
$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
$args = array (
‘posts_per_page’ => ’20’,
‘post_type’ => array(‘annnouncement’, ‘audio_ann’),
‘paged’ => $paged,
‘meta_query’=> array(
array(
‘key’ => ‘date_of_event’,
‘value’ => date(“Y-m-d”, $today),
‘type’ => ‘DATE’,
‘compare’ => ‘>’,
)
),
‘meta_key’ => ‘date_of_event’,
‘orderby’ => ‘meta_value’,
);$the_query = new WP_Query($args);
?>THANK YOU!
Forum: Hacks
In reply to: Add Pagination to querystrSo close keesiemeijer! If I strip out the array for sorting by date, the posts appear with pagination. Thank you so much!
However, I still need to sort by date. When I placed the full code in, I got this error:
PHP Parse error: syntax error, unexpected T_VARIABLE in /path/to/file on line 28Line 28 is:
$the_query = new WP_Query($args);Therefore, I think this is something small with the syntax. Can you help me with that? I really appreciate it!
Forum: Hacks
In reply to: Add Pagination to querystresmi, I posted in the code you provided and am only getting the page title returned, not the title of the posts.
I had to add an endif (which I needed anyways for pagenavi) or else I got a white screen<?php //Get today date $today = strtotime("now"); //Revised query string $querystr = " SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'date_of_event' AND wpostmeta.meta_value > '" . date("m-d-Y", $today) . "' AND wposts.post_status = 'publish' AND wposts.post_type IN ('annnouncement', 'audio_ann') ORDER BY wpostmeta.meta_value ASC LIMIT 0, 20 "; $dateIndexes = array(); ?> <ul> <?php while (have_posts()) : the_post(); ?> <article class="cat_article "> <?php the_title(); ?> </article> <!--End Cat Article--> <?php endwhile;?> <?php if(function_exists('wp_pagenavi')) : wp_pagenavi(); endif; wp_reset_query();?>Curly Bracket, I appreciate the code – but I wasn’t able to get it working either. I’ve added the code as you’ve supplied and did a var_dump on $myposts if you’d like to take a look on what’s getting returned.
Forum: Hacks
In reply to: Add Pagination to querystrMy code looks like this:
<?php //Get today date $today = strtotime("now"); //Revised query string $querystr = " SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'date_of_event' AND wpostmeta.meta_value > '" . date("m-d-Y", $today) . "' AND wposts.post_status = 'publish' AND wposts.post_type IN ('annnouncement', 'audio_ann') ORDER BY wpostmeta.meta_value ASC LIMIT 0, 20 "; $pageposts = $wpdb->get_results($querystr); var_dump($pageposts); $dateIndexes = array(); ?> <?php if ($pageposts->have_posts()) : ?> <ul> <?php while (have_posts()) : the_post(); ?> <article class="cat_article "> test </article> <!--End Cat Article--> <?php endwhile; endif; ?>And I am getting values returned, see here
I’m using a custom query because I need to query two custom post types, which are sorted by date of an event based on a custom field.
Forum: Hacks
In reply to: Add Pagination to querystrNo luck, I’m getting the same issue “Call to a member function have_posts() on a non-object”
The white screen of death doesn’t show, but I tried this: Taking off the endif resulted in a white screen, and removing the “$pageposts = $wpdb->get_results($querystr);?>” made it so there was an open that from $dateIndexes
<?php //Get today date $today = strtotime("now"); //Revised query string $querystr = " SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'date_of_event' AND wpostmeta.meta_value > '" . date("m-d-Y", $today) . "' AND wposts.post_status = 'publish' AND wposts.post_type IN ('annnouncement', 'audio_ann') ORDER BY wpostmeta.meta_value ASC LIMIT 0, 20 "; $dateIndexes = array(); ?> <?php if ($pageposts->have_posts()) : ?> <ul> <?php while (have_posts()) : the_post(); ?> <article class="cat_article "> test </article> <!--End Cat Article--> <?php endwhile; endif; ?>Forum: Hacks
In reply to: Add Pagination to querystrThis is how I pasted it in:
<?php //Get today date $today = strtotime("now"); //Revised query string $querystr = " SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'date_of_event' AND wpostmeta.meta_value > '" . date("m-d-Y", $today) . "' AND wposts.post_status = 'publish' AND wposts.post_type IN ('annnouncement', 'audio_ann') ORDER BY wpostmeta.meta_value ASC LIMIT 0, 20 "; $dateIndexes = array(); $pageposts = $wpdb->get_results($querystr);?> <?php if ($pageposts->have_posts()) : ?> <ul> <?php while (have_posts()) : the_post(); ?> <article class="cat_article "> //html goes here </article> <!--End Cat Article--> <?php endwhile; ?> </ul> <?php else : ?> <p>No upcoming events</p> <?php endif; ?>And I’m not getting any posts to display. My error log says
PHP Fatal error: Call to a member function have_posts() on a non-object in /path/to/front-page.phpThank you for your help thus far!
Forum: Hacks
In reply to: Add Pagination to querystrI’m not a php expert, so I’m not sure how to change it. I tried switching out foreach with while, and then endforeach with endwhile and that didn’t work. Is this something you could help me with please?