Site logo

Archived topic

Excluir Autores de Elements

11 replies · Started by Francisco on March 23, 2022

Viewing posts 1–12 of 12

Hola...
Estoy creando un Elements tipo Hook para una caja de autor, pero no encuentro como excluir las entradas o post por autores para que esta caja sólo aparezca en la entrada o post del autor. Quiero crear Elements para cada autor para tener un diseño muy personalizado para cada uno. ¿Esto se puede hacer?

Gracias por la respuesta.
Lamentablemente no puedo ejecutar las acciones que indica Tom en su respuesta. Mis conocimientos técnicos son muy básicos.
¿Podría ayudarme con algún contenido visual que me indique como realizar el proceso? o ¿alguna información que me ayude a entender los conceptos que requiero para realizar esta tarea con éxito?

Muchas gracias.

1. Go to your element editor, leave the location field empty, get the element ID from the URL:
https://www.screencast.com/t/OAzQut54

2. You can find author id in the URL as well:
https://www.screencast.com/t/3UlBqlcxcrH7

3. Add PHP code to your site, replace 1234/5678with your element ID, replace 123/456 with your author id.

add_filter( 'generate_element_display', function( $display, $element_id ) {
    $author = get_post_field( 'post_author', get_the_ID() );
    if ( 1234 === $element_id && '123' === $author ) {
        $display = true;
    }
    if ( 5678 === $element_id && '456' === $author ) {
        $display = true;
    }

    return $display;
}, 10, 2 );

You can either add the code to your child theme's functions.php file or install and activate a plugin called Code Snippet, create a new snippet, copy and paste the code into it, save and activate the snippet.
https://www.screencast.com/t/MEFAbZj9

Ah I see, if it's from a plugin, we can't control where it shows Unfortuanly.

You'll need to contact the plugin author in this case.

El plugin lo tengo temporal en lo que resuelvo que elements funcione.
Quiero que el Element que se muestre al final del post con el autor correspondiente y las últimos Post del blog.
He seguido las instrucciones que me proporciona pero algo parece no estar funcionando bien.

Volveré a revisar los pasos.
Agradezco mucho el soporte, siempre ha sido de gran ayuda.

He realizado los cambios que me indica pero me da el siguiente error:

Los cambios en tu código PHP se han revertido debido a un error en la línea 18 del archivo wp-content/themes/generatepress_child/functions.php. Por favor, arréglalo y trata de guardar de nuevo.

Uncaught ArgumentCountError: Too few arguments to function {closure}(), 1 passed in wp-includes/class-wp-hook.php on line 309 and exactly 2 expected in wp-content/themes/generatepress_child/functions.php:18
Stack trace:
#0 wp-includes/class-wp-hook.php(309): {closure}(false)
#1 wp-includes/plugin.php(189): WP_Hook->apply_filters(false, Array)
#2 wp-content/plugins/gp-premium/elements/class-layout.php(241): apply_filters('generate_elemen...', false, 17655)
#3 wp-content/plugins/gp-premium/elements/elements.php(71): GeneratePress_Site_Layout->__construct(17655)
#4 wp-includes/class-wp-hook.php(307): generate_premium_do_elements(Object(WP_Screen))
#5 wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array)
#6 wp-includes/plugin.php(474): WP_Hook->do_action(Array)
#7 wp-admin/includes/class-wp-screen.php(421): do_action('current_screen', Object(WP_Screen))
#8 wp-admin/includes/screen.php(243): WP_Screen->set_current_screen()
#9 wp-admin/admin.php(212): set_current_screen()
#10 wp-admin/theme-editor.php(10): require_once('/home2/francis7...')
#11 {main}
thrown

Very glad to hear that :)

This archived topic is closed to new replies.