admin管理员组文章数量:1327849
I m making a plugin and i need to connect to db for get some values that i will put in the content of new page that will be created. It s strange because this morning it worked and now there is a problem:
function mic_keyword_shortcode($atts = [], $content = '') {
try {
$base = new PDO('mysql:host=localhost:3306; dbname=wordpress', 'root', '');
global $post;
$secteur = $post->post_name;
$secteur = explode("-s", $secteur);
var_dump($secteur);
$requete = "select keyword from wp_keyword where id_secteur=(select id_secteurs from wp_secteurs where libelle='".$secteur[0]."') ORDER BY RAND()";
$resultat = $base->query($requete);
ob_start();
echo '
<div>
<table>
<tr>
';
while ($donnees = $resultat->fetch()) {
echo'
<th><p>'.$donnees['keyword'].'</p></th>';
}
echo ' </tr>
</table>
</div>
';
$html_form = ob_get_clean();
return $html_form;
}
catch(exception $e) {
die('Erreur '.$e->getMessage());
}
}
register_activation_hook(__FILE__, 'mic_keyword_shortcode');
add_shortcode( 'makeitseo-keyword', 'mic_keyword_shortcode');
And in all my page there is only [makeitseo-keyword] without content. Why?
PS the plugin is activated
本文标签: pluginsWhy is my shortcode not working
版权声明:本文标题:plugins - Why is my shortcode not working? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742219747a2435231.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论