WordPress.org

Forums

Using PHP in template to create URL based on dropdown (2 posts)

  1. PinkishHue
    Member
    Posted 2 years ago #

    Hello,

    I'm having trouble getting some PHP code to work within a page template.

    The purpose of the code is to send the user to a URL based on post tags, with the options having been selected from dropdown menus.

    (e.g. mywebsite.com/tag/option1+option2+option3)

    Here is the code for the dropdown menus: http://pastebin.com/DBf96VFd

    The code works if placed in a separate PHP file but is not working when placed inside a page.php template.

    (I have tried using a PHP include to insert the code from the external file and that didn't work either.)

    Many thanks for any help anyone can give and let me know if you need any more info from me.

    Huge thanks!

  2. PinkishHue
    Member
    Posted 2 years ago #

    I haven't found a great solution to this but have resorted to putting the PHP dropdown menu in a separate file and using an iframe to insert it in to my WordPress home page.

    This works now so that if someone chooses their options from the dropdown list, they are redirected to a page based on tags like:

    mywebsite.com/tag/option1+option2+option3

    If anyone knows a better (none iframe) solution please do let me know :)

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic