I recently made this wordpress blog, where you can sign up a team for an event, when clicking a link under the event post. This link takes you to a sign-up form on another php-page. The link is added in the lo开发者_StackOverflow社区op of the events-template like this:
<?php query_posts('cat=8');?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<div id="tilmeldknap"><?php wp_list_pages("title_li=&depth=1&include=63"); ?></div>
<?php include (TEMPLATEPATH . '/inc/meta.php' ); ?>...
So every upcoming event will have the same sign-up button. All I need now is to somehow send the specific event-post-title along to the sign-page, so that the following form-submit action will contain that title aswell. But since I'm not very good at php it seems like a mystery, altho I bet it's very simple!
I'm guessing it's something like:
$event=$_POST['single_post_title()']
But how to get the value to the next php-page I have no idea... please help, anyone :)
An eksample can be seen throught this link: http://gadebold.dk/events/ The link sais: 'Tilmeld Hold'
If you are using a form, which I am assuming that you are, you can use hidden fields..
<!-- assuming you are using page slugs -->
<form method='post' action='<?php echo site_url('\sign-up\')?>'>
<input type='hidden' name='post_title' value='<?php echo single_post_title() ?>'>
....<!-- rest of form -->
</form>
And at the receiving page,
<?php
$post_title = $_POST['post_title'];
?>
If you are not using a button, you can embed the page title in the URL and send using $_GET
<a href='<?php echo site_url('\sign_up\').'?title='.single_post_title()?>'>Register</a>
....
$post_title = $_GET['post_title'];
As a side-note, the Pods CMS is a great plugin for doing systems like this, and may help to reduce development time.
精彩评论