0

Here's what I am trying to achieve: when a category page is loaded then, based upn the ID of that category, an "include" file is loaded.

I believe that the below would work for some limited text, but I would prefer to load an "include" file b/c it will have multiple paragraphs and I feel it is better to manage that way.

   <?php
    $catarray = get_the_category( $post->ID );
    foreach ($catarray as $cat) {
        $catid = $cat->term_id;

        if ($catid == 10) {
          echo 'TEXT HERE'; // I prefer a PHP Include File 
        }
        if ($catid == 7) {
          echo 'ANOTHER TEXT';
        }

    }
    ?>

So, my question would be - what would I need to do to replace the "echo" string? Would it be simply:

include get_theme_file_path( '/subdir/text-to-enter-in-the-category-10.php' );

Thanks for all help

1 Answer 1

0

I don't quite understand what you mean but this might work get_template_part()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.