• Resolved Alfio Piccione

    (@picaland)


    We are supporting Seo Yoast on the theme.
    we have a system to insert posts from the frontend and in the phase of creating the post I set the primary term like this:

    /**
    * WPSEO Primary Term
    *
    * @since ${SINCE}
    *
    * @param $taxonomy string The taxonomy name
    * @param $postID int The post ID
    * @param $term int The term ID
    */
    private function wpseoPrimaryTerm($taxonomy, $postID, $term)
    {
    // Seo Yoast support primary term.
    if (class_exists(‘WPSEO_Primary_Term’)) {
    $primaryTermObject = new \WPSEO_Primary_Term($taxonomy, $postID);
    $primaryTermObject->set_primary_term($term);
    }
    }

    the primary is set but I can not find the post in the archive.
    We also have a filter system to filter posts even by categories but the post is not there.
    I only find it if I update the post from backend.
    Is it a problem you have already faced? How can I solve the problem ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Michael Ti?a

    (@mikes41720)

    We can’t offer support on custom code (needed to change (core) features of our plugin). Since we don’t want to take the risk that we break your website by suggesting incorrect or incomplete code, we cannot advise you on how to make such changes. Maybe someone watching these forums can assist you further, but if your topic is inactive for 7 days, we’ll mark it as resolved to keep the overview.

    Thank you for your understanding.

    Thread Starter Alfio Piccione

    (@picaland)

    I understand your answer, but I would have expected at least one suggestion.

    However if needed I solved ??

    This is the solution:

    /**
    * WPSEO Primary Term
    *
    * @since ${SINCE}
    *
    * @param $taxonomy string The taxonomy name
    * @param $postID int The post ID
    * @param $term int The term ID
    *
    * @return bool
    */
    private function wpseoPrimaryTerm($taxonomy, $postID, $term)
    {
    if (! class_exists(‘WPSEO_Primary_Term_Admin’)) {
    return false;
    }

    // Set primary term.
    $primaryTermObject = new \WPSEO_Primary_Term($taxonomy, $postID);
    $primaryTermObject->set_primary_term($term);

    // Save primary term.
    $primaryTermObjectAdmin = new \WPSEO_Primary_Term_Admin();
    $primaryTermObjectAdmin->save_primary_terms($postID);
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_insert_post set WPSEO_Primary_Term’ is closed to new replies.