PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Display Form on Category Link

  1. I would like to display a "Post to this Category" form on the main category pages. I would also like the category field dynamically populated with the current category being viewed.

    Please let me know if more information is required.

    Regards Jeroen.

    Posted 12 years ago on Monday January 2, 2012 | Permalink
  2. To add it to the category archive, you will have to add the form to the template file using the function call. You can read more about that here.

    When you do that, you can use WordPress functions to get the category and populate the category field dynamically. Do you use specific templates for each category, or one archive.php or other file for all your categories?

    Posted 12 years ago on Tuesday January 3, 2012 | Permalink
  3. Thanks Chris,

    Your link was broken.

    I just have 1 category template on my "Swift Theme"

    Posted 12 years ago on Tuesday January 3, 2012 | Permalink
  4. I fixed the link. Sorry about that. Can you take a look at that and let me know if you have any questions? Thanks

    Posted 12 years ago on Wednesday January 4, 2012 | Permalink
  5. Thanks Chris, I found the link and have used the function call to retrieve the form and insert it into category page.

    I have found many pieces of code that should actually do what i want but they don't seem to work. We will continue, however if you can provide some assistance it would be much appreciated.

    Posted 12 years ago on Thursday January 5, 2012 | Permalink
  6. Please share some of the code you're using, template files, your theme's functions.php, etc. Use pastie.org or pastebin.com if the code examples are lengthy. We won't be able to help you without seeing the code you're using. Thank you.

    Posted 12 years ago on Friday January 6, 2012 | Permalink
  7. Hi Chris, I am still somewhat of a novice I feel and I do appreciate your help. I have added the index.php (which loads all my categories) to a pastie here http://pastie.org/3143768 Line 90 is where I call the form. You can view the form on any of my category pages. here is 1 example http://freeineurope.com/category/free-tourist-attractions-in-netherlands-holland/

    The Post Category field currently displays a drop down box with the option to select any of the categories in my blog. However in the case of the Holland Category linked above I want this field to be pre-populated with the "Holland" Category.

    I found the below code on this forum ( http://www.gravityhelp.com/forums/topic/dynamically-populate-field-using-variable ) without success

    add_filter("gform_field_value_categoryid", "populate_categoryid");
    function populate_categoryid($value){
    return get_query_var('cat');
    }

    Please advise if you need more information.

    Posted 12 years ago on Saturday January 7, 2012 | Permalink
  8. Thanks for your help Chris, but I have figured it out. I was close, the above code works perfectly I just wasn't calling the correct parameter name. All I had to do was change "gform_field_value_categoryid" to "gform_field_value_category" as that was the name I had given the parameter. :)

    Posted 12 years ago on Monday January 9, 2012 | Permalink