Title: Shortcode in a shortcode
Last modified: August 20, 2016

---

# Shortcode in a shortcode

 *  [Christopher Martin](https://wordpress.org/support/users/christopher-martin/)
 * (@christopher-martin)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/shortcode-in-a-shortcode-1/)
 * I am trying to get this working, but with real trouble – and have tried everything
   I can:
 * [wpv-view name=”MyViewName” taccnt =”[MyShortcode]”]
 * [MyShortcode] is working and standalone it returns ‘xyz’
 * The view shortcode is also working and if I change it to:
 * [wpv-view name=”MyViewName” taccnt =”xyz”]
 * then I get the expected output.
 * However when I have the full view as follows (shortcode in a shortcode):
 * [wpv-view name=”MyViewName” taccnt =”[MyShortcode]”]
 * then this is the exact output I get based on this example:
 * xyz “]
 * Additional Info. The [MyShortCode] returns the current taxonomy using this PHP
   and the Shortcode Exec plugin.
 * $term = get_term_by ( ‘slug’ ,get_query_var ( ‘term’ ),get_query_var ( ‘taxonomy’));
   
   echo $term->name;
 * I have also tried one shortcode like this:
 * $term = get_term_by ( ‘slug’ ,get_query_var ( ‘term’ ),get_query_var ( ‘taxonomy’));
   
   echo do_shortcode(‘[wpv-view name=”Taxonomy Content” taccnt =”echo $term->name;”]’);
 * But it doesn’t work… echo $term->name; returns the right term for the taxonomy(
   Deposit Match), but it doesn’t work in my shortcode (no posts found).
 * Whereas this:
 * $term = get_term_by ( ‘slug’ ,get_query_var ( ‘term’ ),get_query_var ( ‘taxonomy’));
   
   echo do_shortcode(‘[wpv-view name=”Taxonomy Content” taccnt =”Deposit Match”]’);
 * works perfectly… and returns the post required.
 * I have tried everything I can think of to get this working somehow. Please help!?

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

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/shortcode-in-a-shortcode-1/#post-3499719)
 * The shortcode parser does not accept square brackets within attributes:
    [http://codex.wordpress.org/Shortcode_API#Square_Brackets](http://codex.wordpress.org/Shortcode_API#Square_Brackets)
 * Try it with an enclosing shortcode, they allow for nested shortcodes that can
   be parsed with [do_shortcode()](http://codex.wordpress.org/Function_Reference/do_shortcode):
   
   [http://codex.wordpress.org/Shortcode_API#Enclosing_vs_self-closing_shortcodes](http://codex.wordpress.org/Shortcode_API#Enclosing_vs_self-closing_shortcodes).
 * Is there a reason you cannot just get the the term name in your first shortcode?
 * Can you show the full code off the callback functions for your shortcodes. See
   the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code) for 
   posting code
 *  Thread Starter [Christopher Martin](https://wordpress.org/support/users/christopher-martin/)
 * (@christopher-martin)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/shortcode-in-a-shortcode-1/#post-3499810)
 * Hi,
 * Thanks for the reply. Enclosing shortcodes aren’t supported with my shortcode…
   the second shortcode provides the taxonomy depending on which page is being displayed
   that is used as a variable in the shortcode, hence it only works as a shortcode
   in a shortcode…
 * I am using Types & Views (wp-types.com) and it doesn’t look like enclosing shortcodes
   would work.
 * Thanks

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

The topic ‘Shortcode in a shortcode’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Christopher Martin](https://wordpress.org/support/users/christopher-martin/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/shortcode-in-a-shortcode-1/#post-3499810)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
