0

I'm working on a client's website that I, nor the company I work for, didn't develop, but due to our contract with the client we now manage the site.

There is an issue with three pages for different project categories that link to different projects within those categories the client has done. The heading on each page is showing "Active Projects" (a separate page and category) instead of the specific project category for each page (Government Development, Healthcare Development and Municipal).

There are multiple other category pages that are working properly, but for some reason these three don't work. I've tried fixing it myself, but I only made things worse. Any help is appreciated.

Here is the code that controls the heading:

            <h1><span class="bccTitle2">

                <?php

                    $terms = wp_get_object_terms( $post->ID, 'project_category' );

                    foreach( $terms as $term )
                        $term_names[] = $term->name;

                    //echo implode( ', ', $term_names );
                    echo $term_names[0];

                ?>

    </span></h1>
0

Firstly, are you sure they don't have more than one category selected for those posts? wp_get_object_terms will attempt to get the terms in the order they have been added, so maybe there is an "Active Projects" term in play?

Alternatively, they could be hooking into the wp_get_object_terms filter elsewhere in the code, and modifying what it returns. You'd need to search for that.

  • Most of the posts have multiple categories assigned to them. These three particular pages all have posts that are also assigned the "active projects" category. On one page the first four posts are also assigned "active projects," on the second page the fourth, seventh and twelfth and on the third page only the fifth. Do I need to remove the extra categories so those posts only show up in the active projects page or is there something else I could do to work around this issue? – ABorg Sep 15 '16 at 20:19
  • What you describe doesn't quite fit my theory about the order of terms, but I cannot be sure. Regardless, try using single_cat_title() to get the title of your category page, instead of the code you currently have. – vancoder Sep 15 '16 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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