<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: Wrong category in list</title>
		<link>https://legacy.forums.gravityhelp.com/topic/wrong-category-in-list</link>
		<description>Gravity Support Forums Topic: Wrong category in list</description>
		<language>en-US</language>
		<pubDate>Sat, 04 Apr 2026 03:02:15 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/wrong-category-in-list" rel="self" type="application/rss+xml" />

		<item>
			<title>Moose on "Wrong category in list"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/wrong-category-in-list#post-24051</link>
			<pubDate>Mon, 25 Apr 2011 05:20:25 +0000</pubDate>
			<dc:creator>Moose</dc:creator>
			<guid isPermaLink="false">24051@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thanks!, I used the documentation in the wordpress codex. This was the sulution:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;quot;gform_pre_render_1&#38;quot;, populate_dropdown);
function populate_dropdown($form){

$args = array(
    &#38;#39;numberposts&#38;#39;     =&#38;gt; 5,
    &#38;#39;offset&#38;#39;          =&#38;gt; 0,
    &#38;#39;category&#38;#39;        =&#38;gt; 1,
    &#38;#39;orderby&#38;#39;         =&#38;gt; &#38;#39;post_date&#38;#39;,
    &#38;#39;order&#38;#39;           =&#38;gt; &#38;#39;DESC&#38;#39;,
    &#38;#39;post_type&#38;#39;       =&#38;gt; &#38;#39;post&#38;#39;,
    &#38;#39;post_status&#38;#39;     =&#38;gt; &#38;#39;publish&#38;#39; );

    //Reading posts for &#38;quot;Business&#38;quot; category;
$posts = get_posts( $args );

    //Creating drop down item array.
    $items = array();

    //Adding initial blank value.
    $items[] = array(&#38;quot;text&#38;quot; =&#38;gt; &#38;quot;&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;&#38;quot;);

    //Adding post titles to the items array
    foreach($posts as $post)
        $items[] = array(&#38;quot;value&#38;quot; =&#38;gt; $post-&#38;gt;post_title, &#38;quot;text&#38;quot; =&#38;gt; $post-&#38;gt;post_title);

    //Adding items to field id 8. Replace 8 with your actual field id. You can get the field id by looking at the input name in the markup.
    foreach($form[&#38;quot;fields&#38;quot;] as &#38;amp;$field)
        if($field[&#38;quot;id&#38;quot;] == 35){
            $field[&#38;quot;type&#38;quot;] = &#38;quot;select&#38;quot;;
            $field[&#38;quot;choices&#38;quot;] = $items;
        }

    return $form;
}

?&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;As you can see now its easy to order, and to set the max amount of items..
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Hiranthi on "Wrong category in list"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/wrong-category-in-list#post-24049</link>
			<pubDate>Mon, 25 Apr 2011 03:47:42 +0000</pubDate>
			<dc:creator>Hiranthi</dc:creator>
			<guid isPermaLink="false">24049@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;What happens when you use the category ID instead of the slug? If you look at the &#60;a href=&#34;http://codex.wordpress.org/Function_Reference/get_posts&#34; rel=&#34;nofollow&#34;&#62;get_posts&#60;/a&#62; page in the WordPress Codex you'll notice that they're only using an ID in the examples.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Moose on "Wrong category in list"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/wrong-category-in-list#post-24047</link>
			<pubDate>Mon, 25 Apr 2011 02:45:34 +0000</pubDate>
			<dc:creator>Moose</dc:creator>
			<guid isPermaLink="false">24047@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hello,&#60;/p&#62;
&#60;p&#62;Just purchashed the gravity form (very awesome btw) But I nog added a list to my form filled with post. like explained on &#60;a href=&#34;http://www.gravityhelp.com/forums/topic/automatically-populate-a-dropdown-with-post-titles&#34; rel=&#34;nofollow&#34;&#62;http://www.gravityhelp.com/forums/topic/automatically-populate-a-dropdown-with-post-titles&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;It seems to word fine however the post which are shown are from the wrong category! When you to to &#60;a href=&#34;http://www.geneeskundebaan.nl/demo/solliciteer/&#34; rel=&#34;nofollow&#34;&#62;http://www.geneeskundebaan.nl/demo/solliciteer/&#60;/a&#62; the first field is supposed to load the post from category &#34;vacatures&#34; but is showing post from the category &#34;portfolio&#34; instead.&#60;/p&#62;
&#60;p&#62;I use this code in mij functions.php:&#60;/p&#62;
&#60;p&#62;'//Adds a filter to form id 14. Replace 14 with your actual form id&#60;br /&#62;
add_filter(&#34;gform_pre_render_1&#34;, populate_dropdown);&#60;br /&#62;
function populate_dropdown($form){&#60;/p&#62;
&#60;p&#62;    //Reading posts for &#34;Business&#34; category;&#60;br /&#62;
    $posts = get_posts(&#34;category=vacatures&#34;);&#60;/p&#62;
&#60;p&#62;    //Creating drop down item array.&#60;br /&#62;
    $items = array();&#60;/p&#62;
&#60;p&#62;    //Adding initial blank value.&#60;br /&#62;
    $items[] = array(&#34;text&#34; =&#38;gt; &#34;&#34;, &#34;value&#34; =&#38;gt; &#34;&#34;);&#60;/p&#62;
&#60;p&#62;    //Adding post titles to the items array&#60;br /&#62;
    foreach($posts as $post)&#60;br /&#62;
        $items[] = array(&#34;value&#34; =&#38;gt; $post-&#38;gt;post_title, &#34;text&#34; =&#38;gt; $post-&#38;gt;post_title);&#60;/p&#62;
&#60;p&#62;    //Adding items to field id 8. Replace 8 with your actual field id. You can get the field id by looking at the input name in the markup.&#60;br /&#62;
    foreach($form[&#34;fields&#34;] as &#38;amp;$field)&#60;br /&#62;
        if($field[&#34;id&#34;] == 35){&#60;br /&#62;
            $field[&#34;type&#34;] = &#34;select&#34;;&#60;br /&#62;
            $field[&#34;choices&#34;] = $items;&#60;br /&#62;
        }&#60;/p&#62;
&#60;p&#62;    return $form;&#60;br /&#62;
}'
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
