Query for Custom Post Type UI Does Not Loop All the Post

Just found the answer.. Add posts_per_page in the arguments as -1. It should look like this: $args = array( ‘post_type’ => ‘lirik_melayu’, ‘posts_per_page’=> -1, // set the limit post to UNLIMITED (-1 is unlimited) ‘orderby’ => array( ‘ID’ => ‘DESC’ , ), ); $query = new WP_Query( $args ); $query_contents=Array(); while ( $query->have_posts() ) { … Read more

Customizing the_tags output?

Try this: $args = array( ‘taxonomy’ => ‘post_tag’, ‘hide_empty’ => 0 ); $tags = get_terms( $args ); $class_name=”my-custom-class-name”; if ( ! empty( $tags ) && ! is_wp_error( $tags ) ) { shuffle( $tags ); foreach( array_slice( $tags, 0, 6 ) as $tag ) { printf( ‘<a class=”%1$s” href=”https://wordpress.stackexchange.com/questions/223735/%2$s”>%3$s</a>’, sanitize_html_class( $class_name ), get_tag_link( $tag->term_id ), sprintf( … Read more

WordPress PHP syntax doesn’t seem to be working correctly

get_the_post_thumbnail() returns the full html output of the image, including the image <img /> tags. You want just the image src. Try this: <div class=”leftBox”> <?php $query = new WP_Query( ‘pagename=jour’ ); // The Loop if ( $query && $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); if ( has_post_thumbnail() ) { $img_src = … Read more

Want to use wp_get_current_user() in query filter

since the query filter is “applied to all queries (at least all queries run after plugins are loaded)” as stated here in the wordpress codex you should do a further test to make sure that you are in the query you want to be. Perhaps a certain query or queries is/are run before the one(s) … Read more