Assuming that I learn how to do this, how do I pull information about the user's selected page and display them?
Obviously, I start with
$mytheme_f_page[1] = get_theme_mod( 'mytheme_featured_page_1', '' );
What do I do to pull the information about this page? As there will be three, can I get all three at once or do I need to do it one at a time?
I'm going to need the thumbnail, the title, and the excerpt.
Assuming that I learn how to do this, how do I pull information about the user's selected page and display them?
Obviously, I start with
$mytheme_f_page[1] = get_theme_mod( 'mytheme_featured_page_1', '' );
What do I do to pull the information about this page? As there will be three, can I get all three at once or do I need to do it one at a time?
I'm going to need the thumbnail, the title, and the excerpt.
Share Improve this question asked Jul 1, 2019 at 1:36 Matthew Brown aka Lord MattMatthew Brown aka Lord Matt 1,0683 gold badges13 silver badges34 bronze badges 1 |1 Answer
Reset to default 2When you save a selected page in the Customiser you're just saving the post ID of the page, which means you can just pass that value to any function that accepts a post ID as a parameter:
$mytheme_f_page[1] = get_theme_mod( 'mytheme_featured_page_1' );
echo get_the_title( $mytheme_f_page[1] );
echo get_the_excerpt( $mytheme_f_page[1] );
echo get_the_post_thumbnail( $mytheme_f_page[1] );
The first time you use any one of these the full post (page) is cached internally, so you don't need to worry about getting them one at a time or all at once, or anything like that.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745356123a4624127.html
get_the_title()
andget_the_excerpt()
. You could also store an array of page IDs and loop over the array to get the post data. – Sally CJ Commented Jul 1, 2019 at 2:10