Find out what page the category is using and add a div to the code that creates that box. Here is a reference to the Template Hierarchy that may help.
Thanks for your reply.
But with this method I’ll add the div on every category page, and not only in the category “Hand Out”..isn’t it?
Cause I just need to have the div in one specific category that is “Hand out”
If you only want to show it on a specific category, use the condition is_category.
YEP!
It’s working!
Huge thanks!
Can I decide to display an article inside the is_category function?
Because the layout that I would like is pretty the same of an article, and it’s easier to edit it by the Article page itself instead of coding.
I’m using this code
<?php if (is_category('6') || in_category('6')) { ?>
<?php query_posts('p=204'); ?>
<?php } ?>
You can do something like if you want one post to show:
$args = array(
'cat' => 6,
'posts_per_page' => '1'
);
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '
<li>' . get_the_title() . '</li>
';
}
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
http://codex.wordpress.org/Class_Reference/WP_Query
I really have to thank you for your time and help!
The above code is working but I’m just getting the title of the post without any style and content.
If you, for example, go here http://www.mille9e20.com/hand-out-1-bros/
you will see a white box with video and text.
That it’s a post that automatically get that style by CSS.
I would like to have the same box, from a certain post, that appears dynamically with the is_category function to show up the white box + content + style in a certain category.
Is it possible?
Really, thank you so much!
Try this:
$args = array(
'cat' => 6,
'posts_per_page' => '1'
);
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<div class="boxed">';
echo '<h1 class="post-header-title">' . get_the_title() . '</h1>';
echo get_the_content();
echo '</div>';
}
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
Yes!
Also this code works, but it doesn’t get the information from a ID post but, seems, from the post that I’ve in the same page.
What if, for example, would like to load that part of code/content, but from post_ID 123?
Anyway I have to thank you for everything!
You can do this but your now asking about a specific post which is different from asking for posts in a different category.
You can do try something like this:
$post = get_post(123);
$title = $post->post_title;
$content = $post->post_content;
echo '<div class="boxed">';
echo '<h1 class="post-header-title">' . $title . '</div>';
echo $content;
echo '</div>';