Get featured image outside the loop using foreach

First you will need to get a list of all available sizes on your site. This function get_intermediate_image_sizes() will do that. You can then pass the results of that to image_get_intermediate_size() along with the post id and <?php $sizes = get_intermediate_image_sizes(); ?> <?php foreach($major_data as $postID) { ;?> <?php $postData = get_post( $postID );?> <?php … Read more

All custom posts are not showing up

What you need to do is , first create a the CPT. Once the CPT with scholarship is created then create your custom taxonomy i.e scholarship which will be hierarchal. So when you will add your custom taxonomy as scholarship, then in the 2nd argument please provide the slug of your CPT ie. “scholarship”. register_taxonomy( … Read more

Metabox value for post loop?

Thanks guys.I did it with WP_Meta_Query (https://codex.wordpress.org/Class_Reference/WP_Meta_Query) Solution: <?php $query = new WP_Query( array( ‘meta_key’ => ‘j4cob_yaz_ayarlar_show_on_slider_’, ‘meta_value’ => ‘show-on-slider’, ‘posts_per_page’ => 6 ) ); ?> <?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?> . Loop . <?php endwhile; wp_reset_postdata(); else : ?> <p><?php _e( ‘Sorry, no posts matched your … Read more

Loop shows post 5 times in a query

the_title() is a template tag which relies on global state. Specifically $post global variable, holding current post instance. While you query a set of posts, you never set up that global state for template tag to use. Though in case you started with get_posts() it might be more convenient to leave global state alone altogether … Read more

How to return custom posts in loop?

The following code Worked with the code above: <?php $loop = new WP_Query( array( ‘post_type’ => ‘yourposttypehere’, ‘posts_per_page’ => -1 ) ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> The stuff you want to loop goes in here <?php endwhile; wp_reset_query(); ?> Source: link

WordPress Pages in an Array

Your changes $r[$page->post_name]; to $r[] = $page->post_name; are working fine when I checked them Instead of return $r; use print_r($r) You should see the list of all your pages. Also could you describe why you are using return $r

Looping through custom taxonomy in one template

As Template hierarchy says, there are 5 possible file names for displaying taxonomy: taxonomy-{taxonomy}-{term}.php – If the taxonomy is sometax, and taxonomy’s term is someterm, WordPress will look for taxonomy-sometax-someterm.php. In the case of post formats, the taxonomy is ‘post_format’ and the terms are ‘post-format-{format}. i.e. taxonomy-post_format-post-format-link.php for the link post format. taxonomy-{taxonomy}.php – If … Read more