Setting up a WP site that has a similar structure to craigslist.. There are many regions and each region is a category. I've put a form for submitting a listing in my category.php file. I need the form to post to the category that is being viewed. How would I achieve this?
What I have tried so far... :
Viewing and using the source code. I found that there was a piece of code that looked liked this:
action='/?cat=3#gf_1'>
.. And I thought, oh that's where it tells it to post to the specific category... So I change it to:
action='/?cat=<?php the_category_ID(); ?>#gf_1'>
Which seemed to work but it would still post to category 3. I think that line just showed what category page you were in by default.
I've searched through the documentation and forum, and of course have considered adding a hidden category field that is pre-populated, but not sure if that would work. As I understand it, you have to place the following in your functions.php file.. :
add_filter('gform_field_value_your_parameter', 'my_custom_population_function')
function my_custom_population_function($value){
return 'boom!';
}
The return value would have to be something like the_category_id but I'm not sure how to merge those two things together. And even if I could, I'm not sure that it would work. And also it appears that you *have* to set a category for the form to post to in the post title. So how would I stop it from posting to more than one category and only posting to the category which the user is currently viewing?
Thanks in advance.