Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
206 views
in Technique[技术] by (71.8m points)

php - I tried changing my wordpress template in page attributes, now Its broken

These pages are connected to a custom template style that queries a custom post type

https://cotoacademy.com/about-yokohama-school/

https://cotoacademy.com/about-us/

Previously I tried cloning the About.php template that was selected in page attributes. My aim was to include a custom contact form for one school location.

Cloning the about.php and editing the title / file name didn't work and it seems to have broken my connection to the custom post type and their entries - so i tried reselecting the previous about template under page attributes which also didn't work.

Basically I

  1. Cloned my about.php template file
  2. renamed it - and edited the title of it within the php file
  3. Selected this new cloned php template
  4. this broke my connection to the custom post type and the selected template in page attributes
  5. I restored the original settings for the post prior to the issue
  6. this still hasn't fixed the problem

Any ideas on what happened? the template is below

    <?php
/**
 * Template Name: About
 *
 * @package WordPress
 * @subpackage Coto Academy
 */
?> <?php get_header(); ?>

<section class="section__container">
    <div class="section__container"> 
        <div class="section__content"> <?php the_content(); ?>
        </div>
</section>

<section class="staffs">
  <div class="anchor-point" id="our-school-staff"></div>
    <div class="container">
        <h2 class="staff__title">Our school Staff</h2>
        <div class="desktop" style="height:40px;"></div>
        <div class="mobile" style="height:20px;"></div>
    <?php
    $schools = get_field('select_school');
    foreach ($schools as $school):
      $loop = new WP_Query(array(
        'post_type' => 'staff',
        'posts_per_page' => 99,
        'meta_query' => array(
          array(
            'key' => 'select_school',
            'value' => $school,
            'compare' => 'LIKE'
          ),
          array(
            'key' => 'teacher_or_staff',
            'value' => 'staff',
            'compare' => 'LIKE'
          )
        )
      ));
    endforeach;
    ?>
        <?php $the_count = $loop->found_posts; ?>
        <ul class="staff-list flex-wrap">
            <?php
   while ($loop->have_posts()):
     $loop->the_post(); ?>
            <?php get_template_part('staffs/staff'); ?>
            <?php
   endwhile;
   wp_reset_query();
   ?>
    </div>
    <div class="desktop" style="height:40px;"></div>
    <div class="mobile" style="height:20px;"></div>
</section>

<section class="staffs">
<div class="anchor-point" id="our-teachers"></div>
    <div class="container">
        <h2 class="staff__title">Our teachers</h2>
        <div class="desktop" style="height:40px;"></div>
        <div class="mobile" style="height:20px;"></div>
    <?php
    $schools = get_field('select_school');
    foreach ($schools as $school):
      $loop = new WP_Query(array(
        'post_type' => 'staff',
        'posts_per_page' => 99,
        'meta_query' => array(
          array(
            'key' => 'select_school',
            'value' => $school,
            'compare' => 'LIKE'
          ),
          array(
            'key' => 'teacher_or_staff',
            'value' => 'teacher',
            'compare' => 'LIKE'
          )
        )
      ));
    endforeach;
    ?>
        <?php $the_count = $loop->found_posts; ?>
        <ul class="staff-list flex-wrap">
            <?php
   while ($loop->have_posts()):
     $loop->the_post(); ?>
            <?php get_template_part('staffs/staff'); ?>
            <?php
   endwhile;
   wp_reset_query();
   ?>
    </div>
    <div class="desktop" style="height:40px;"></div>
    <div class="mobile" style="height:20px;"></div>
</section>

<?php get_footer();

Any ideas?

question from:https://stackoverflow.com/questions/65932611/i-tried-changing-my-wordpress-template-in-page-attributes-now-its-broken

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...