using the loop in custom meta is messing up ‘add new’ post type
After you create a custom loop, you need to restore the global post variables with wp_reset_query().
After you create a custom loop, you need to restore the global post variables with wp_reset_query().
I finally figured this out. It’s simple, too. As I posted it, that loop would never finish because there’s nothing advancing the counter inside the while loop. But if I uncomment my fairly normal-looking code and run it, it still wouldn’t close, because I’m not advancing the specific Query object’s counter. When you run the_post(), … Read more
See WP_Query in Codex for info on how to query on custom fields. $args = array( ‘posts_per_page’ => -1, ‘cat’ => 4, ‘meta_key’ => ‘point_score’, ‘orderby’ => ‘meta_value_num’ ); $points_query = new WP_Query( $args ); while( $points_query->have_posts() ): $points_query->the_post(); the_title(); echo ‘ : ‘; echo get_post_meta( $post->ID, ‘point_score’, true ); endwhile;
Try this code, but replace METAKEY to the key-name of your metadata. <?php function cmp( $a, $b ) { if( $a->METAKEY == $b->METAKEY ){ return 0 ; } return ($a->METAKEY < $b->METAKEY ) ? -1 : 1; } ?> <ul> <?php $args = array( ‘role’ => ‘author’ , ‘meta_key’ => ‘METAKEY’, ‘number’ => 5, ); … Read more
$query = new WP_Query( ‘post_type=page’ ); as seen at codex http://codex.wordpress.org/Class_Reference/WP_Query#Type_.26_Status_Parameters
I have managed to find the problem. Basically calling the google API from the footer was causing the maps to break and not function properly.
The problem is in the logic. A post may have several terms, not all of which will be child terms. For instance, consider the parent > child term relationships: a > b > c d > e f And let’s suppose that our post has the terms c,e and f attached to them. Now the … Read more
Your first issue is the fact that you’re using query_posts. That function isn’t meant for creating new queries to the database; instead, it’s used to modify the existing global query. Read up here and here for more information on what you can use instead. Second, there is just some strange code in your template that, … Read more
Add to your child themes functions file: function wpsites_add_cpt_home($query) { if ( !is_admin() && $query->is_main_query() && is_home() ) { $query->set(‘post_type’, array( ‘post’, ‘accommodation’ ) ); } } add_action(‘pre_get_posts’,’wpsites_add_cpt_home’); You could also add category__in => array() Source pre_get_posts
You can easily add whatever variables you want to your AJAX call. Using jQuery you can set a AJAX action like this: jQuery.post( ‘your-url-to-admin-ajax.php’, { action: ‘your_called_function’, argument: ‘year’ or ‘category’, some_other_var: ‘some value’ }, function( response ) { if(response) { } else { } } ); Then in your functions.php add this: add_action( ‘wp_ajax_nopriv_your_called_function’, … Read more