This is How a code in single.php looks like →
But needed that in homepage so I decided to make code based on the post ID →
<?php $fpid = get_theme_mod('kirki_fpid'); ?>
(The above is fetching the Post ID)
and
<?php $imv = get_post_meta($fpid, 't_vid_base', true); ?>
Now comes it’s implementation→
The code in single.php →
1
if(certain condition true) {
$url = esc_url( get_post_meta( get_the_ID(), 't_oembed', 1 ) );
echo wp_oembed_get( $url );
}
and
2
if(certain condition true) {
the_post_thumbnail( 'large');
}
The #1 can be converted to be usable for home page(based on POST ID) like this →
if(certain condition true) {
$url = esc_url( get_post_meta( $fpid, 't_oembed', 1 ) );
echo wp_oembed_get( $url );
}
Question →
How to make the second one based on the POST ID($fpid
)? that means this(the_post_thumbnail( 'large');
) should render results based on POST ID
1 Answer
I got the solution so self-answering the question for future users/visitors.
Hope it will help someone.
I think this won’t be able to generate results based on the Post ID →
the_post_thumbnail( 'large');
However, this should work →
<?php echo get_the_post_thumbnail($fpid, 'large'); ?>
(Above is succesfully tested)
Other possibilities →
<?php echo get_the_post_thumbnail($fpid, 'thumbnail'); ?>
<?php echo get_the_post_thumbnail($fpid, 'medium'); ?>
<?php echo get_the_post_thumbnail($fpid, 'full'); ?>
If you want to use the hardcoded POST ID then this should work →
<?php echo get_the_post_thumbnail('311', 'large'); ?>
Other possibilities(Hard Coded POST ID) →
<?php echo get_the_post_thumbnail('311', 'thumbnail'); ?>
<?php echo get_the_post_thumbnail('311', 'medium'); ?>
<?php echo get_the_post_thumbnail('311', 'full'); ?>
P.S. → 311 is a post ID, for example.
$fpid → User selected POST ID(Post selected form the Theme customizer
settings)
I hope this should be helpful to someone in future.