Hot answers tagged

2

In each of your hooks & filters handlers, in addition to checking for archive conditions, check for a custom query var that you can then set for a custom/manual query. For example, where you might have: function wpse_223991_pre_get_posts( $wp_query ) { if ( $wp_query->is_main_query() && $wp_query->is_post_type_archive( 'my_post_type' ) ...


2

You are correct, you will need to get the image URL and set is as a variable so you can echo it out as an inline style in your HTML. I've updated your foreach loop below and set the image as an inline style of your <li> element: foreach( $postQuery as $post ) : setup_postdata($post); if ( has_post_thumbnail() ) { ?> /* Get the post ...


1

There's a couple things that you need to do to get the URL - you could combine them into one long sentence probably but I'll break it down. WordPress stores the thumbnail ID in the postmeta table as _thumbnail_id so we need to get that using get_post_meta(): $thumb_id = get_post_meta( $post->ID, '_thumbnail_id', true ); Now that we have the ID we need ...


1

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="%2$s">%3$s</a>', ...


1

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() ) : ...



Only top voted, non community-wiki answers of a minimum length are eligible