子主题functions.php无法正常工作

时间:2017-04-14 20:58:35

标签: php wordpress wordpress-theming

我创建了一个wordPress子主题,但激活后该网站显示500错误,管理页面显示空白。 这是我的代码:

/*
Theme Name:   WP Kallyas Child Theme
Theme URI:    http://www.wpbeginner.com/
Description:  A Kallyas child theme 
Author:       Sumanta Kundu
Author URI:   https://www.upwork.com/freelancers/~01b606f18d998a5fb2
Template:     kallyas_30.3.2017
Version:      1.0.0
*/
@import url("../kallyas_30.3.2017/style.css");

并且functions.php代码在这里:

if(isset($_POST['submit_wp_buttons_settings'])){
save_plugin_data_meta_table();
}
 if ( isset( $_POST['btn_save_send_data_email'] ) ) {
$current_user = wp_get_current_user();
$admin_email = get_option( 'admin_email' );
$current_url="//".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$contact_errors = false;
    // get the posted data
    $name = $_POST["name"];
    $email_address = $_POST["email"];
    $messagee = $_POST["messagee"];
    $price = $_POST["price"];
    $txt_txt = $_POST['txt_txt'];
    // write the email content
    $header .= "MIME-Version: 1.0\n";
    $header .= "Content-Type: text/html; charset=utf-8\n";
    $header .= "From:" . $email_address;
    $message = "Name: $name <br/>";
    $message .= "Email Address: $email_address <br/>";
    $message .= "$txt_txt: $price <br/>";
    $message .= "Message: <br/> $messagee <br/>";
    $message .= "Product Url: <br/> $current_url";
    $subject = "$txt_txt - ww2badges";
    $subject = "=?utf-8?B?" . base64_encode($subject) . "?=";
    $to = $admin_email;
    // send the email using wp_mail()
    if( !mail($to, $subject, $message, $header) ) {
        echo '<script>alert("Failed");</script>';
        echo '<script>window.location.href="'.$current_url.'"</script>';
    } else {
        echo '<script>alert("Email has been sent to admin.");</script>';
        echo '<script>window.location.href="'.$current_url.'"</script>';
    }
 }
 if ( isset( $_POST['not_logged_in'] ) ) {
echo '<script>alert("You should login first.");</script>';
echo '<script>window.location.href="'.site_url().'/wp-login.php"</script>';
}
if ( isset( $_POST['starting_price_btn'] ) ) {
send_starting_bid_email_to_admin();
}

请帮帮我,我是WordPress的新手。我也将这段代码添加到我的插件中,但同样的问题。

1 个答案:

答案 0 :(得分:0)

您可以使用此:

/*
Theme Name: Twenty Seventeen Child
Theme URL: http://hostinger-tutorials.com
Description: Twenty Seventeen Child Theme
Author: John Doe
Author URL: http://hostinger-tutorials.com
Template: twentyseventeen
Version: 1.0.0
Text Domain: twentyseventeen-child
*/
@import url("../kallyas_30.3.2017/style.css");

然后在functions.php中使用此代码:

<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );

function enqueue_parent_styles() {
   wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
  

您可以从hostinger

阅读更多内容