Title: Category shortcode question.
Last modified: August 19, 2016

---

# Category shortcode question.

 *  [jayce103](https://wordpress.org/support/users/jayce103/)
 * (@jayce103)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/category-shortcode-question/)
 * If I wanted a certain category to be included on a page is there a short code
   that I code use???
 * For example
 * [category_posts id=123]
 * Or even php in the header or html section?
 * I know that the code above is not right and way off hence why I am asking.
 * Jayce

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [Dave Redfern](https://wordpress.org/support/users/daveredfern/)
 * (@daveredfern)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/category-shortcode-question/#post-1615559)
 * If you wish to hard code it into the templates you can us WP_Query ([http://codex.wordpress.org/Function_Reference/WP_Query](http://codex.wordpress.org/Function_Reference/WP_Query))
   inside any php file in your themes folder. Here is an example of it in practice:
 *     ```
       <?php
       	$args=array(
       		'cat' => 1
       	);
       	$the_query = new WP_Query($args);
       	while ($the_query->have_posts()) : $the_query->the_post();
       ?>
           <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
       <?php
       	endwhile;
       ?>
       ```
   
 * For a full list of options you can put inside the array i recommend checking 
   out query_posts ([http://codex.wordpress.org/Function_Reference/query_posts](http://codex.wordpress.org/Function_Reference/query_posts)).
 * You can use this code inside the admin but it requires a plugin to enable you
   to process php inside a post called exec-php ([http://wordpress.org/extend/plugins/exec-php/](http://wordpress.org/extend/plugins/exec-php/)).
 * Thanks
 * Dave.
 *  Thread Starter [jayce103](https://wordpress.org/support/users/jayce103/)
 * (@jayce103)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/category-shortcode-question/#post-1615641)
 * Hi Dave,
 * Thanks for that! I have got the plugin installed and the code on the page, and
   although it works it creates a list of posts in a category rather than show the
   posts in full.
 * Is this due to the php code above of the css styling of a theme?
 * Thanks again for your help.
 *  [Dave Redfern](https://wordpress.org/support/users/daveredfern/)
 * (@daveredfern)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/category-shortcode-question/#post-1615657)
 * Hello again,
 * In this instance you can modify anything inside the while() to suit what you 
   wish to display. You can using any tags you would see in the template files such
   as the_permalink, the_title, the_excerpt, the_content, the_date, the_time. In
   your Instance I think you’re looking for something similar to the below.
 *     ```
       <?php
       	$args=array(
       		'cat' => 1
       	);
       	$the_query = new WP_Query($args);
       	while ($the_query->have_posts()) : $the_query->the_post();
       ?>
       	<div class="post">
       		<h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
       		<?php the_content(); ?>
       	</div>
       <?php
       	endwhile;
       ?>
       ```
   
 * You can checkout the following links for more information about templating.
 * [http://codex.wordpress.org/The_Loop](http://codex.wordpress.org/The_Loop)
    [http://codex.wordpress.org/Stepping_Into_Templates](http://codex.wordpress.org/Stepping_Into_Templates)
   [http://codex.wordpress.org/Template_Tags](http://codex.wordpress.org/Template_Tags)
 * Thanks
 * Dave.
 *  Thread Starter [jayce103](https://wordpress.org/support/users/jayce103/)
 * (@jayce103)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/category-shortcode-question/#post-1615735)
 * Thanks for the quick reply Dave. I will give it ago over the next day or too.
 * Cheers buddy,
 * Jayce
 *  Thread Starter [jayce103](https://wordpress.org/support/users/jayce103/)
 * (@jayce103)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/category-shortcode-question/#post-1615736)
 * Just one little quicky!!!!
 * Using the code above works, but it puts the full posts in the section. Is it 
   possible to selct category instead so it shows the overview (don’t really know
   what to call it).
 * IE
 * If I click on a category in the widget it takes me to a category overview with
   the posts in a short format below that. I can then click on a post to view the
   full version.
 * Hope this makes sense.
 * Jayce
 *  Thread Starter [jayce103](https://wordpress.org/support/users/jayce103/)
 * (@jayce103)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/category-shortcode-question/#post-1615737)
 * *UPDATE*
 * It does show all posts in a certain category but it shows the entire post instead
   of the normal way..
 * [http://phototraining(](http://phototraining().)tv/news
 * This is the normal styling.
 * [http://phototraining(](http://phototraining().)tv/testpage
 * This is using the code Dave supplied
 *  [chinmoy29](https://wordpress.org/support/users/chinmoy/)
 * (@chinmoy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/category-shortcode-question/#post-1615738)
 * use <?php the_excerpt() ?> instead of <?php the_content() ?>
 *  Thread Starter [jayce103](https://wordpress.org/support/users/jayce103/)
 * (@jayce103)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/category-shortcode-question/#post-1615740)
 * [@dave](https://wordpress.org/support/users/dave/)
 * Thanks for this buddy, it works a treat!!!
 * [@chinmoy](https://wordpress.org/support/users/chinmoy/)
 * Thank you for the addition, that also worked.
 * Jayce
 *  [orgspirit](https://wordpress.org/support/users/orgspirit/)
 * (@orgspirit)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/category-shortcode-question/#post-1615748)
 * chinmoy29
 * Hi!Sorry that I’m writing not related text,but I really need your help!)I didn’t
   know how to contact with you..Can you please reply to my question on my topic
   at
    [http://wordpress.org/support/topic/make-div-on-static-page-for-latest-post?replies=7](http://wordpress.org/support/topic/make-div-on-static-page-for-latest-post?replies=7)
   Thank you very much!

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Category shortcode question.’ is closed to new replies.

## Tags

 * [categories](https://wordpress.org/support/topic-tag/categories/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 9 replies
 * 4 participants
 * Last reply from: [orgspirit](https://wordpress.org/support/users/orgspirit/)
 * Last activity: [15 years, 8 months ago](https://wordpress.org/support/topic/category-shortcode-question/#post-1615748)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
