• Resolved commadelimited

    (@commadelimited)


    I’m trying to build out a mesh of pages on my site for search engines to crawl. I’d like to be able to dynamically set the meta robots tag for “all” pages under the /foobar/ endpoint. For example:

    /foobar/page-one -> noindex
    /foobar/page-two -> index
    /foobar/page-three -> noindex

    I’m using the Yoast plugin which allows you to set the index status of all the pages under an endpoint, but I need more granular control than that.

    This page
    /wp-content/themes/mm-throne/single-boardgame.php

    uses get_template_part to call this page (which does all the work)
    /wp-content/themes/mm-throne/sections/loops/single-layout-boardgame.php

    So I need to pass a value from that innermost include up the chain to the header.

    Anyone have ideas?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    There is no easy way to influence meta tag output in the <head> section from a template part. By the time template part code executes, the <head> section has already been output. I suppose an output buffering scheme could be used to reflect a forward state, but that would be an very unusual approach for WP.

    The conditional logic for meta tag output should anticipate certain template parts would be used based on data it has available such as the page’s query object or its HTML request.

    Thread Starter commadelimited

    (@commadelimited)

    @bcworkz thanks for the response; I was afraid of something like that. Thankfully in this case I had a friend of mine who works as an SEO analyst take a look and he suggested not bothering with the conditional logic and just index all of the pages. 😀 Lucky me.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Dynamically setting meta robots value based on page logic’ is closed to new replies.