New answers tagged

0

You can save post IDs with their menu order as well so later you can simply sort them using PHP sorting methods. But now you've to query menu order of each post then have to write two loops. One for sorting another for displaying. The another approach is using get_posts() and pass the post IDs which you have as an array. Then you can simply order the posts ...


0

Here's the relevant part of your code that should work: // This will make a URL like http://yoursite.com/path/to/fallback.png $fallback_image = site_url( '/path/to/fallback.png' ); $fallback_image = "<img src='{$fallback_image}' />"; foreach( $recent_posts as $recent ){ echo '<div class="sidebar-entries">'; $featured_image = ...


1

Fields in database tables can not contain other types of data than text strings and numbers, and variations of them like dates and times. The field meta_value of wp_postmeta is a text field. So, when you store an array as meta_value you are really storing a string containing the serialized data that represents the original array. If you need to interpret ...


-1

global $wpdb; $excludeposts = "SELECT * FROM $wpdb->posts WHERE $wpdb->posts.post_status = 'publish' AND meta_key NOT LIKE %aa_% ORDER BY post_date DESC "; $main_query = new WP_Query( array( 'post__not_in' => $excludeposts, 'paged' => $paged ) ); while ($main_query->have_posts()) : $main_query->the_post(); //Stuff... endwhile; ...


0

You can check get_post_meta before args, Example: // Get post meta $game = get_post_meta($post->ID, 'sd_game', true); $game_series = get_post_meta($post->ID, 'sd_game_series', true); // Check which meta if( !empty( $game ) ) { $key = 'sd_game'; } else { $key = 'sd_game_series'; } $posts = get_posts(array( 'numberposts' => -1, ...


4

You forgot option 3 - Add a special table in which the pair (user,post id) will be the index. Ok I am not a MySQL person so maybe it is too extreme, but maybe having two tables one with users as index and one with posts will be even better. The thing about performance is that there are rarely absolute solutions for everybody at anytime, and the "best" ...


0

Option 1 is not the best choice because serializing data means you must parse your SQL result to be readable and thus you can't take any advantages of SQL queries. Option 2 would be the easiest way but if you have a lot of users that are liking a lot of posts then it starts to pollute user meta table. Option 3 what i would do, is create relational table ...



Top 50 recent answers are included