下面的行为应该是用户在下拉框中进行选择,页面将刷新为的查询参数editevent=1
并在选定内容的情况下传递帖子ID的值。在下拉列表上方,应该是
职位ID:[此处职位ID]
这段代码有问题:
<option value="<?php the_ID(); ?>"><?php the_title(); ?>
</option>
当我将帖子的ID作为值时,它会使表单重定向到实际的帖子,而不仅仅刷新当前页面。我不明白为什么会这样。我把表格设置为action="#"
代码中没有任何URL的永久链接引用。以下是完整片段:
<?php if ($_GET[\'editevent\'] == true) {
echo \'Post ID: \'.$_GET[\'page_id\'];
}
?>
<form method="GET" action="#">
<select name="page_id" id="page_id" onchange="this.form.submit()">
<?php
global $post;
$args = array( \'numberposts\' => -1, \'post_type\' => \'event\', \'season\' => \'2013-2014\');
$posts = get_posts($args);
foreach( $posts as $post ) : setup_postdata($post); ?>
<option value="<?php the_ID(); ?>"><?php the_title(); ?>
</option>
<?php endforeach; ?>
</select>
<input type="hidden" name="editevent" value="true" />
</form>