tienduydng
Forum Replies Created
-
Forum: Hacks
In reply to: Get popular custom post type post by viewsThanks Clarion for your words with my heart!
I found my problem. Because i use “pre_get_post”
$query->set(‘orderby’,’modified’);
I am so crazy!!
Thanks Clarion again. Nice to meet you.Forum: Hacks
In reply to: Get popular custom post type post by viewsLet me explain more detail.
The result show:product title 1 (2 view)
product title 2 (1 view)
product title 3 (5 view)
product title 4 (8 view)
product title 5 (3 view)But i need result.
product title 4 (8 view)
product title 3 (5 view)
product title 5 (3 view)
product title 1 (2 view)
product title 2 (1 view)I just want to sort by views
Forum: Hacks
In reply to: Get popular custom post type post by viewsoh. Thanks Clarion for your reply.
function wp_set_post_views($postID) {
…
}
//To keep the count accurate, lets get rid of prefetching
remove_action( ‘wp_head’, ‘adjacent_posts_rel_link_wp_head’, 10, 0);
//show view
function wp_get_post_views($postID){
…
}
I put two above functions in function.php.and below code i put in sidebar.php
<?php
//////////this is my code to get list by views:
$arg = array(
“post_type” => “product”,
“posts_per_page” => 10,
“meta_key” => “wpb_post_views_count”,
“orderby” => “meta_value_num”,
“order” => “DESC”,
);
$query = new wp_query($arg);
if($query->have_posts()) :
while($query->have_posts()) : $query->the_post();
the_title();
echo ‘(‘.wp_get_post_views(get_the_ID()).’)’;
endwhile;
endif;
?>
In index.php I get_sidebar();
So where is problem. Thanks.Forum: Hacks
In reply to: Get popular custom post type post by viewsno one can help me
Forum: Fixing WordPress
In reply to: Updating string in mysqlNo one can help me?
Forum: Plugins
In reply to: Redirect users after booking (Booking System Pro)coated_pill. How could you do that! Can you share to me. Thanks so much.
Forum: Plugins
In reply to: [Polylang] Multi menu in PolylangOk thanks Chrystl, may be my english so bad.
Let me explain more detail i mean.
I use Polylang plugin to create multi language site.
I create menu header name: “menu_header” for Vietnames language and “menu_header_en” for english lamguage.
In header.php file i use code:<?php wp_nav_menu( array( 'menu'=>'', 'container'=>'', 'theme_location' => 'primary' ) );Its work. I mean it can auto change language when i change language site.
Now ! I create menu footer name: “menu_footer” for Vietnames language and “menu_footer_en” for English language. And in footer.php file I use code.<?php wp_nav_menu( array( 'menu'=>'menu_footer', 'container' =>'', 'theme_location' => 'primary' ) );It doesn’t auto change to english when i change language site to English.
What wrong. How can I fix it! Thanks so much !Forum: Themes and Templates
In reply to: [Moesia] Menu bar not alignedIn your theme:
<div class=”site-branding col-md-4″></div>
<nav id=”site-navigation” class=”main-navigation col-md-8″ role=”navigation”></nav>
Try to replace: ‘col-md-4; and ‘col-md-8’ by ‘row’
In class .site-branding in style.css file replace
.site-branding{float: left; padding: 40px 15px;} by .site-branding{text-align:center}
.main-navigation li{replace float:left by display: inline-block;}.main-navigation {
display: block;
float: left;
}
change to
.main-navigation{ text-align: center; }I hope it helpful with you !
Forum: Themes and Templates
In reply to: [Elucidate] header image too small on mobile formatYou can use css.
ex: #header img{max-width: 100%; min-width: 50%, 70%…certain size}
Hope can help you !Forum: Themes and Templates
In reply to: Get all images attachment in a postAnybody can help me ! please.
Forum: Themes and Templates
In reply to: [Customizr] Header image repeatingbackground: url(http://www.mydomain.com/image.png) no-repeat top center;
Forum: Fixing WordPress
In reply to: Can't display custom fieldMy custom field: key: Giá value: 120000
I want to get value 120000 and display on index page.Forum: Fixing WordPress
In reply to: Can't display custom fieldThis is code in index.php. It doesn’t work.
get_header(); ?>
<div class=”spnoibat”></div>
<div class=”leftpanel”>
<?php include ‘sanpham.php’; ?>
</div>
<div id=”content” class=”site-content” role=”main”>
<?php /* The loop */ ?>
<?php
$arg = array(
‘post_type’ => ‘post’
);
$query = new $wp_query($arg);
while($query->have_posts()): $query->the_post();?>
<div class=”loadcontent”>
<div class=”hinh”>“><?php echo the_post_thumbnail();?></div>
<div class=”info”>“><?php the_title(); ?>
<?php echo get_post_meta(get_the_ID(),’Giá’,true); ?></div>
</div>
<?php endwhile; ?>
</div><!– #content –>And this is code in category.php. It work !
get_header(); ?>
<div class=”spnoibat”></div>
<div class=”menunav”>
<?php
//get id of current category
$id = get_query_var(‘cat’);
// get category parent
$nav = get_category_parents($id,true,'<span class=”navi”></span>’);?>
“>Trang chủ<span class=”navi”><?php echo $nav;?></span>
</div>
<div class=”leftpanel”>
<?php include ‘sanpham.php’; ?>
</div>
<div id=”content” class=”site-content” role=”main”>
<?php while ( have_posts() ) : the_post(); ?>
<div class=”loadcontent”>
<div class=”hinh”>“><?php the_post_thumbnail();?></div>
<div class=”info”>“><?php the_title(); ?>
<?php echo get_post_meta(get_the_ID(),’Giá’,true); ?></div>
</div>
<?php endwhile; ?></div><!– #content –>