Get 2 meta values from meta key column

Not tested 100% but this might work: SELECT a.post_title, m1.meta_value AS SKU, m2.meta_value AS PRICE FROM wp_posts a LEFT JOIN wp_postmeta m1 ON a.ID = m1.post_id LEFT JOIN wp_postmeta m2 ON a.ID = m2.post_id WHERE a.post_type=”product” AND m1.meta_key=’_sku’ AND m2.meta_key=’_price’ Note that _price field corresponds to the “sale price” (if existing) so you may grab … Read more

Prevent versioning for .woff (font) files

If you load your fonts using standard stylesheet enqueueing then you can add this to your functions.php file: function remove_querystrings( $src ) { $parts = explode( ‘.woff?ver’, $src ); return $parts[0]; } add_filter( ‘style_loader_src’, ‘remove_querystrings’, 15, 1 ); I haven’t tested this but I’m fairly certain it will only work if you’re adding the fonts … Read more

Question about of query

The Answer is: Nothing. These two snippets SHOULD return the same posts. However, there are a lot of things, that can change a query before it is executed: plugins, your own theme by a pre_get_posts Filter. So to check if it is an error in this code or some other code, you can disable all … Read more

SEO friendly query vars

At the end I made this work by using Javascript: var currentURL = window.location.href; var prettyURL = currentURL.replace(‘?’, ”).replace(‘state=”, “‘).replace(‘&type=”, “https://wordpress.stackexchange.com/”); window.history.replaceState({}, document.title, “https://wordpress.stackexchange.com/” + prettyURL);

Displaying data from custom table

OK, so maybe the above wasn’t worded very well? I have since made some progress as follows: global $wpdb; $current_user = wp_get_current_user(); $uid = $current_user->ID; $fname = $current_user->first_name . ” ” . $current_user->last_name; $email = $current_user->user_email; $studentTable = $wpdb->prefix.’um_metadata’; $result = $wpdb->get_results ( “SELECT * FROM $studentTable WHERE `user_id` = $uid AND ‘um_key’ = ‘student_number’ … Read more