Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • I used ACF to register CPT.

    this is the JSON

    {
        "key": "post_type_64dea13278e29",
        "title": "Experiences",
        "menu_order": 0,
        "active": true,
        "post_type": "bookable-tour",
        "advanced_configuration": true,
        "import_source": "",
        "import_date": "",
        "labels": {
            "name": "Experiences",
            "singular_name": "Experience",
            "menu_name": "Experiences",
            "all_items": "All Experiences",
            "edit_item": "Edit Experience",
            "view_item": "View Experience",
            "view_items": "View Experiences",
            "add_new_item": "Add New Experience",
            "add_new": "",
            "new_item": "New Experience",
            "parent_item_colon": "Parent Experience:",
            "search_items": "Search Experiences",
            "not_found": "No experiences found",
            "not_found_in_trash": "No experiences found in Trash",
            "archives": "Experience Archives",
            "attributes": "Experience Attributes",
            "featured_image": "",
            "set_featured_image": "",
            "remove_featured_image": "",
            "use_featured_image": "",
            "insert_into_item": "Insert into experience",
            "uploaded_to_this_item": "Uploaded to this experience",
            "filter_items_list": "Filter experiences list",
            "filter_by_date": "Filter experiences by date",
            "items_list_navigation": "Experiences list navigation",
            "items_list": "Experiences list",
            "item_published": "Experience published.",
            "item_published_privately": "Experience published privately.",
            "item_reverted_to_draft": "Experience reverted to draft.",
            "item_scheduled": "Experience scheduled.",
            "item_updated": "Experience updated.",
            "item_link": "Experience Link",
            "item_link_description": "A link to a experience."
        },
        "description": "",
        "public": true,
        "hierarchical": false,
        "exclude_from_search": false,
        "publicly_queryable": true,
        "show_ui": true,
        "show_in_menu": true,
        "admin_menu_parent": "",
        "show_in_admin_bar": true,
        "show_in_nav_menus": true,
        "show_in_rest": true,
        "rest_base": "",
        "rest_namespace": "wp\/v2",
        "rest_controller_class": "WP_REST_Posts_Controller",
        "menu_position": "",
        "menu_icon": "",
        "rename_capabilities": false,
        "singular_capability_name": "post",
        "plural_capability_name": "posts",
        "supports": [
            "title",
            "excerpt",
            "revisions",
            "thumbnail"
        ],
        "taxonomies": "",
        "has_archive": true,
        "has_archive_slug": "",
        "rewrite": {
            "permalink_rewrite": "post_type_key",
            "with_front": "1",
            "feeds": "0",
            "pages": "1"
        },
        "query_var": "post_type_key",
        "query_var_name": "",
        "can_export": true,
        "delete_with_user": false,
        "register_meta_box_cb": "",
        "modified": 1695644506
    }

    I’ve installed the plugin and this errors showed in archive page of a CPT.
    Doing debug the exception is due to this scenario

    // in /plugins/seo-by-rank-math/includes/opengraph/class-image.php 
    // line  602
    
    /**
       * Check if archive has an image and add this image.
       */
      private function set_archive_image() {
    
       // NOTE: 
       // request url: "my-site.com/my-cpt"
       // this url is the post archive page of "my-cpt"
    
        $post_type = get_query_var('post_type');
        
        // In my case, and i don't know why the returned value 
        // of "get_query_var" is not a string but an array of string 
        // $post_type = [ "my-cpt" ]
        // 
    
        // because of this in the next line (👇)
        // string interpolation  will fail
        // and trigger the exception "array to string conversion..." 
        //
        $image_id  = Helper::get_settings("titles.pt_{$post_type}_facebook_image_id");
        $this->add_image_by_id($image_id);
      }

    I modified the code like this and it works

    private function set_archive_image() {
        $post_type = get_query_var('post_type');
        
        // sometimes "post_type" returns array of string 
        // instead of string
        if (is_array($post_type)) $post_type = $post_type[0];
    
        $image_id  = Helper::get_settings("titles.pt_{$post_type}_facebook_image_id");
        $this->add_image_by_id($image_id);
      }

    But until you don’t include the same in the plugin code i cannot update it

Viewing 2 replies - 1 through 2 (of 2 total)