Title: Putting a shortcode into a PHP file
Last modified: August 24, 2016

---

# Putting a shortcode into a PHP file

 *  [qlddrones](https://wordpress.org/support/users/websupportguy/)
 * (@websupportguy)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/putting-a-shortcode-into-a-php-file/)
 * I am using Progress Maps plugin on my site and I want to add it to all blog listing
   pages so they display a map of the post locations by category automatically. 
   The author says this is possible but the code he provides to do it doesn’t work,
   so I wonder if anyone knows why it doesn’t work?
 * The shortcode when I use it in a widget looks like:
 * ‘[codespacing_progress_map map_id=”blogposts” post_type=”post” tax_query=”category{
   296|IN}”]’
 * This maps all the posts in category_ID=296.
 * To put it into archive.php so it gets the category_ID dynamically for each category,
   the author suggests adding the following code to /library/includes/blog_listing.
   php in my child theme:
 * ‘<div id=”top_map”>
    <?php $categories = get_the_category(); $category_id = $
   categories[0]->cat_ID; echo do_shortcode(‘[codespacing_progress_map post_type
   =”post” tax_query=”category{‘.$category_id.’|IN}”]’); ?> </div>’
 * But all this does is display every post in every category, so I’m assuming it’s
   not getting the current category_ID into the shortcode (because that’s what Progress
   Maps displays with no category filter in the shortcode).
 * I’m not a PHP coder so I don’t know where it’s going wrong. Can anyone help me
   to debug it?

The topic ‘Putting a shortcode into a PHP file’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [qlddrones](https://wordpress.org/support/users/websupportguy/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/putting-a-shortcode-into-a-php-file/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
