Creating shortcode with a database query in it…
-
I get the basics of creating a shortcode and have the query part down, but if I just use the query as I normally would in a function. I’m also not sure how to pass a variable (or an attribute?) for the query to use.
The plan would be for me and other writers to use this shortcode when creating a Post. [team_preview team=######]
How do I get the function/query to read the ‘team’ part? Is it as easy as using the $atts or $content variables where I have $team in the query below?
function team_players {
select * from data-table
where team = . ‘ $team ‘ .}
add_shortcode(‘team_preview’, ‘team_players’);
- The topic ‘Creating shortcode with a database query in it…’ is closed to new replies.