• Resolved s7e7v7e7n7

    (@s7e7v7e7n7)


    Hello guys,

    First thanks. This plugins working awesome….

    Now i have a question. Sorry i dont know much php.

    Normally i use post pages this code

    <div class="thumbnails">
    
    	<div class="wrap1">
    	<div class="wrap2">
    	<div class="ubar"><?php
    $thetitle = $post->post_title; /* or you can use get_the_title() */
    $getlength = strlen($thetitle);
    $thelength = 30;
    echo substr($thetitle, 0, $thelength);
    if ($getlength > $thelength) echo "...";
    ?></div>
    
    			<a href="<?php the_permalink(); ?>" target="_blank" itemprop="url"><img src="<?php echo wp_get_attachment_thumb_url( get_post_thumbnail_id( $post->ID ) ); ?>" onload="this.style.opacity='1'" class="thumbnail" alt="<?php the_title(); ?>" title="<?php the_title(); ?> Wallpaper" itemprop="thumbnailUrl" width="300" height="200"> </a>
    
         <div class="bbar">
    <?php $attachment_id = get_post_thumbnail_id(); $image_attributes = wp_get_attachment_image_src( $attachment_id, 'full' );if( $image_attributes ) {?>
    <?php $width = $image_attributes[1]; $height = $image_attributes[2]; ?>
    <?php } ?>
    <?php $fsize = filesize(get_attached_file($attachment_id));$file_size = round($fsize/1024);echo '' . $width. 'x' . $height . ' px';?>
    &nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;
    <?php echo getPostViews(get_the_ID());?> hits</div>
    	</div>
    	</div>
    
    		</div>

    Now i turned this plugin code like this;

    <?php wpp_get_mostpopular( 'range=monthly&limit=40&thumbnail_width=300&thumbnail_height=200&post_type=post&post_html="
    <a href=\'{url}\'>
    <div class=\'thumbnails\'>
    
    	<div class=\'wrap2\'>
    <div class=\'ubar\' style=\'color: #fff;max-width: 300px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;\'>
    {text_title}
    </div>
    {thumb_img}
    </div>
    </div></a>"' ); ?>

    But i cant use php codes. how can i use php in “post_html=”

    Sorry my english not great. Hope understand me…

    thank you very much…

    https://www.ads-software.com/plugins/wordpress-popular-posts/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi there!

    What exactly are you trying to do?

    Thread Starter s7e7v7e7n7

    (@s7e7v7e7n7)

    Hello Hector,

    Thanks for answer.

    Actually i want use php codes in this code. Like this; (please look div class=”ubar”)

    <?php wpp_get_mostpopular( 'range=monthly&limit=40&thumbnail_width=300&thumbnail_height=200&post_type=post&post_html="
    <a href=\'{url}\'>
    <div class=\'thumbnails\'>
    
    	<div class=\'wrap2\'>
    <div class="ubar"><?php
    $thetitle = $post->post_title; /* or you can use get_the_title() */
    $getlength = strlen($thetitle);
    $thelength = 30;
    echo substr($thetitle, 0, $thelength);
    if ($getlength > $thelength) echo "...";
    ?></div>
    {text_title}
    </div>
    {thumb_img}
    </div>
    </div></a>"' ); ?>

    How can work php in this code? This is possible?

    Plugin Author Hector Cabrera

    (@hcabrera)

    The post title is already being printed with {text_title}, you don’t really need to use $post->post_title.

    If all you want is to shorten the post title, then use the title_length parameter:

    <?php
    wpp_get_mostpopular( 'range=monthly&limit=40&thumbnail_width=300&thumbnail_height=200&title_length=30&post_type=post&post_html="
    <a href=\'{url}\'>
    <div class=\'thumbnails\'>
    
    	<div class=\'wrap2\'>
    <div class="ubar">{text_title}</div>
    </div>
    {thumb_img}
    </div>
    </div></a>"' );
    ?>
    Thread Starter s7e7v7e7n7

    (@s7e7v7e7n7)

    Hector so sorry my english not great. You dont understand me.

    Juset test document. Yes i know {text_title} printed post title.

    I need use some php codes. Like this ;

    <?php wpp_get_mostpopular( 'range=monthly&limit=40&thumbnail_width=300&thumbnail_height=200&post_type=post&post_html="
    <a href=\'{url}\'>
    <div class=\'thumbnails\'>
    
    	<div class=\'wrap2\'>
    <div class=\'ubar\' style=\'color: #fff;max-width: 300px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;\'>
    {text_title}
    </div>
    {thumb_img}
      <div class="bbar">
    <?php $attachment_id = get_post_thumbnail_id(); $image_attributes = wp_get_attachment_image_src( $attachment_id, 'full' );if( $image_attributes ) {?>
    <?php $width = $image_attributes[1]; $height = $image_attributes[2]; ?>
    <?php } ?>
    <?php $fsize = filesize(get_attached_file($attachment_id));$file_size = round($fsize/1024);echo '' . $width. 'x' . $height . ' px';?>
    &nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;
    <?php echo getPostViews(get_the_ID());?> hits</div>
    </div>
    </div></a>"' ); ?>

    (this php codes show image dimensions and etc…)

    Now i use php in bbar div.

    Im just wondering, can i use php codes in post_html= ?

    Plugin Author Hector Cabrera

    (@hcabrera)

    Nope, the post_html parameter isn’t intended for that.

    In your case, you’ll want to use either the wpp_custom_html filter hook or the wpp_post filter hook to do what you need.

    Thread Starter s7e7v7e7n7

    (@s7e7v7e7n7)

    thank you Hector.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘how can i use php’ is closed to new replies.