• Hello, I would like to use custom posts, I tried something like this, but it doesn’t work, can you help me? I thank you, great plugin

    
    
    <?php
    global $post;
     
    $posts = wpp_get_mostpopular( array(
       'limit'     => 10,
       'post_type' => 'post',
       'range'     => 'last24hours',
    ) );
     
    echo '<ul>';
     
    if ( count( $posts ) > 0 ):
       foreach ( $posts as $the_post ):
          setup_postdata( $the_post );
    ?>
     
       <li><a href="<?php the_permalink() ?>" title="<?php echo esc_attr( get_the_title() ); ?>"><?php the_title(); ?></a></li>
     
    <?php
       endforeach;
    endif;
     
    echo '</ul>';
     
    wp_reset_postdata();
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @tom2,

    All you need to do is pass your custom post type to the post_type parameter, like this for example:

    
    <?php
    $args = array(
        'post_type' => 'post, page, your-custom-post-type-here' // comma separated
    );
    
    wpp_get_mostpopular($args);
    ?>
    Thread Starter erismarcds

    (@tom2)

    I would like to add thumbnail and manual title, but it shows what comes in the plug-in ‘<ul class = “wpp-list”>’, if you want to send my site, I don’t know much about PHP. Pardon my English.

    <?php
    $args = array(
        'post_type' => 'post, page, <div class="img" style="background-image:url(<?php echo get_the_post_thumbnail_url( $post_id, 'large' ); ?>);">	</div>' // comma separated
    );
    
    wpp_get_mostpopular($args);
    ?>
    
    Plugin Author Hector Cabrera

    (@hcabrera)

    Alright, try this:

    <?php
    $args = array(
        'limit' => 10,
        'range' => 'last24hours',
        'post_type' => 'your-custom-post-type-here',
        'thumbnail_width' => 100,
        'thumbnail_height' = 100,
        'post_html' => '<div class="img" style="background-image:url({thumb_url});">Your Custom Title Here (eg. {text_title})</div>'
    );
    wpp_get_mostpopular($args);
    ?>

    Things you need to change:

    • The width & height of the background image (see thumbnail_width and thumbnail_height).
    • The name of your custom post type (see post_type).
    • The actual HTML structure of each of your popular posts (see post_html)

    Friendly advice: you should consider spending some more time learning PHP and WordPress Development in general if you want to code stuff on your own. Alternatively, hiring a more experience developer is also an option if you don’t have time to learn (eg. you have a deadline ahead.)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Post Types’ is closed to new replies.