wordpress - 获取分配给模板的帖子
问题描述:
I want to get the post that is assigned to this template and display the content,
currently, I can only display the post content if I put the post id manually. I only want to display the content if the post is assigned to this template and display the content inside woocommerce page
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php /** * Template Name: Sign up Page * * @package WordPress * @subpackage Twenty_Fourteen * @since Twenty Fourteen 1.0 */ echo \'this is the signup page\'; $post = get_post(2); $output = apply_filters( \'the_content\', $post->post_content ); echo $output; |
图片转代码服务由CSDN问答提供
感谢您的意见,我们尽快改进~
功能建议
我想获取分配给此模板的帖子并显示内容,目前,我只能显示 如果我手动输入帖子ID,则发布内容。 我只想显示内容,如果帖子被分配到此模板并在woocommerce页面内显示内容</ p>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
&lt;?php / ** *模板名称 :注册页面 * * @package WordPress * @subpackage Twenty_Fourteen * @since Twenty Fourteen 1.0 * / echo\'这是注册页面\'; $ post = get_post(2); $ output = apply_filters(\'the_content\',$ post-&gt; post_content); echo $ output; </ code> </ pre> </ div> <h5>网友观点:</h5> <div> <p><strong>Updated:</strong></p> <p>You could try to use <a>get_page_template_slug()</a> function to check, if the current page uses specific template, something like:</p> <pre><code> while ( have_posts() ) : the_post(); $current_template = get_page_template_slug( get_the_ID() ); if ($current_template == \'signup.php\' ) { the_content(); } endwhile; |
由于网站搬家,部分链接失效,如无法下载,请联系站长!谢谢支持!
1. 带 [亲测] 说明源码已经被站长亲测过!
2. 下载后的源码请在24小时内删除,仅供学习用途!
3. 分享目的仅供大家学习和交流,请不要用于商业用途!
4. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
5. 本站所有资源来源于站长上传和网络,如有侵权请邮件联系站长!
6. 没带 [亲测] 代表站长时间紧促,站长会保持每天更新 [亲测] 源码 !
7. 盗版ripro用户购买ripro美化无担保,若设置不成功/不生效我们不支持退款!
8. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
9. 如果你也有好源码或者教程,可以到审核区发布,分享有金币奖励和额外收入!
10.如果您购买了某个产品,而我们还没来得及更新,请联系站长或留言催更,谢谢理解 !
GG资源网 » wordpress - 获取分配给模板的帖子
1. 带 [亲测] 说明源码已经被站长亲测过!
2. 下载后的源码请在24小时内删除,仅供学习用途!
3. 分享目的仅供大家学习和交流,请不要用于商业用途!
4. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
5. 本站所有资源来源于站长上传和网络,如有侵权请邮件联系站长!
6. 没带 [亲测] 代表站长时间紧促,站长会保持每天更新 [亲测] 源码 !
7. 盗版ripro用户购买ripro美化无担保,若设置不成功/不生效我们不支持退款!
8. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
9. 如果你也有好源码或者教程,可以到审核区发布,分享有金币奖励和额外收入!
10.如果您购买了某个产品,而我们还没来得及更新,请联系站长或留言催更,谢谢理解 !
GG资源网 » wordpress - 获取分配给模板的帖子