Tuan_H
(Tuan H)
1
add_action('wp_footer','readmore_postcontent');
function readmore_postcontent(){
?>
<style>
/*.single-product div#tab-description {
overflow: hidden;
position: relative;
}*/
/*.single-product .tab-panels div#tab-description.panel:not(.active) {
height: 0 !important;
}*/
.readmore_postcontent {
text-align: center;
cursor: pointer;
position: absolute;
z-index: 9999;
bottom: 0;
width: 100%;
background: #fff;
}
.readmore_postcontent:before {
height: 55px;
margin-top: -45px;
content: -webkit-gradient(linear,0% 100%,0% 0%,from(#fff),color-stop(.2,#fff),to(rgba(242,133,31,0)));
display: block;
}
.readmore_postcontent a {
color: white;
display: block;
background-color: #00BCD4;
padding: 10px;
margin: 10px;
}
.readmore_postcontent a:after {
content: '';
width: 0;
right: 0;
border-top: 6px solid white;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
display: inline-block;
vertical-align: middle;
margin: -2px 0 0 5px;
}
.entry-content.clearfix.single-post-content.tooglereadmore {
height: 400px;
overflow: hidden;
position: relative;
}
</style>
<script>
(function($){
$(document).ready(function(){
$(window).load(function(){
if($('.entry-content.single-post-content').length > 0){ //thay .entry-content.single-post-content bằng class tương ứng bao post content của bạn
var wrap = $('.entry-content.single-post-content'); //thay .entry-content.single-post-content bằng class tương ứng bao post content của bạn
var dodai_post = wrap.height(); //lấy độ dài post
var dodai_max = 800;
if(dodai_post > dodai_max){ //kiểm tra dodai_post lớn hơn dodai_max(800) không
wrap.addClass('tooglereadmore');
wrap.append(function(){
return '<div class="readmore_postcontent"><a title="Xem thêm" href="javascript:void(0);">Xem thêm</a></div>';
});
$('body').on('click','.readmore_postcontent', function(){ //hiển thị toàn bài khi click vào nút xem thêm
wrap.removeClass('tooglereadmore');
$('body .readmore_postcontent').remove();
});
}
}
});
})
})(jQuery)
</script>
<?php
}