• Resolved darerodz

    (@darerodz)


    Hi, AIOSEO team.

    Writing here because it seems to be the best place to do so.

    I’m involved in the development of the REST API – Head Tags plugin, which exposes the meta tags in the WP REST API for each entity, JSON format. That’s a useful feature if you want to follow a Headless-WordPress approach.

    The way it works, basically, is by calling the "wp_head" action and parsing the html that was generated, and that could happen more than once during the same request, because a REST API response might contain several entities
    (a list of posts, embedded categories & tags, etc.).

    Well, our plugin used to work with the previos AIOSEO version but not since the v4 came up.

    I found the root of the problem: is this line of code (168), inside the Head‘s output method. There, a bunch of .php files called ‘views’ — those that output the html code for the meta tags — are loaded using require_once. As require_once just loads the specified file if it hasn’t been loaded before, the Head‘s output method only renders the meta tags the first time it’s called. That makes our plugin to work only for the first entity included in a REST API response, and the following ones are missing the tags added by the AIOSEO plugin.

    For me, the easiest way to fix this would be replacing require_once with require, but that involves modifying the AIOSEO plugin’s code.

    Is there any critical reason why require_once should be used?

    If so, do you know if there is a workaround that could help us? I already failed trying to figure out a possible solution.

    Thanks in advance.

    • This topic was modified 3 years, 9 months ago by darerodz.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Issue exposing meta tags in the REST API’ is closed to new replies.