[Support request] Añadir script a cada entrada de WordPress

Home Forums Support [Support request] Añadir script a cada entrada de WordPress

Home Forums Support Añadir script a cada entrada de WordPress

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #765681
    jmpefe78gmail-com

    Hola, necesito insertar el dato estructurado “article” y algunos otros de forma individual a cada entrada de WordPress

    ¿Cómo puedo meter con Generatepress códigos scripts de forma individual para cada entrada?

    Gracias

    #765977
    jmpefe78gmail-com

    ¿Por qué Generapress no usa ni article ni blogposting en el marcado de datos del post?

    #765986
    Tom
    Lead Developer
    Lead Developer

    BlogPosting requires some fields that we don’t provide by default, so we default to CreativeWork for now.

    You can change it to BlogPosting like this:

    add_filter( 'generate_article_itemtype', function( $type ) {
        return 'BlogPosting';
    } );
    #766001
    jmpefe78gmail-com

    Ok, ¿es mejor creative work que article? ¿Qué diferencia hay? gracias Tom

    #766016
    jmpefe78gmail-com

    Y disculpa de nuevo, ¿dónde tengo que insertar ese código? ¿Y no es mejor usar article en vez de “blogposting” ?

    #766024
    jmpefe78gmail-com

    He metido ese código en el funtions php pero no es lo que quiero, yo solo quiero que article sea para los post del blog no para la home y demás páginas

    #766069
    Leo
    Staff
    Customer Support

    Try this:

    add_filter( 'generate_article_itemtype', function( $type ) {
        if ( is_single() ) {
            return 'BlogPosting';
        }
    } );
    #766079
    jmpefe78gmail-com

    Genera errores ese código al usar el probado de datos estructurados tanto en las páginas como en los post.

    ¿Qué puedo hacer? creo que usar article es importante para el SEO.

    #766148
    jmpefe78gmail-com

    A ver si podéis darme otra solución ya que ese código genera errores!

    #766328
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Try this instead:

    add_filter( 'generate_article_itemtype', function( $type ) {
        if ( 'post' === get_post_type() ) {
            return 'BlogPosting';
        }
    
        return $type;
    } );

    The type you use depends on your content. You can definitely use Article instead if that suits your content better.

    #766364
    jmpefe78gmail-com

    Este último código genera un error y una advertencia:
    publisher MISSING_FIELD_WITHOUT_TYPE
    [object Object]:mainEntityOfPage MIS

    #766806
    jmpefe78gmail-com

    ¿Otra solución? Gracias

    #766807
    Tom
    Lead Developer
    Lead Developer

    Yes – that’s one of the reasons we use CreativeWork by default. You’ll also need a publisher value set with a logo.

    If you’re not super familiar with schema.org, it may be better to disable the GP microdata and use a JSON-LD plugin.

    That will give you more options/instructions.

    To disable the default schema, you can add this PHP:

    add_filter( 'generate_schema_type', '__return_false' );

    #766817
    jmpefe78gmail-com

    No es mi idea, me gusta el marcado que tiene Generatepress y no estoy muy familiarizado con el código pero pero creo que usar article es fundamental. ¿No hay otra opción?

    #766846
    Tom
    Lead Developer
    Lead Developer

    In order to change the schema type in GP, you would need to understand the schema type you are changing to and what’s required to add/remove within your content.

    In some cases, it’s easier to go with a JSON-LD plugin that does that kind of stuff for you, unless you know exactly what you need to add/remove.

Viewing 15 posts - 1 through 15 (of 19 total)
  • You must be logged in to reply to this topic.