Tag Info

New answers tagged

0

Not tested but you can try this: $args = array( 'posts_per_page' => 4, 'post_type' => 'post', 'meta_key' => 'meta-select', 'order' => 'ASC', 'orderby' => 'meta_value_num', 'meta_query' => array( array( 'key' => 'meta-select', 'value' => ...


0

$wpdb->query() returns number of rows affected by the query. It's returning NULL indicates that there is an error in your query. The problem with your query is that you are updating $wpdb->posts table, but the condition depends on $wpdb->postmeta table. You have to join these tables for the query to work. Another problem is that you have to place ...


1

I just ran into this with WooCommerce. I ended up passing the IDs I needed to a variable for safe keeping, and then hooking a function with extremely low priority. That worked fine. I figure woocommerce or what of my cleint's 8000000 plugins was overwriting post__in. add_filter('pre_get_posts', 'assign_ids', 1000);


0

your are comparing time against wrong time string: change: 'meta-value' => date('Y-m-d', strtotime('-6 hours')), //value of "order-date" to this 'value' => date('m-d-Y', strtotime('-6 hours')), //value of "order-date" because your time string is in m-d-Y format and you are check against Y-m-d which is wrong. NOTE if above trick doesn't work ...


0

You have to use JOIN for that. Try it like this: $wpdb->get_results("SELECT tags.*, $wpdb->posts.*, $wpdb->postmeta.* FROM tags INNER JOIN $wpdb->posts ON tags.charity_id = $wpdb->posts.ID INNER JOIN $wpdb->postmeta ON tags.charity_id = $wpdb->postmeta.post_id WHERE tags.charity_id ...


0

You don't need to invoke $wpdb->prepare() since your original SQL query doesn't contain any input from the user. Your 2nd query -- SELECT * FROM wp_blogs ORDER BY blog_id = %d -- has a syntax error (the ORDER BY clause won't accept the = %d), and so won't work. (At least I'm pretty sure that's the case. I can't find anything in the MySQL docs to indicate ...


1

These look like 2 separate questions. The first I think is a single vs double quotes issue: Try this: $html = ''; foreach ( $recent_across_network as $post ) { $html .= 'blog_id, '.$post->ID.' ) . '">' . $post->post_title . ''; } $html .= ''; The line in the foreach is putting $post->ID in single quotes which won't evaluate it's value but ...


2

WordPress by default will only load 10 posts. That can be changed in the admin under Settings->Reading and then setting the amount beside "Blog pages show at most". You can override that number in your custom queries a couple of ways but I would first recommend against the use of query_posts() ( take a read at the link for the reasons why) in favour of ...


0

Try this: query_posts( 'posts_per_page=-1' ); Just a head up, you shouldn't be using this function here, do whatever you want, but is recommender to use WP_Query or get_posts


0

I believe what you want are the previous_post_link() and next_post_link() functions.


0

// This worked great for me so much thanks! I just adapted for what I needed. Right in template file, Sweet! global $wpdb; // QUERY HERE TO COUNT TOTAL RECORDS FOR PAGINATION $total = $wpdb->get_var("SELECT COUNT(*) $post_per_page = 10; $page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1; $offset = ( $page * $post_per_page ) - ...


1

<?php if (have_posts()) : while (have_posts()) : the_post(); endwhile; else: _e('No blog found.', 'polymer'); endif; ?> if(have_post) condition is to check if the page contain post, while(have_posts) condition if there is more than one post display in loop, the_post() is used to display the post if(have_post) ...


0

The only way to do it is using a query filter I think function wpse156319_posts_where( $where, $query ) { global $wpdb; $where .= $wpdb->prepare( ' AND (' . $wpdb->posts . '.post_parent = %s OR ' . $wpdb->posts . '.post_author = %s)', $_POST['id'], get_current_user_id() ); return $where; } which you just add in the ...


2

You could also use the posts_orderby filter: function wpse155827_posts_orderby_price( $orderby ) { return str_replace( 'wp_postmeta.meta_value', 'substr(wp_postmeta.meta_value, 1)', $orderby ); } add_filter( 'posts_orderby', 'wpse155827_posts_orderby_price' ); $theQuery = new WP_Query( array( 'orderby' => 'meta_value_num', 'meta_key' => ...


0

You'll have to use the post_clauses filter to create some custom SQL: add_filter( 'posts_clauses', 'wpse155827_price_sort', 10, 2 ); function wpse155827_price_sort( $clauses, $wp_query ) { $orderby = $wp_query->get( 'orderby' ); $order = ( $wp_query->get( 'order' ) == 'desc') ? 'DESC' : 'ASC'; if( 'price' === $orderby ) { ...


0

You should not modify the wordpress DB via SQL unless it is a total emergency. Wordpress DB structure getting more complex with time and there are always possible intractions with plugins that you might bypass with direct SQL. What you should do is to write a small plugin that inserts the tags by calling using the relevant APIs.



Top 50 recent answers are included