Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter mddenton

    (@mddenton)

    Thanks for the help. I have figured out the problem. I rebuilt my site today using a different name for my taxonomy. (I had used “year” which is a reserved word in WP. I now use “season” which is not reserved.)

    The result is that the site works perfectly now. So the use of the reserved word seems to have been the problem.

    Lesson learned!

    Thread Starter mddenton

    (@mddenton)

    Thanks again. This is the script for custom-post-types.php in mu-plugins folder

    <?php
    
    function custom_post_types() {
        register_post_type('review', array(
            'show_in_rest' => true, // enables modern block-style editor display of this post type
            'supports' => array('title', 'editor', 'excerpt'),
            'rewrite' => array(
                'slug' => 'reviews',
            ),
            'has_archive' => true,
            'public' => true,
            'show_in_nav_menus' => true, 
            'labels' => array(
                'name' => 'Reviews',
                'add_new_item' => 'Add New Review',
                'edit_item' => 'Edit Review', 
                'all_items' => 'All Reviews',
                'singular_name' => 'Review',
                'new_item' => 'New Review',
                'view_item' => 'View Review',
                'search_items' => 'Search Reviews',
                'not_found' => 'No Reviews Found.'
            ),
            'menu_icon' => 'dashicons-thumbs-up',
            'description' => 'Reviews written by Martin Denton, 1997 - 2016'
        ));
    }
    
    // eventually add tag cloud functionality!
    function custom_taxonomies() {
        register_taxonomy('company', 'review', array(
            'labels' => array(
                'name'              => 'Company',
                'singular_name'     => 'Company',
                'search_items'      => 'Search Companies',
                'all_items'         => 'All Companies',
                'edit_item'         => 'Edit Company',
                'update_item'       => 'Update Company',
                'add_new_item'      => 'Add Company',
                'new_item_name'     => 'New Company',
                'menu_name'         => 'Companies',
            ),
            'show_in_rest' => true,
            'public' => true,
            'hierarchical'  => false,
            'show_ui'       => true, 
            'show_admin_column' => true, //add the taxonomies to the wordpress admin
            'query_var'         => true,
            'rewrite'       => array('slug' => 'company')
        ));
    
        register_taxonomy('year', 'review', array(
            'labels' => array(
                'name'              => 'Year',
                'singular_name'     => 'Year',
                'search_items'      => 'Search Years',
                'all_items'         => 'All Years',
                'edit_item'         => 'Edit Year',
                'update_item'       => 'Update Year',
                'add_new_item'      => 'Add Year',
                'new_item_name'     => 'New Year',
                'menu_name'         => 'Years',
            ),
            'show_in_rest' => true,
            'public' => true,
            'hierarchical'  => false,
            'show_ui'       => true, 
            'show_admin_column' => true, //add the taxonomies to the wordpress admin
            'query_var'         => true,
            'rewrite'       => array('slug' => 'year')
        ));
    }
    
    add_action('init', 'custom_post_types');
    add_action('init', 'custom_taxonomies');
    
    ?>

    I tried to change the taxonomy ‘year’ to ‘revyear’ and it still didn’t work.

    Thread Starter mddenton

    (@mddenton)

    Thanks for the reply! I have already done both of the two things you suggested, and neither has helped.

    Here is the code for page.php:

    <?php
    
    get_header();
    
    while(have_posts()) {
        the_post(); ?>
        
        <div class="page-banner">
        <div class="page-banner__bg-image" style="background-image: url(<?php echo get_theme_file_uri('/images/ocean.jpg'); ?>)"></div>
        <div class="page-banner__content container container--narrow">
          <h1 class="page-banner__title"><?php the_title(); ?></h1>
          
        </div>  
      </div>
    
      <div class="container container--narrow page-section">
    
        <?php
          $parentID = wp_get_post_parent_id(get_the_ID());
          if ($parentID) { ?>
    
          <div class="metabox metabox--position-up metabox--with-home-link">
            <p><a class="metabox__blog-home-link" href="<?php echo get_permalink($parentID); ?>"><i class="fa fa-home" aria-hidden="true"></i> Back to <?php echo get_the_title($parentID); ?></a> <span class="metabox__main"><?php the_title(); ?></span></p>
          </div>
    
        <?php  } ?>
        <?php
        $testArray =  get_pages(array('child_of'=>get_the_id()));
        if ($parentID or $testArray) {
        ?>
    
        <div class="page-links">
          <h2 class="page-links__title"><a href="<?php echo get_permalink($parentID); ?>"><?php echo get_the_title($parentID); ?></a></h2>
          <ul class="min-list">
            <?php
            if ($parentID) {
              $findChildrenOf = $parentID;
            }
            else{
              $findChildrenOf = get_the_ID();
            }
            wp_list_pages(array(
              'title_li'=> NULL,
              'child_of'=> $findChildrenOf 
            ));
            ?>
          </ul>
        </div>
      <?php }  ?>
        <div class="generic-content">
          <?php the_content(); ?>
        </div>
    
      </div>
    
    <?php }
    
    get_footer();
    
    ?>

    Note that this was working correctly until I installed the custom taxonomies. Could that have something to do with this?

Viewing 3 replies - 1 through 3 (of 3 total)