Title: PHP code (WITH tags)
Last modified: August 22, 2016

---

# PHP code (WITH tags)

 *  Resolved [Pete](https://wordpress.org/support/users/perthmetro/)
 * (@perthmetro)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/php-code-with-tags/)
 * I’d like this plugin to be able to accept php opening and closing tags.
 * Can this be an option or how would I edit this plugin to be able to accept php
   tags?
 * thanks
 * [https://wordpress.org/plugins/global-content-blocks/](https://wordpress.org/plugins/global-content-blocks/)

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

 *  Plugin Author [benz1](https://wordpress.org/support/users/benz1/)
 * (@benz1)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/php-code-with-tags/#post-5610449)
 * If you start your php block with a php closing tag (to close the embedded opening
   tag) and end the block with a starting tag (to open the embedded closing tag)
   then you should be able to put your complete php in between.
 *  Thread Starter [Pete](https://wordpress.org/support/users/perthmetro/)
 * (@perthmetro)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/php-code-with-tags/#post-5610453)
 * Unfortunately it doesn’t work…
    this is my code pasted directly into the template
   that works…
 *     ```
       <?php
       echo '<ul>';
       global $post;
       $taxonomy = 'category';
       // get the term IDs assigned to post.
       $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
       // separator between links
       $separator = ', ';
       if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) { $term_ids = implode( ',' , $post_terms ); wp_list_categories( 'title_li=&style=list&hierarchical=1&echo=1&taxonomy=' . $taxonomy . '&include=' . $term_ids ); }
       echo '</ul>';
       ?>
       ```
   
 * This is the code in your plugin that doesn’t work…
 *     ```
       ?>
       <?php
       echo '<ul>';
       global $post;
       $taxonomy = 'category';
       // get the term IDs assigned to post.
       $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
       // separator between links
       $separator = ', ';
       if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) { $term_ids = implode( ',' , $post_terms ); wp_list_categories( 'title_li=&style=list&hierarchical=1&echo=1&taxonomy=' . $taxonomy . '&include=' . $term_ids ); }
       echo '</ul>';
       ?>
       <?php
       ```
   
 *  Thread Starter [Pete](https://wordpress.org/support/users/perthmetro/)
 * (@perthmetro)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/php-code-with-tags/#post-5610454)
 * this works…
 *     ```
       ;?>
       <?php
       echo '<ul>';
       global $post;
       $taxonomy = 'category';
       // get the term IDs assigned to post.
       $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
       // separator between links
       $separator = ', ';
       if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) { $term_ids = implode( ',' , $post_terms ); wp_list_categories( 'title_li=&style=list&hierarchical=1&echo=1&taxonomy=' . $taxonomy . '&include=' . $term_ids ); }
       echo '</ul>';
       ?>
       <?php;
       ```
   

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

The topic ‘PHP code (WITH tags)’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/global-content-blocks_c8cac8.svg)
 * [Global Content Blocks](https://wordpress.org/plugins/global-content-blocks/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/global-content-blocks/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/global-content-blocks/)
 * [Active Topics](https://wordpress.org/support/plugin/global-content-blocks/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/global-content-blocks/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/global-content-blocks/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Pete](https://wordpress.org/support/users/perthmetro/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/php-code-with-tags/#post-5610454)
 * Status: resolved