robbiegod
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Query custom post types by two custom date fieldshi there gran3,
Actually my Event List Widget is not a widget in terms of a wordpress widget. It was a combination of a wordpress query, jquery ajax call that sent the year and month to a wordpress page that would output the results and then refresh the results using ajax.
I’ll be around my computer where my files are located on Monday, I can try to help you out some more then.
happy thanksgiving!
Forum: Plugins
In reply to: [GA Nav Menus Tracking] ga.js or universal.js?Please update this plugin to work with the new Universal Tracking Code ??
Forum: Plugins
In reply to: [JoeMobi - Create your own Native Mobile App] Still Supported?I don’t know for certain, but since the plugin hasnt been updated in years, i would not hold your breath on this one waiting for updates. ??
This seems like a really great idea and plugin. I wonder if the company will release it on Github in an open source fashion so others can take the ball and run with it.
Forum: Fixing WordPress
In reply to: Query custom post types by two custom date fieldsAwesome!!! Thank you keesiemeijer!
I definitely owe you a beer! This works. My god, that was a tricky thing to do. I think maybe they should post this on the official Advanced Custom Fields page instead of the short solution they have.
Your filter and the query work perfectly for me.
Thanks again!
Forum: Fixing WordPress
In reply to: Query custom post types by two custom date fieldsThanks for the reply. I’ll try it out tonight and report back.
For now, in my project, I’ve just reverted back to the event calendar plugin, but if I can ditch that plugin that will be a good thing. Its overkill for what we need.
I’ll report back here, thanks for your help. If it works I owe you a beer!
Forum: Fixing WordPress
In reply to: Query custom post types by two custom date fieldsKinda shifted gears a bit. I came up with an idea to store the range of dates between the two dates selected into a new custom field. I made a textarea custom field and wrote a function that grabs the range of the two dates and the saves it into this field.
I’m storing it as a string like this:
20140506,20140507,20140508,20140509
This event starts on may 6 2014 and ends on may 9 2014.
The way i imagined this working is I’d store the range in the textarea and then create another range via the code, not stored in the database, the new range would from first day of the month to the last day of the month. Then I was gonna send the string or array, whatever would work and do a meta query using compare “IN” to get any matches. This doesn’t seem to be working.
I make the range like this – the function takes the dates and then i convert the array it makes to a string.
$aryDates = createDateRangeArray($startday, $endday); $date_str = implode(",", $aryDates);
So, then i tried this:
$all_events = array ( 'post_type' => 'events', 'posts_per_page' => 50, 'status' => 'published', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'auto_event_date_span', 'value' => $date_str, 'compare' => 'IN', 'type' => 'NUMERIC' ) ) );
Is there a way i can do what i describle with wp_query and meta_query OR do i need to write a custom query?
Forum: Fixing WordPress
In reply to: Query custom post types by two custom date fieldsThe problem with the query above is the same as before, it won’t return events that span multiple months. In the case of an event that starts in May and ends in July, the event won’t show on the June page.
Here is what I’m thinking I’ll need to do.
Yeah that query does the same thing. I’m thinking I’ll need to write two queries for this or 1 query and a filter of some sort.
Something like one primary query to get all of the events in the database and grab all of the start and end dates. Maybe put all of them into an array?
Then another query to split the results into groups by month and year and display those results based on the query string i send it. Query string is month and year numeric values.
The first part of that is easy enough, but how about the second part? I’m gonna investigate that now.
Forum: Fixing WordPress
In reply to: Query custom post types by two custom date fieldsWouldn’t the result be the same with that query? I’m pretty I tried that type of query too and I got the same result.
But, i’ll try it again and let you know how it goes.
Forum: Fixing WordPress
In reply to: Query custom post types by two custom date fieldsI came up with an ok solution for making the events appear. I added 12 checkboxes for each month and then i changed the query to look for the month in that field.
This is not ideal, but i can’t seem to get the range query to work.
I would really like to get the date range to work because then this new system would be perfect and then i can get rid of one of the plugins.
Does anyone have any additional suggestions?
Forum: Fixing WordPress
In reply to: Query custom post types by two custom date fieldsHi keesiemeijer – thanks for the reply…I still can’t get this to work exactly. Turning out to be quite complicated.
The code in my page:
if (isset($_GET['_m'])) { $current_month = str_pad($_GET['_m'], 2, '0', STR_PAD_LEFT); $current_day = "01"; // day one $current_year = $_GET['_y']; $get_last_day = $current_year.$current_month.$current_day; $lastday = date("t", strtotime($get_last_day)); $tempstartday = $current_year.$current_month.$current_day; $tempendday = $current_year.$current_month.$lastday; $startday = date('Ymd', strtotime($tempstartday)); $endday = date('Ymd', strtotime($tempendday)); } else { $current_month = str_pad(date('d'), 2, '0', STR_PAD_LEFT); $current_day = "01"; // day one $current_year = date('Y'); $get_last_day = $current_year.$current_month.$current_day; $lastday = date("t", strtotime($get_last_day)); $tempstartday = $current_year.$current_month.$current_day; $tempendday = $current_year.$current_month.$lastday; $startday = date('Ymd', strtotime($tempstartday)); $endday = date('Ymd', strtotime($tempendday)); } add_filter( 'get_meta_sql', 'get_meta_sql_date' ); $qryevents = array( 'post_type' => 'events', 'posts_per_page' => 50, 'status' => 'published', 'meta_key' => 'event_start_date', 'orderby' => 'meta_value', 'order' => 'ASC', // produces meta join and where clauses for the query // which will be filtered in functions.php 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'event_start_date', 'value' => $startday, 'compare' => '<=' ), array( 'key' => 'event_end_date', 'value' => $endday, 'compare' => '>=' ), ) ); remove_filter( 'get_meta_sql', 'get_meta_sql_date' ); $loop = new WP_Query( $qryevents );
I’ve tried multiple things here, but instead of just trying random things I figure i would ask you to see if you can see what the problem is?
The function I put in my functions file:
function get_meta_sql_date( $where ) { global $wpdb; $where = " AND ($wpdb->postmeta.meta_key = 'event_end_date' AND CAST($wpdb->postmeta.meta_value AS DATE) >= '$endday') OR ($wpdb->postmeta.meta_key = 'event_start_date' AND CAST($wpdb->postmeta.meta_value AS DATE) <= '$startday') "; return $where; }
I do use the Date Picker and the save format I use for the dates is yymmdd. Should I change that to something else?
Here is the resulting query.
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id) INNER JOIN wp_postmeta AS mt2 ON (wp_posts.ID = mt2.post_id) WHERE 1=1 AND wp_posts.post_type = 'events' AND ((wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') OR wp_posts.post_status = 'private') AND (wp_postmeta.meta_key = 'event_start_date' OR (mt1.meta_key = 'event_start_date' AND CAST(mt1.meta_value AS DATE) <= '20140401') OR (mt2.meta_key = 'event_end_date' AND CAST(mt2.meta_value AS DATE) >= '20140430') ) GROUP BY wp_posts.ID ORDER BY wp_postmeta.meta_value ASC LIMIT 0, 50
The results I get contain events that start and end in May and June. I am in the month of April in that widget i referred too before so I should only see events that start in April.
—
If an event starts in May and ends in June, I should not see it on the April page or in the July page, but i should see it on the May and June pages.
I pass the month and year to the widget and some ajax to tell it which month and year to start the filter by. The widget has arrows in it that you can click to cycle through the months and years.
Forum: Fixing WordPress
In reply to: Query custom post types by two custom date fieldsDo you think that solution will work for me if I have a start date field and end date field? I noticed that query was using $today variable so the query is just using one date to compare by. I’m actually trying to compare two dates and create a range between them.
Forum: Plugins
In reply to: Facebook PHP SDK and WordPress PluginUPDATE #2 – I’ve also tried taking the Facebook PHP SDK from the facebook plugin. This worked better, but still its a no go because i am getting a different error.
The error i get when i use the facebook php sdk from the facebook plugin is:
Fatal error: Access to undeclared static property: WP_BaseFacebook::$CURL_OPTS in {path}/wp-content/plugins/{pluginname}/facebook-php-sdk/src/base_facebook.php on line 932
How can i fix this error?
Forum: Plugins
In reply to: [Posts 2 Posts] Cross link several post typesI’m trying to figure this out too since i have multiple custom post types and i want to relate anything from posts and pages to those custom post types and vice versa.
If i figure it out, i will let you know. If you figure this out, i hope you post back here.
Forum: Plugins
In reply to: [JW Player for Flash & HTML5 Video] What is the shortcode?@LongTail Video – I was looking in the wordpress plugins section and found this plugin to use for displaying video. I didnt see anywhere in the documentation about what the shortcode might be.
Is there a page with full documentation on the shortcode?
Otherwise, looks to be a great plugin, it just needs clearer directions.
Forum: Fixing WordPress
In reply to: Updated from WordPress 3.4.2 to WordPress 3.5.1 – 500 server errori have re-uploaded the files from my backup and that has fixed the problem. At least the site is back up now.