admin管理员组文章数量:1421951
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.
本文标签:
版权声明:本文标题:theme development - How do I get information about a page, such as featured image, except, and title? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745356122a2655062.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