Is it even possible?
I’ve tried the _GET form and it just spat errors out at me.
I assumed I could get user input from the search form and set it as a variable and give the variable in place of “xxx” but that was a swing and miss too.
I am not going to be able to help you by commenting on whether you could pass user input to the shortcode, because I dont know for sure. Maybe someone else does.
But what I would like to suggest is
1) Write your own query using wp_query
http://codex.ww.wp.xz.cn/Class_Reference/WP_Query
or if you prefer not to write code, this may be an option:
2) http://ww.wp.xz.cn/plugins/query-wrangler/
Thanks, but I don’t see how Query Wrangler can help me at all.
<?php
if (strlen($_GET['input'])>0) {
echo do_shortcode("[mendeley type="groups" id="3913021" groupby="year" filter="keyword=.$_GET['input']"]")
} else {echo "Sorry, try again."}
?>
<form action="" method="get">
<input name="input" value="Keyword Search" />
<input type="submit" value="Submit" />
</form>
That’s what I’ve got so far and the page displays:
Parse error: syntax error, unexpected T_STRING in /home2/cannabib/public_html/wp-content/plugins/wp-exec-php/wp-exec-php.php(652) : eval()’d code on line 9
Missing ; at end of echo statements
I feel foolish for leaving those out. I’ve got all the proper marks in place and I still cannot get the job done.
At last the errors have stopped but I still cannot get the shortcode to execute with the input after it is submitted.
<code>
<form action="" method="get">
<input name="input" value="Keyword Search" />
<input type="submit" value="Submit" />
</form>
<?php
$input = $_GET['input'];
if (strlen($input) > 0) {
echo do_shortcode('[mendeley type="groups" id="3913021" groupby="year" filter="keyword=$input"]');
}
?>
</code>
Not sure how to help with that but I looked around and found this – I hope it may help you
http://www.s2member.com/kb/using-variables-in-a-shortcode/
That was VERY helpful! I was able to solve the problem after viewing the above link.
Thank you!
For those in the future with the same problem:
I had to replace the
"filter="keyword=$input"
with
"keyword="<?php echo $input; ?>""
<code>
<form action="" method="post">
<input name="input" value="" />
<input type="submit" value="Keyword Search" />
</form>
<?php
$input = $_POST["input"];
$input = strtolower($input);
if (strlen($input) > 0) {
echo do_shortcode('[mendeley type="groups" id="3913021" groupby="year" filter="keyword="<?php echo $input; ?>""]');
}
?>
</code>
Glad that you got it working 🙂