What′s wrong with this shortcode function?
-
Hi, working on a plugin which has a shortcode feature, got a problem with the output though. This is my function:
function the_output($atts){ extract(shortcode_atts(array( "id" => '1' ), $atts)); $poll_sel_data = get_poll_objects($id); foreach($poll_sel_data as $poll_sel_item){ $poll_sel_output = "<ul>"; $poll_sel_output .= "<li>"; $poll_sel_output .= $poll_sel_item->object_title; $poll_sel_output .= "</li>"; $poll_sel_output .= "<ul>"; $poll_sel_output .= "<li>"; $poll_sel_output .= $poll_sel_item->secondary_text; $poll_sel_output .= "</li>"; $poll_sel_output .= "</ul>"; $poll_sel_output .= "</ul>"; } return $poll_sel_output; }
And the get_poll_objects function:
function get_poll_objects($current_poll_id){ global $wpdb; $table_name = $wpdb->prefix . "poll_objects"; $poll_sel = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE poll_id={$current_poll_id}" ); return $poll_sel; }
When I use the shortcode it should output all the objects which has the current poll_id. However, it only gives me the last added item with that poll_id.
Anyone who can spot the problem?
Regards.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘What′s wrong with this shortcode function?’ is closed to new replies.