Thêm tên class vào <body> trong magento (How to add class into body in magento)
Muốn thêm tên class vào body của 1 trang nào đó ví dụ trang customer.
mở file layout : customer.xml
chèn vào đoạn code :
<reference name="root">
<action method="addBodyClass"><classname>customers-profile</classname></action>
</reference>
trong đó customers-profile: là tên class mới thêm vào <body>
Thứ Ba, 8 tháng 7, 2014
Thứ Hai, 30 tháng 12, 2013
Phân trang trong wordpress
Phân trang
Dùng hàm paginate_links() có sẵn trong wordpress
<ul>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => 1,
'category_name' => 'cong-nghe',
'paged' => $paged,
);
$the_query = new WP_Query($args);
while ($the_query->have_posts()):$the_query->the_post();
echo ' <li>';
echo ' <div class="title"> ';
the_title();
echo '</div>';
echo ' <div class="img">';
the_post_thumbnail();
echo '</div>';
echo ' <div class="content">';
echo get_the_content();
echo '</div>';
echo '</li>';
endwhile;
$big = 999999999; // need an unlikely integer
echo paginate_links(array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'total' => $the_query->max_num_pages));
?>
</ul>
Chủ Nhật, 29 tháng 12, 2013
Hiển thị bài viết ngẫu nhiên trong wordpress
Hiển thị bài viết ngẫu nhiên trong wordpress dùng thuộc thính 'orderby' => 'rand'
// hiển thị 5 bài viết ngẫu nhiên
<?php
global $post;
$args = array('numberposts' => 5, 'category_name' => 'thiet-bi-ho-tro', 'orderby' => 'rand');
$posts = get_posts($args);
foreach ($posts as $post): setup_postdata($post);?>
// Echo nội dung
.......................
<?php endforeach ?>
// hiển thị 5 bài viết ngẫu nhiên
<?php
global $post;
$args = array('numberposts' => 5, 'category_name' => 'thiet-bi-ho-tro', 'orderby' => 'rand');
$posts = get_posts($args);
foreach ($posts as $post): setup_postdata($post);?>
// Echo nội dung
.......................
<?php endforeach ?>
Hiển thị nội dung của các trang và bài viết
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile;?>
<?php the_content(); ?>
<?php endwhile;?>
Loại bỏ các thẻ html có trong chuỗi dữ liệu
dùng hàm strip_tags để bỏ đi các thẻ html có trong chuỗi khi hiển thị lên web
strip_tags($chuỗi);
strip_tags($chuỗi);
Đăng ký:
Bài đăng (Atom)