I am having a bit of an issue with autogenerating shortcodes, based on database entries.
I am able to get a normal shortcode working i.e:
function route_sc5() {
return "<div>Route 5</div>";
}
add_shortcode('route 5','route_sc');
and the following shortcode to activate it would be [route 5]
This works. But what I need is the shortcode to be produced for each database entry. something like:
$routes = $wpdb->get_results( $wpdb->prepare("SELECT * FROM wp_routes") );
foreach($routes as $route)
{
function route_sc$route->id () {
return "<div>Route $route->id</div>";
}
add_shortcode('route $route->id','route_sc$route->id');
}
The above is just an example of how I want it to work. Not literally the code I am using. How would I go about achieving this? ): Thanks.