【发布时间】:2016-10-21 00:01:35
【问题描述】:
希望实现类似于此页面的内容,用户可以在表单字段中输入想法,然后在提交时直接发布到页面上。
使用 wordpress cmets 最适合这个吗?或者以某种方式发送表单提交以填充页面上的转发器高级自定义字段。谁能建议如何最好地实现这一目标?
还想知道垃圾邮件。上面的网站没有验证码或类似的(据我所知)。这有什么关系?
谢谢!
【问题讨论】:
希望实现类似于此页面的内容,用户可以在表单字段中输入想法,然后在提交时直接发布到页面上。
使用 wordpress cmets 最适合这个吗?或者以某种方式发送表单提交以填充页面上的转发器高级自定义字段。谁能建议如何最好地实现这一目标?
还想知道垃圾邮件。上面的网站没有验证码或类似的(据我所知)。这有什么关系?
谢谢!
【问题讨论】:
如果您不想使用付费插件,您可以创建一个新的自定义帖子类型,然后在您想要的页面上显示结果。你应该关注这个tutorial here
简而言之:
创建一个新的帖子类型:
// Our custom post type function
function create_posttype() {
register_post_type( 'movies',
// CPT Options
array(
'labels' => array(
'name' => __( 'Movies' ),
'singular_name' => __( 'Movie' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'movies'),
)
);
}
// Hooking up our function to theme setup
add_action( 'init', 'create_posttype' );
在页面中显示结果:
<?php
$args = array( 'post_type' => 'movies', 'posts_per_page' => 10 );
$the_query = new WP_Query( $args );
?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<h2><?php the_title(); ?></h2>
<div class="entry-content">
<?php the_content(); ?>
</div>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
然后您可以使用这个免费插件添加Google reCaptcha 以避免垃圾邮件
【讨论】: