Order Posts By Youtube Views

https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters <ul> <?php $item=0; $attr = array( ‘post_type’ => ‘lyrics’, ‘date_query’ => array( array( ‘after’ => ‘1 month ago’ ) ), ‘post_status’=> ‘publish’, ‘meta_key’ => ‘youtube_views’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 10 ); $loop = new WP_Query( $attr ); while ( $loop->have_posts() ) : $loop->the_post(); $song_name = get_the_title(); /*YOUTUBE QUERY HERE*/ // … Read more

Bring a post to the top of the query if it’s in a certain category?

You will have to use 2 queries, where in the first loop you should use: $args = array( “post_type” => “post”, “post_status” => “publish”, “orderby” => “date”, “order” => “DESC”, “posts_per_page” => 20, ‘post__in’ => cat, ); (The Query) And in the second: $args = array( “post_type” => “post”, “post_status” => “publish”, “orderby” => “date”, … Read more

How to take parameters from a function and make them editable as attributes in a shortcode

Essentially you are asking how to pass parameters to a shortcode. This can be done with the function shortcode_atts, which has two required parameters: an array of valid parameters and their defaults, and the attributes of the shortcode that is being passed. You would use it like this: add_shortcode( ‘wpse232385_show_news’, ‘wpse232385_news_query’ ); function wpse232385_news_query ($atts) … Read more