Support » Plugin: WordPress Popular Posts » Summary, Date and Categories not showing up

  • Resolved talitakorb

    (@talitakorb)


    Hello,

    For some reason that I don’t know, the tags {summary}, {author}, {date} and categories are not showing up, but other tags like url, thumb_url or title are good.

    My code:

    <?php if ( function_exists('wpp_get_mostpopular') ) {
    
    $args = array(
    'post_html' => '
    <article class="post item">
    <a href="{url}">
    <figure class="thumb" style="background-image: url({thumb_url})">                        
    </figure>
    </a>                   
    <header class="header-posts"> 
    <div class="data-autor">
    {date} - Por {author}
    </div>
    
    <div class="categoria">{category}</div>  
    
    <a href="{url}"><h1 class="h1-post">{text_title}</h1></a>
    </header> 
    
    <div class="excerpt">{summary}</div>
    </article>',        
    'range' => 'last30days',
    'limit' => 12,
    'order_by' => 'views',
    'post_type' => 'post',
    'thumbnail_width' => 500,
    'thumbnail_height' => 400,
    'wpp_start' => '<div class="wrap-posts slide-pesquisados" id="slide-pesquisados">',
    
    );
    wpp_get_mostpopular( $args );
    
    }
    ?>

    Can you help me solve this?

    Thanks!

    • This topic was modified 1 month, 3 weeks ago by talitakorb.
    • This topic was modified 1 month, 3 weeks ago by talitakorb.
    • This topic was modified 1 month, 3 weeks ago by talitakorb.
    • This topic was modified 1 month, 3 weeks ago by talitakorb.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Héctor Cabrera

    (@hcabrera)

    Hi @talitakorb,

    Could you please edit your comment and use the code button to format your code? Otherwise the format gets all messed up (as you can probably tell :P) and I can’t tell what’s what. (Alternatively you can also use pastebin.com.)

    Thanks in advance!

    Thread Starter talitakorb

    (@talitakorb)

    Oh, sorry about that. Fixed!

    Thread Starter talitakorb

    (@talitakorb)

    Explaining better: I tried to use shortcode and all the codes I found but the excerpt, date, author and categories do not appear. The code is not inside the loop, and my WP version is the last one (5.6.2). I also tried to disable some plugins, but it didn’t work well.

    Plugin Author Héctor Cabrera

    (@hcabrera)

    Alright, that helped!

    So, from the documentation:

    {summary} (returns post/page excerpt, and requires excerpt_length to be greater than 0)

    {author} (returns linked author name, requires stats_author=1)

    {date} (returns post/page date, requires stats_date=1)

    {category} (returns linked category name, requires stats_category=1)

    The reason none of the mentioned content tags are working for you is that you’re not using the required parameters 😛

    Here’s the updated code including said missing parameters:

    <?php
    if ( function_exists('wpp_get_mostpopular') ) {
    
        $args = array(
            'post_html' => '
                <article class="post item">
                    <a href="{url}">
                        <figure class="thumb" style="background-image: url({thumb_url})"></figure>
                    </a>
                    <header class="header-posts">
                        <div class="data-autor">
                            {date} - Por {author}
                        </div>
    
                        <div class="categoria">{category}</div>
    
                        <a href="{url}"><h1 class="h1-post">{text_title}</h1></a>
                    </header>
                    <div class="excerpt">{summary}</div>
                </article>',
            'range' => 'last30days',
            'limit' => 12,
            'order_by' => 'views',
            'post_type' => 'post',
            'thumbnail_width' => 500,
            'thumbnail_height' => 400,
            'excerpt_length' => 25, /* adjust this as needed */
            'stats_author' => 1,
            'stats_category' => 1,
            'stats_date' => 1,
            'wpp_start' => '<div class="wrap-posts slide-pesquisados" id="slide-pesquisados">',
        );
        wpp_get_mostpopular( $args );
    
    }
    ?>

    And, in case you’re curious, here’s the shortcode version:

    [wpp range='last30days' limit=12 order_by='views' post_type='post' thumbnail_width=500 thumbnail_height=400 excerpt_length=25 stats_author=1 stats_category=1 stats_date=1 wpp_start='<div class="wrap-posts slide-pesquisados" id="slide-pesquisados">' post_html='<article class="post item"><a href="{url}"><figure class="thumb" style="background-image: url({thumb_url})"></figure></a><header class="header-posts"><div class="data-autor">{date} - Por {author}</div><div class="categoria">{category}</div><a href="{url}"><h1 class="h1-post">{text_title}</h1></a></header><div class="excerpt">{summary}</div></article>']

    Thread Starter talitakorb

    (@talitakorb)

    Thank you so much for your quickly answer! I’ve wasted hours trying to make this code to work! Now everything is working perfectly. Thank you very much!

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.