how would i change post->ID to work correctly when querying pages?

Try with get_the_ID() $image_uploaded_meta_id = get_post_meta(get_the_ID(), ‘_listing_image_id’, true); get_the_ID() is a core WordPress function that acts directly inside the WordPress Loop, retrieving the id of the current item being loaded. $post->id is not working because the variable $post has no scope inside the loop. Here’s the link to the documentation: https://developer.wordpress.org/reference/functions/get_the_id/

Set a featured image as a replacement to the header image

You did not mention or shown in the code to which hook are you hooking the above code to, but here’s what I think should work. NOT TESTED global $post; $header_image=””; // featured image is first priority, right? if ( has_post_thumbnail( $post->ID ) ) { $header_image = get_the_post_thumbnail_url( $post->ID, ‘full’ ); } elseif ( !empty( … Read more

the_title() is not displaying over the_thumbnail

the_post_thumbnail() and get_the_post_thumbnail() will output the complete HTML for displaying that image. So this <img class=”img-responsive” src=”https://wordpress.stackexchange.com/questions/274181/<?php the_post_thumbnail(); ?>” alt=””> will be rendered to something like this <img class=”img-responsive” src=”https://wordpress.stackexchange.com/questions/274181/<img src=”…” alt=”..” class=”..”>” alt=””> which is not valid HTML and you can’t really tell how browsers will display this. Now you have 2 choices: Use … Read more

Featured image size in column

In functions.php : Make sure featured images are enabled add_theme_support( ‘post-thumbnails’ ); then add add_image_size( ‘thumbnail-news’, ‘100’, ’75’, true ); And in the code above change echo get_the_post_thumbnail($post_id, ‘thumbnail’); to echo get_the_post_thumbnail($post_id, ‘thumbnail-news’);

How to add gallery support in WordPress?

You can use gallery-metabox. Its open source and easy to use; https://github.com/zulfnore/gallery-metabox From Readme ; Include the gallery.php in your functions.php: require_once ‘gallery-metabox/gallery.php’; Specify where you want the gallery metabox to show on line 17 in gallery.php. You can pass an array to have it show up on multiple post types, custom post types are … Read more

How can i hide post without thumbnails/featured images from index pages?

You can manipulate the main WP_Query just before it asks the database for posts. Looking for an existing _thumbnail_id meta field should suffice, so using the pre_get_posts filter, something like this might work for you: add_action(“pre_get_posts”, function($query) { if(!is_front_page() || !$query->is_main_query()) { return; } if(!array_key_exists(“meta_query”, $query->query_vars)) { $query->query_vars[“meta_query”] = array(); } array_push($query->query_vars[“meta_query”], array( ‘key’ => … Read more