• I would like to make a premise: this, for me, is still one of the best plugins. I really hope that @satrya will return to deal with it.
    Anyway, after searching for a long time and asking countless times, I have developed a work around to be able to display the category. This solution is independent of the original plugin, it can be further customized without risking incompatibility.

    This solution is only possible using a child.

    Inside the functions.php I added the following code:

    // aggiungo categoria a RPWE
    function rpwe_custom_shortcode($atts) {
    // Attributi predefiniti
    $atts = shortcode_atts(
    array(
    'limit' => 5, // Numero massimo di articoli da mostrare
    'cat' => '', // ID della categoria
    'orderby' => 'date', // Ordine degli articoli
    'order' => 'DESC', // Ordine crescente o decrescente
    'excerpt' => false, // Mostra l'estratto (true/false)
    'length' => 20, // Lunghezza dell'estratto
    'thumb_width' => 150, // Larghezza della miniatura
    'thumb_height' => 150, // Altezza della miniatura
    'date' => false, // Mostra la data (true/false)
    'readmore' => false, // Mostra il pulsante "Leggi di più"
    'readmore_text' => 'Leggi di più', // Testo del pulsante
    ),
    $atts,
    'rpwe_custom'
    );

    // Costruzione degli argomenti della query
    $args = array(
    'posts_per_page' => intval($atts['limit']),
    'post_status' => 'publish',
    'orderby' => sanitize_text_field($atts['orderby']),
    'order' => sanitize_text_field($atts['order']),
    );

    // Filtro per categoria
    if (!empty($atts['cat'])) {
    $args['cat'] = intval($atts['cat']);
    }

    // Query personalizzata
    $query = new WP_Query($args);

    // Avvia il buffer per costruire l'output
    ob_start();

    if ($query->have_posts()) {
    echo '<ul class="rpwe-custom">';
    while ($query->have_posts()) {
    $query->the_post();

    echo '<li>';

    // Miniatura
    if (has_post_thumbnail()) {
    echo '<a href="' . get_permalink() . '">' . get_the_post_thumbnail(null, array($atts['thumb_width'], $atts['thumb_height'])) . '</a>';
    }

    // Titolo
    echo '<a href="' . get_permalink() . '">' . get_the_title() . '</a>';

    // Categoria
    $categories = get_the_category();
    if (!empty($categories)) {
    echo '<p class="rpwe-category"> ';
    foreach ($categories as $category) {
    echo '<a href="' . esc_url(get_category_link($category->term_id)) . '">' . esc_html($category->name) . '</a> ';
    }
    echo '</p>';
    }

    // Estratto
    if ($atts['excerpt']) {
    echo '<p class="rpwe-excerpt">' . wp_trim_words(get_the_excerpt(), intval($atts['length']), '...') . '</p>';
    }

    // Pulsante "Leggi di più"
    if ($atts['readmore']) {
    echo '<a class="rpwe-readmore" href="' . get_permalink() . '">' . esc_html($atts['readmore_text']) . '</a>';
    }

    echo '</li>';
    }
    echo '</ul>';
    } else {
    echo '<p>' . __('Nessun articolo trovato.', 'recent-posts-widget-extended') . '</p>';
    }

    // Ripristina il contesto globale
    wp_reset_postdata();

    return ob_get_clean();
    }
    add_shortcode('rpwe_custom', 'rpwe_custom_shortcode');

    Now you can use the new shortcode [rpwe_custom] with the additional parameters you want.

    ES:

    [rpwe_custom limit="1" cat="11" orderby="rand"]

    This solution worked for me.

  • You must be logged in to reply to this topic.