DatagoniaWeb
Forum Replies Created
-
Forum: Plugins
In reply to: [Displet Pop] Displet Pop Ignoring CookiesYeah I am having the same issue and I think the plugin has been abandoned. Quite a pity.
Forum: Plugins
In reply to: [WordPress Importer] Compatible with WP 3.9.2?I also need to know this. I have been having issues importing data in 3.9.2!
Forum: Plugins
In reply to: [Menu Item Visibility Control] Something in cart?I, too, would like to see an answer to this.
Forum: Hacks
In reply to: Modifying the Main Loop Query (wp_query->set)Bcworkz, just wanted to say thank you again. You’re right it was putting the events in order anyway so I used the meta query and compared my start dates. I also had the order of the meta_value and actual meta value backwards.
Crazy how you take a couple of weeks off and come back and things make sense. Thanks a ton for your help!
Forum: Hacks
In reply to: Modifying the Main Loop Query (wp_query->set)Hmmm it looks like I am having issues with the comparison clause.
Here is what I currently have:
//specifically alter the main query *before* it takes place add_action('pre_get_posts','alter_events_query'); function alter_events_query( $query ){ if( $query->is_main_query() && $query->is_post_type_archive( "event" ) ) { $event_meta_query = array( array( 'meta_key' => 'start_date', 'meta_value' => time(), 'meta_compare' => '>=' ), ); $query->set( 'meta_query', $event_meta_query ); $query->set( 'order', 'ASC' ); $query->set( 'posts_per_page', '20' ); $query->set( 'meta_key', 'start_date' ); $query->set( 'orderby', 'meta_value' ); } }
Currently it does not look like the dates are being limited to those in the future (eg “upcoming” events). Any idea what’s wrong with the query? Keep in mind that the ‘start_date’ is a postmeta column / field.
Forum: Hacks
In reply to: Modifying the Main Loop Query (wp_query->set)bcworkz,
Dude, I can’t thank you enough. I consider myself relatively advanced when it comes to PHP but not as much with WordPress’s API. I guess the point of having a meta key and meta value is to tell WordPress first that you want order by a meta value / key pair and then the meta_key part tells it specifically which meta values.
You are right that alphabetical order should work for both yyyymmdd and yyyy-mm-dd formats (as well as timestamps) but I thought it might be possible that the dashes mess the ordering up or something.
Anyway just wanted to say thank you for your help and patience!
Forum: Hacks
In reply to: Modifying the Main Loop Query (wp_query->set)Okay I am making some good progress now. I have figured out how to do a meta query thanks to the following link:
https://www.billerickson.net/customize-the-wordpress-query/However I am still running into the issue of date comparisons without using a Unix timestamp. It seems WordPress (or MySQL, more specifically) has problems comparing dates when in yyyy-mm-dd form. If I’m only using dates then I could probably use yyyymmdd form and get away with things or I could use Unix timestamp.
The one problem I am currently having with Unix timestamp is how to use a MySQL function as part of the array arguments for the meta query. The following code, for example, pulls up no results:
//specifically alter the main query *before* it takes place add_action('pre_get_posts','alter_events_query'); function alter_events_query( $query ){ if( $query->is_main_query() && $query->is_post_type_archive( "event" ) ) { $event_meta_query = array( array( 'key' => 'UNIX_TIMESTAMP("start_date")', //MySQL function doesn't seem to be working 'value' => time(), //will give unix timestamp of current time 'compare' => '>=' ) ); $query->set( 'meta_query', $event_meta_query ); $query->set( 'orderby', 'UNIX_TIMESTAMP(start_date)' ); //MySQL function doesn't seem to be working $query->set( 'order', 'ASC' ); $query->set( 'posts_per_page', '20' ); } }
Any help with the Unix timestamp issue would be awesome. Thank you.
Forum: Hacks
In reply to: Modifying the Main Loop Query (wp_query->set)So it seems that I have almost gotten it to work. Here is my current code:
//specifically alter the main query *before* it takes place add_action('pre_get_posts','alter_events_query'); function alter_events_query( $query ){ if( $query->is_main_query() && $query->is_post_type_archive( "event" ) ) { //$query->query_vars['meta_key'] = 'start_date'; //$query->query_vars['meta_value'] = date('o-m-d'); //$query->query_vars['meta_compare'] = '>='; $query->set('orderby', "start_date[0]"); } }
Unfortunately because the ‘start_date’ is in the postmeta table I think this is causing a problem. I have tried using “ID” instead of “start_date[0]” and that worked fine (ordering posts by post ID in descending order).
How would I go about putting them in order by their start_date field if that field is in the postmeta table rather than the wp_posts table? Would I have to do a custom query with a MySQL join?
Forum: Hacks
In reply to: Modifying the Main Loop Query (wp_query->set)Sorry about bumping. Navigating these forums can be tricky at times.
As luck would have it the custom field (start_date) that I am using to order the posts are in yyyy-mm-dd format so if they were to be ordered alphabetically they would be put in the order that I am, indeed, seeking.
I just need to know how to make the process use that specific parameter to put them in order. I have taken out the call within the archive-event.php file and here is the code that I have in functions.php currently:
add_action('pre_get_posts','alter_events_query'); function alter_events_query( $query ){ if( $query->is_main_query() && is_post_type_archive( "event" ) ) { $query->set('orderby', "start_date[0]"); } }
It does not seem to be ordering by start_date (which I have reformatted and echoed on the “Starts: __________” line. I am trying to look closer into what order it is putting them in by default (I have a feeling it will be original post date in ascending order but I could be wrong). Any help would be appreciated!
It just seems like a lot of the tutorials and codex don’t quite go into enough detail when it comes to this stuff.
Forum: Hacks
In reply to: Modifying the Main Loop Query (wp_query->set)Bump. Any help would be great! I know I’m not the only one wondering how to modify the main loop this way.
Forum: Plugins
In reply to: [Binary MLM] Problems Registering New UsersI emailed them last Friday and still have not gotten a response. I will email once more with the details you specified but time is of the essence here… we have deadlines and would appreciate a reasonably quick response.
Forum: Themes and Templates
In reply to: [K-BOOM] How does loop typically find correct post?Esmi, the question would be the same regardless of which theme I am using. How do loops typically figure out which post or posts to get? From the URL / URI? And do they always resort to the post ID or can they use the name (slug) in the URL?