admin管理员组文章数量:1130349
I am trying to accomplish something.
First am using two themes on my blog, on the mobile theme which is carrington, i would love to add five posts from a certain category or tag for example "Tech" to the footer of the theme or immediately after the recent posts.
Update: what i think am trying to achieve is:
category archieve pages and tag archieves has the same design (css) as the homepage.
i just need to copy the design and contents of one category page archieve and place it in the footer section of my homepage.
Any help please
I am trying to accomplish something.
First am using two themes on my blog, on the mobile theme which is carrington, i would love to add five posts from a certain category or tag for example "Tech" to the footer of the theme or immediately after the recent posts.
Update: what i think am trying to achieve is:
category archieve pages and tag archieves has the same design (css) as the homepage.
i just need to copy the design and contents of one category page archieve and place it in the footer section of my homepage.
Any help please
Share Improve this question edited Mar 28, 2017 at 14:49 Tarrmie de Man asked Mar 24, 2017 at 8:11 Tarrmie de ManTarrmie de Man 431 silver badge7 bronze badges 03 Answers
Reset to default 1 $args = array(
'posts_per_page' => 5,
'cat' => 77 // 77 - id category
);
$query = new WP_Query( $args );
// loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
echo '<li>';
the_post_thumbnail();
echo '<a href="'.get_permalink().'">' . get_the_title() . '</a></li>';
}
} else {
// posts not fount
echo 'posts not fount';
}
wp_reset_postdata();
Replace the category id (77) with the id of the category you need. You need to add this code to the template. In the place where you want to display the records (for example: index.php).
<?php query_posts('category_name=xxxxxxxxxxxx&order=dsc&showposts=12'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<br clear="all"><br />
<?php endwhile; ?>
<?php endif; ?>
Here you see category_name=xxxxxxxxxxxx here change the xxxx to your category slug and you are done
my mission was achieved by using some part of the code suggested above.
I changed the xxxxx to my category slug then below that code i posted all of my loop and that was it.
So if you want it to have your post page design:
copy this
copy the whole of your loop and paste under and save
I am trying to accomplish something.
First am using two themes on my blog, on the mobile theme which is carrington, i would love to add five posts from a certain category or tag for example "Tech" to the footer of the theme or immediately after the recent posts.
Update: what i think am trying to achieve is:
category archieve pages and tag archieves has the same design (css) as the homepage.
i just need to copy the design and contents of one category page archieve and place it in the footer section of my homepage.
Any help please
I am trying to accomplish something.
First am using two themes on my blog, on the mobile theme which is carrington, i would love to add five posts from a certain category or tag for example "Tech" to the footer of the theme or immediately after the recent posts.
Update: what i think am trying to achieve is:
category archieve pages and tag archieves has the same design (css) as the homepage.
i just need to copy the design and contents of one category page archieve and place it in the footer section of my homepage.
Any help please
Share Improve this question edited Mar 28, 2017 at 14:49 Tarrmie de Man asked Mar 24, 2017 at 8:11 Tarrmie de ManTarrmie de Man 431 silver badge7 bronze badges 03 Answers
Reset to default 1 $args = array(
'posts_per_page' => 5,
'cat' => 77 // 77 - id category
);
$query = new WP_Query( $args );
// loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
echo '<li>';
the_post_thumbnail();
echo '<a href="'.get_permalink().'">' . get_the_title() . '</a></li>';
}
} else {
// posts not fount
echo 'posts not fount';
}
wp_reset_postdata();
Replace the category id (77) with the id of the category you need. You need to add this code to the template. In the place where you want to display the records (for example: index.php).
<?php query_posts('category_name=xxxxxxxxxxxx&order=dsc&showposts=12'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<br clear="all"><br />
<?php endwhile; ?>
<?php endif; ?>
Here you see category_name=xxxxxxxxxxxx here change the xxxx to your category slug and you are done
my mission was achieved by using some part of the code suggested above.
I changed the xxxxx to my category slug then below that code i posted all of my loop and that was it.
So if you want it to have your post page design:
copy this
copy the whole of your loop and paste under and save
本文标签: categoriesPosts from a category on homepage with category archieves page default css
版权声明:本文标题:categories - Posts from a category on homepage with category archieves page default css 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749252715a2339956.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论