Jump to content

Php And Wordpress Help


Recommended Posts



My name is Steve and I just joined up here. Looks like a good community so far.

I am learning PHP and use Wordpress alot and I would like some help with an issue I'm having. Apologies if this is in the wrong section.


I would like to output tags that I have preset in the backend, into a dropdown list on the frontend. Think of a profile page where a user can select an option from a dropdown, well I would like the tags to appear here for the user to select from. There are however a couple of requirements. If the user changes the dropdown value it needs to submit this to the Database so that the value is set to the new option. Also if a user wanted to choose more than 1 tag up to a maximum of 5, how could I add into the code if the user clicks a small link, another dropdown appears for them to select from the tags, and then save this to the Database as well.


To me this seems like a highly advanced thing to accomplish, but to you guys this may be quite easy.


Any tips, suggestions or links will be greatly appreciated.





Link to comment
Share on other sites

Your question is too larger in scope to be covered in a simple forum reply. Do you have a specific question / issue that you would like help with? You need to break the problem down into smaller parts and ask for help with the parts you are having problems with one at a time.

Link to comment
Share on other sites

Thankyour for the reply.


I guess the steps I have at the moment are:


1. show the tags in a dropdown with the corresponding tag as the selected option (ie- if first tag show the tag dropdown list with tag1 selected, and if there is a second,third or fourth tag, show each of them in a dropdown list with corresponding tag selected).


2. if a change is made to the tags selection, then update this to the DB to save the value.


3. be able to add a new dropdown with the tags if the user would like to add another tag, upto a maximum of 5.


So if I were to focus on step 1, here is my current code:


if(isset($_GET['eid']) && $field['name'] == "tags")
$alltags = get_tags();
$posttags = get_the_tags($_GET['eid']);
foreach($posttags as $tag){
$selectedtag = $tag->name;}

echo '<div class="tagsdrop">';

if ($alltags)
if ($posttags > 0)
foreach($posttags as $tag)

echo " tag is: " . $tag->name ;
echo ''; foreach($alltags as $tag) { if($tag->name == $selectedtag) { echo ''.$tag->name.''; } else { echo ''.$tag->name.''; } } echo ' ';


echo '</div>'; //end tagsdrop

$FIELDVALUE = $tags;

elseif(isset($_POST['action']) && (isset($field['dataname']) && !isset($data[$field['dataname']]) ) && isset($_POST['form'][$field['name']]) ){
$FIELDVALUE = $_POST['form'][$field['name']];
elseif(isset($field['dataname']) && isset($data[$field['dataname']])){
$FIELDVALUE = $data[$field['dataname']];


I am editing a theme and have only added the code between "$alltags = get_tags();" and "echo '</div>'; //end tagsdrop".


Currently my output is 2 dropdown lists, as there are 2 tags on this particular post. Each dropdown lists all the tags, but the selected tag in both dropdowns is the 2nd tag alphabetically for the post. I am wanting tag 1 to be selected in the first tag dropdown, and tag 2 to be selected in the second tag dropdown.


Apologies again for the long winded explanation, I feel like my solution is close but just needs modifying by an expert.


Thankyou for your help.

Edited by binga30
Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.