Saltar al contenido Saltar a la barra lateral

Este es el foro de soporte técnico de WPML, el plugin multilingüe de WordPress.

Todas las personas pueden leerlo pero solo los clientes de WPML pueden ingresar comentarios. El equipo de WPML responde en los foros 6 días a la semana, 22 horas por día.

Etiquetado: 

Este tema contiene 1 respuesta, tiene 2 voces.

Última actualización por Carlos Rojas hace 1 año, 10 meses.

Asistido por: Carlos Rojas.

Autor Publicaciones
noviembre 15, 2023 a las 2:56 pm #14810583

gustavoG-22

Estoy tratando de:

Obtener un Single Post usando su Slug con GraphQL

Ya probe la solucion que plantean en https://wpml.org/errata/wpml-graphql-fails-to-fetch-single-custom-post-type-by-slug-based/

pero continua sin funcionarme.

Este es mi query

query GetPost($slug: ID!) {
    post(id: $slug, idType: SLUG) {
        id
        date
        link
        title
        guid
        date
        seo {
            metaDesc
            metaKeywords
            metaRobotsNofollow
            metaRobotsNoindex
            schema {
                articleType
                pageType
            }
            title
            twitterDescription
            twitterImage {
                altText
                sourceUrl
            }
            twitterTitle
        }
        slug
        content
        tags {
            nodes {
                name
                uri
            }
        }
        featuredImage {
            node {
                altText
                sourceUrl
            }
        }
        translations {
            slug
            uri
        }
    }
}

Argumento en Ingles que devuelve Null

{
    "slug": "visas-for-traders-investors-and-businessmen-2"
}

Response

{
    "data": {
        "post": null
    },
    "extensions": {
        "debug": [],
        "queryAnalyzer": {
            "keys": "ab07eab1b95ff152ee3ea0820c2215b5854a2bb44aebace0f333f4d9a293fabd graphql:Query operation:GetPost",
            "keysLength": 96,
            "keysCount": 3,
            "skippedKeys": "",
            "skippedKeysSize": 0,
            "skippedKeysCount": 0,
            "skippedTypes": []
        }
    }
}

Argumento en Español que funciona correctamente

{
    "slug": "visas-para-comerciantes-inversionistas-y-hombres-de-negocios-2"
}

Response

{
    "data": {
        "post": {
            "id": "cG9zdDo1MTgxMg==",
            "date": "2023-09-20T15:07:45",
            "link": "<em><u>enlace oculto</u></em>",
            "title": "VISAS PARA COMERCIANTES ,INVERSIONISTAS Y HOMBRES DE NEGOCIOS.",
            "guid": "<em><u>enlace oculto</u></em>",
            "seo": {
                "metaDesc": "",
                "metaKeywords": "",
                "metaRobotsNofollow": "follow",
                "metaRobotsNoindex": "noindex",
                "schema": {
                    "articleType": [],
                    "pageType": [
                        "WebPage"
                    ]
                },
                "title": "VISAS PARA COMERCIANTES ,INVERSIONISTAS Y HOMBRES DE NEGOCIOS. - PFS Realty Group",
                "twitterDescription": "",
                "twitterImage": null,
                "twitterTitle": ""
            },
            "slug": "visas-para-comerciantes-inversionistas-y-hombres-de-negocios-2",
            "content": "......",
            "tags": {
                "nodes": []
            },
            "featuredImage": {
                "node": {
                    "altText": "VISAS PARA COMERCIANTES ,INVERSIONISTAS Y HOMBRES DE NEGOCIOS.",
                    "sourceUrl": "<em><u>enlace oculto</u></em>"
                }
            },
            "translations": [
                {
                    "slug": "visas-for-traders-investors-and-businessmen-2",
                    "uri": "/visas-for-traders-investors-and-businessmen-2?lang=en"
                }
            ]
        }
    },
    "extensions": {
        "debug": [],
        "queryAnalyzer": {
            "keys": "ab07eab1b95ff152ee3ea0820c2215b5854a2bb44aebace0f333f4d9a293fabd graphql:Query operation:GetPost cG9zdDo1MTgxMg== cG9zdDo1MTg1Ng==",
            "keysLength": 130,
            "keysCount": 5,
            "skippedKeys": "",
            "skippedKeysSize": 0,
            "skippedKeysCount": 0,
            "skippedTypes": []
        }
    }
}

Yo esperaba ver:

En vez de eso, obtuve:

noviembre 16, 2023 a las 9:38 am #14823777

Carlos Rojas
Partidario de WPML desde 03/2017

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/Madrid (GMT+02:00)

Hola,
Muchas gracias por contactarnos

He intentado verificar el contenido del slug de ejemplo, pero al parecer el idioma secundario está oculto. Por favor compruebe si el idioma secundario está oculto, y en caso de no estarlo le pido que comparta la URL del contenido que no puede obtener.

Saludos!