Site logo

Archived topic

Añadir script a cada entrada de WordPress

18 replies · Started by jmpefe78gmail-com on December 26, 2018

Viewing posts 1–15 of 19

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

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

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';
} );

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

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

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

Try this:

add_filter( 'generate_article_itemtype', function( $type ) {
    if ( is_single() ) {
        return 'BlogPosting';
    }
} );

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.

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

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.

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

¿Otra solución? Gracias

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' );

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?

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.

This archived topic is closed to new replies.