插件在自定义主题中不起作用

时间:2021-12-17 作者:seshadri mandal

我正在创建一个自定义主题。在其中,我试图添加沙龙预订插件。此插件创建默认预订页面。当我查看预订页面时,我看不到预订表单。我已经尝试在WordPress默认主题2021中安装沙龙预订插件,它在这个主题中运行良好。不知道我的主题有什么突破。

在我的主题中,我添加了wp_head() 就在头部标记结束之前header.php. 我还补充了wp_footer() 就在页脚中body标记的末尾之前。php。

我有以下php文件

  • header.php
  • footer.php
  • functions.php
  • index.php
  • front-page.php
我有以下页面-主页(我创建的,这是指向front page.php),预订,感谢您预订,预订我的帐户。最后三个预订页面是作为沙龙预订插件的一部分创建的。

header.php:

<!DOCTYPE html>
<html <?php language_attributes();?>>
<head>
    <meta charset=<?php bloginfo(\'charset\');?>>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!--<title>Dust Doctors LLC Theme</title>-->
    <title><?php bloginfo(\'name\');?></title>
    <link rel="shortcut icon" href="<?php echo get_theme_file_uri(\'/img/favicon.ico\');?>">
    <?php /*include_once( ABSPATH . \'wp-admin/includes/plugin.php\' ); */?>
    <?php wp_head(); ?>
    
</head>
<body <?php body_class();?> data-spy="scroll" data-target="#navbarResponsive">

    <!-- Start Header Section -->
    <header id="home">

        <!-- Navigation -->
        <nav class="navbar navbar-expand-lg fixed-top">
            <div class="container-fluid">
                <a href="#home" class="navbar-brand"><img src="<?php echo get_theme_file_uri(\'/img/logo.jpeg\');?>" alt=""></a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive">
                    <span class="custom-toggler-icon"><i class="fas fa-bars"></i></span>
                </button>

                <div class="collapse navbar-collapse" id="navbarResponsive">
                    <ul class="navbar-nav ml-auto">
                        <li class="nav-item">
                            <a href="#aboutUs" class="nav-link">About Us</a>
                        </li>
                        <li class="nav-item">
                            <a href="#services" class="nav-link">Our Services</a>
                        </li>
                        <li class="nav-item">
                            <a href="#portfolio" class="nav-link">Portfolio</a>
                        </li>
                        <li class="nav-item">
                            <a href="#clients" class="nav-link">Clients</a>
                        </li>
                        <li class="nav-item">
                            <a href="#contact" class="nav-link">Contact Us</a>
                        </li>
                        <li class="nav-item">
                            <a href="#book" class="nav-link">Book Now</a>
                        </li>
                        <li class="nav-item">
                            <a href="#faq" class="nav-link">FAQ</a>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>
        <!-- End Navigation -->
    </header>
    <!-- End Header Section --> 
footer.php:

<footer>
    
    <div class="container footer px-0">
        <hr class="socket">
        <div class="row">
            <div class="col-12 d-flex justify-content-center">
                <img src="img/logo.jpeg" alt="" class="brand__logo">
            </div>
        </div>
        <div class="row outer">
            <div class="container">
                <div class="row py-3">
                    <!--<div class="col-md-6 px-0 pr-md-3">-->
                    <div class="col-md-4 px-0 pl-md-3">
                        <h5 class="text-theme util__margin__botom">Corporate Office</h5>
                        <p>
                            <i class="fas fa-map-marker"></i>&nbsp;&nbsp;&nbsp;&nbsp;100 Street Name,<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Our City, <br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AA 10000
                        </p>
                    </div> <!-- End Column -->
                    <div class="col-md-4 px-0 pl-md-3">
                        <h5 class="text-theme util__margin__botom">Contact Info</h5>
                        <p><i class="fas fa-phone"></i>&nbsp;&nbsp;&nbsp;&nbsp;(888) 888-8888 <br>
                            <i class="fas fa-envelope"></i>&nbsp;&nbsp;&nbsp;&nbsp;[email protected] <br>
                            <i class="fas fa-fax"></i>&nbsp;&nbsp;&nbsp;&nbsp;(888) 888-8888</p>
                            <h5 class="text-theme util__margin__botom">Follow Us On</h5>
                        <ul class="social">
                            <li><span><a href="#"><i class="fab fa-facebook-square"></i></a></span></li>
                            <li><a href="#"><i class="fab fa-twitter-square" ></i></a></li>
                            <li><a href="#"><i class="fab fa-instagram"></i></a></li>
                            <li><a href="#"><i class="fab fa-youtube-square"></i></a></li>
                            <li><a href="#"><i class="fab fa-linkedin"></i></a></li>
                        </ul>
                    </div>
                    <!---<div class="col-md-6 px-0 pr-md-3">-->
                        <div class="col-md-4 px-0 pl-md-3">
                            <h5 class="text-theme util__margin__botom">Useful Links</h5>
                            <i class="fas fa-link"></i>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" class="footer__link">PRIVACY POLICY</a><br>
                            <i class="fas fa-link"></i>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" class="footer__link">TERMS</a><br>
                            <i class="fas fa-link"></i>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" class="footer__link">COMPANY</a><br>
                            <i class="fas fa-link"></i>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" class="footer__link">SERVICES</a><br>
                        </div>                  
                </div> <!-- End Row -->
            </div> <!-- End Container -->

            <hr class="socket">
            <div class="col-12 d-flex justify-content-center">
                <p class="text-center">&copy; Dust Doctors LLC 2021</p>
            </div>

        </div> <!-- End Row Outer -->
    </div> <!-- End Container Fluid -->
    
</footer>
    <!-- Top Scroll -->
    <a href="#home" class="top-scroll">
        <i class="fa fa-angle-up"></i>
    </a>
    <!-- End of Top Scroll -->


    <!-- Script Source Files -->


    <!-- Plugins.js -->
    <script src="js/plugins.js"></script>
    <!-- Waypoints https://cdnjs.com/libraries/waypoints
        https://github.com/imakewebthings/waypoints -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/jquery.waypoints.min.js"></script>
    <!-- Font Awesome https://fontawesome.com/  https://use.fontawesome.com/releases/v5.13.0/js/all.js -->
    <script src="https://use.fontawesome.com/releases/v5.13.0/js/all.js"></script>
    <!-- Lightbox Image Gallery https://cdnjs.com/libraries/lightbox2  https://lokeshdhakar.com/projects/lightbox2/ -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.1/js/lightbox.min.js"></script>
    <!-- Owl Carousel https://cdnjs.com/libraries/OwlCarousel2
        http://owlcarousel2.github.io/OwlCarousel2/ -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
    <!-- jQuery CounterUp https://www.jsdelivr.com/package/npm/jquery.counterup
        https://github.com/bfintal/Counter-Up2 -->
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/jquery.counterup.min.js"></script>
    <!-- Bootstrap Form Validator https://cdnjs.com/libraries/1000hz-bootstrap-validator -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.9/validator.min.js"></script>
    
    <!-- End of Script Source Files -->
    <?php wp_footer(); ?>
</body>
</html>
index.php:

<?php get_header(); ?>



<?php get_footer();?>
functions.php:

<?php
    function theme_assets(){
        /*wp_enqueue_style(\'dust_doctors_main_styles\',get_stylesheet_uri());*/
        /* bootstrap*/
        wp_enqueue_style(\'bootstrap\',\'//cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css\',array(),\'v5.1.3\',false);
        /* main css*/
        wp_enqueue_style(\'main_style\',get_theme_file_uri(\'/css/style.css\'),array(\'bootstrap\'),\'1.0\',false);
        /* plugins css*/
        wp_enqueue_style(\'plugins_style\',get_theme_file_uri(\'/css/plugins.css\'),array(),\'1.0\',false);
        /* google fonts*/
        wp_enqueue_style(\'google-fonts\',\'//fonts.googleapis.com/css?family=Lato:300,400,700&display=swap\',array(),\'1.0\',false);
        /* animate css*/
        wp_enqueue_style(\'animate-css\',\'//cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.min.css\',array(),\'v3.7.2\',false);
        /* lightbox*/
        wp_enqueue_style(\'lightbox\',\'//cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.1/css/lightbox.min.css\',array(),\'v2.11.1\',false);
         /* owl carousel */
         wp_enqueue_style(\'owlcarousel1\',\'//cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css\',array(),\'v2.3.4\',false);
         wp_enqueue_style(\'owlcarousel2\',\'//cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.min.css\',array(),\'v2.3.4\',false);
         /* jquery */
         wp_enqueue_script(\'boot-jquery\',\'//code.jquery.com/jquery-3.4.1.min.js\',array(\'jquery\'),\'\',false);
         /* bootstrap popper js*/
         wp_enqueue_script(\'boot-popper-js\',\'//cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js\',array(\'jquery\'),\'v1.14.7\',false);
         /* bootstrap main js*/
         wp_enqueue_script(\'boot-main-js\',\'//stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js\',array(\'jquery\'),\'v4.3.1\',false);
         /* main js script*/
         wp_enqueue_script(\'plugin-js\',get_theme_file_uri(\'/js/plugins.js\'),array(\'jquery\',\'jquery-ui-core\',\'jquery-ui-selectmenu\'),\'1.0\',true);
         /* waypoints*/ 
         wp_enqueue_script(\'waypoints\',\'//cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/jquery.waypoints.min.js\',array(\'jquery\'),\'v4.0.1\',true);
         /* font awesome */
         wp_enqueue_script(\'font-awesome\',\'//use.fontawesome.com/releases/v5.13.0/js/all.js\',array(),\'v5.13.0\',true);
         /* lightbox */
         wp_enqueue_script(\'lightbox-js\',\'//cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.1/js/lightbox.min.js\',array(\'jquery\'),\'v2.11.1\',true);
         /* owl carousel */
         wp_enqueue_script(\'owl-carousel-js\',\'/cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js\',array(\'jquery\'),\'v2.3.4\',true);
         /* counter js */
         wp_enqueue_script(\'counter-js\',\'//cdn.jsdelivr.net/npm/[email protected]/jquery.counterup.min.js\',array(\'jquery\'),\'v2.1.0\',true);
         /* form validator*/
         wp_enqueue_script(\'form-validator\',\'//cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.9/validator.min.js\',array(\'jquery\'),\'v0.11.9\',true);
       
    }

    /* change login logo in wp-admin*/
    function my_login_logo() { ?>
        <style type="text/css">
            body.login{
                background-image:url(<?php echo get_stylesheet_directory_uri(); ?>/img/slide-02.jpeg);
                background-size: cover;
                background-position: center center;
                background-repeat:no-repeat;
            }
            #login h1 a, .login h1 a {
                background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/img/logo.jpeg);
            height:150px;
            width:150px;
            background-size: 150px 150px;
            background-repeat: no-repeat;
                padding-bottom: 30px;
            }
        </style>
    <?php }

    function my_login_logo_url() {
        return home_url();
    }

    function my_login_logo_url_title() {
        return \'Dust Doctors LLC Login\';
    }

    function add_site_favicon() {
        echo \'<link rel="shortcut icon"
    href="\' . get_stylesheet_directory_uri() . \'/img/favicon.ico" />\';
    }
    

        /*function custom_unregister_theme_post_types() {
            global $wp_post_types;
        
              if ( isset( $wp_post_types["image"] ) ) {
                 unset( $wp_post_types[ "image" ] ); //UPDATED
              }
        
        }
        add_action( \'init\', \'custom_unregister_theme_post_types\', 20 );*/
        
    add_action(\'wp_enqueue_scripts\',\'theme_assets\');
    add_action( \'login_enqueue_scripts\', \'my_login_logo\' );
    add_filter( \'login_headerurl\', \'my_login_logo_url\' );
    add_filter( \'login_headertext\', \'my_login_logo_url_title\' );
    add_action(\'login_head\', \'add_site_favicon\');
    add_action(\'admin_head\', \'add_site_favicon\');
?>
front-page.php:

    <?php get_header(); ?>
    
    <?php 
    //custom fields
    $landing_background_image = get_field(\'landing_background_image\');
    $landing_header = get_field(\'landing_header\');
    if (empty($landing_header)){
        $landing_header = \'looking for a cleaning service?\';
    }
    $landing_tag_line = get_field(\'landing_tag_line\');
    if (empty($landing_tag_line)){
        $landing_tag_line = \'we are here to make your home shine\';
    }
    if (empty($landing_button)){
        $landing_button = "let\'s shine";
    }
    ?>
    
    
        <!-- Start Landing Page Section -->
        <section>
            <!-- Start Landing Page Image and Title -->
            <div class="landing">
                <div class="home-wrap">
                    <!--<div class="home-inner"></div>-->
                    <ul class="home-slideshow">
                    <li>
                        <?php if(!empty($landing_background_image)){?>
                            <span style="background-image: -webkit-linear-gradient(rgba(11,12,16,0.7) 30%,rgba(0,0,0,0.7)), url(<?php echo $landing_background_image[\'url\'];?>)">Image 01</span>
                        <?php } else{?>
                            <span style="background-image: -webkit-linear-gradient(rgba(11,12,16,0.7) 30%,rgba(0,0,0,0.7)), url(<?php echo get_theme_file_uri(\'/img/slide-02.jpeg\');?>)">Image 01</span>
                        <?php }?>
                <!--        <div class="slide__title text-center text-uppercase">
                        <h1 class="slide__title__main">looking for a cleaning service?</h1>
                        <h3 class="slide__title__sub">we are here to make your home shine</h3>-->
                        </div>
                    </li>
                    </ul>
                </div>
            </div>
            <!-- End Landing Page Image and Title-->
    
            <!-- Start Landing Page Button -->
            <div class="caption text-center text-light text-uppercase">
                <!--<h1 class="caption__title__main os-animation" data-animation="fadeInUp" data-animation="fadeInUp" data-delay="1s">looking for a cleaning service?</h1>
                <h3 class="caption__title__sub os-animation" data-animation="fadeInUp" data-delay="2s">we are here to make your home shine</h3>
                <a href="#booking" class="btn btn__primary btn__animated os-animation" data-animation="fadeInUp" data-delay="3s">let\'s shine</a>-->
                <h1 class="caption__title__main os-animation" data-animation="fadeInUp" data-animation="fadeInUp" data-delay="1s"><?php echo $landing_header;?></h1>
                <h3 class="caption__title__sub os-animation" data-animation="fadeInUp" data-delay="2s"><?php echo $landing_tag_line;?></h3>
                <a href="#booking" class="btn btn__primary btn__animated os-animation" data-animation="fadeInUp" data-delay="3s"><?php echo $landing_button;?></a>
            </div>
            <!-- End Landing Page Button -->
    
            <!-- Start Bouncing Down Arrow -->
            <a href="#aboutUs" class="down-arrow text-center">
                <!--<div class="arrow d-none d-md-block">-->
                <div class="arrow">
                    <i class="fas fa-angle-down"></i>
                </div>
            </a>
            <!-- End Bouncing Down Arrow -->
        </section>
        <!-- End Landing Page Section -->
    
<?php get_footer();?>

2 个回复
SO网友:Tom J Nowell

您的主题不包含主帖子循环,因此插件没有位置执行其工作

if ( have_posts() ) {
    while ( have_posts() ) {
        the_post(); 
        //
        // Post Content here
        //
        the_content();
    } // end while
} // end if

https://codex.wordpress.org/The_Loop

SO网友:seshadri mandal

非常感谢。我现在创建了两个新的php文件页面。php和single。php提供了以下内容,问题得到了解决。

    <div class="generic-content"> <?php the_content();?> </div>