customization - Why does a custom php code inside a custom template not get executed?

So in order to have some php code executed inside a page on wordpress there are 2 ways. One of them is to create a page

So in order to have some php code executed inside a page on wordpress there are 2 ways. One of them is to create a page template and when creating the new page in wordpress set the Page Attribute to this new page template.

This is what i have done. I have created a custom template called stockchart.php. I have copied the default content of page.php into it. Then i added my php code below the first line

But it still doesnt work i dont know why?

Here is my custom template:

<?php /* Template Name: StockChart */ ?>

<?php print("hello") ?>

<?php
    $dbHost = "xxx";
    $dbDatabase = "xxx";
    $dbPasswrod = "xxx";
    $dbUser = "xxx";
    $mysqli = mysqli_connect($dbHost, $dbUser, $dbPasswrod, $dbDatabase);

/* Getting stock1 table data */
    $sql = "SELECT TradeDate as date, Lscore2 as L FROM levermann_kurz WHERE Stock_short='AAPL' ORDER BY TradeDate asc";
    $stock1 = mysqli_query($mysqli,$sql);
    $stock1 = mysqli_fetch_all($stock1,MYSQLI_ASSOC);
    $stock_dual = json_encode($stock1);
?>


<?php get_header(); ?>

<div id="primary" class="content-area">
    <main id="main" class="site-main" role="main">
        <?php
        // Start the loop.
        while ( have_posts() ) : the_post();

            // Include the page content template.
            get_template_part( 'template-parts/content', 'page' );

            // If comments are open or we have at least one comment, load up the comment template.
            if ( comments_open() || get_comments_number() ) {
                comments_template();
            }

            // End of the loop.
        endwhile;
        ?>

    </main><!-- .site-main -->

    <?php get_sidebar( 'content-bottom' ); ?>

</div><!-- .content-area -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745621261a4636530.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信