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