admin管理员组文章数量:1434900
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(); ?>
本文标签: customizationWhy does a custom php code inside a custom template not get executed
版权声明:本文标题:customization - Why does a custom php code inside a custom template not get executed? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745621260a2666695.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论