Title: using shortcode in href under another shortcode
Last modified: September 30, 2021

---

# using shortcode in href under another shortcode

 *  [suman260](https://wordpress.org/support/users/suman260/)
 * (@suman260)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/using-shortcode-in-href-under-another-shortcode/)
 * I am using alike plugin to compare my custom post types and alike provide shortcode[
   alike_link] to run the procedure and I create shortcode to display my custom 
   post type In this shortcode I made anchor tag and I want to put alike shortcode
   in href but It’s not working you can see my code down bottom there is anchor 
   tag with href=”#” is there any solution?
 *     ```
       // function that runs when shortcode is called
   
       function wpb_demo_shortcode() {
       $html = '';
       $html .= '<div class="crypto-box">';
   
       $args = array( 'post_type' => 'Crypto Brokers', 'posts_per_page' => 10 );
       $the_query = new WP_Query( $args );
       if ( $the_query->have_posts() ) {
       while ( $the_query->have_posts() ) { $the_query->the_post();
       $html .= "<div class='crypto_content'>";
       $html .= "<div class='crypto_left'>";
       $html .= "<div class='crypto_img'>".get_the_post_thumbnail()."</div>";
       $html .= '<a href="'.get_the_permalink().'">'.get_field('review_button').'</a>';
       $html .= "</div>";
       $html .= "<div class='crypto_center'>";
       $html .= '<h4>'.get_the_title().'</h4>';
       $html .= "<p>".get_the_excerpt()."</p>";
       $html .= "</div>";
       $html .= "<div class='crypto_right'>";
       $html .= '<p><b>Location : </b>'.get_field('location').'</p>';
       $html .= '<p><b>Leverage : </b>'.get_field('leverage').'</p>';
       $html .= '<p><b>Deposit : </b>'.get_field('deposit').'</p>';
       $html .= '<p><b>Spreads : </b>'.get_field('spreads').'</p>';
       $html .= '<p><b>Instruments : </b>'.get_field('instruments').'</p>';
       $html .= '<p><b>Platforms : </b>'.get_field('platforms').'</p>';
       $html .= "</div>";
       $html .= '<a href="#" class="cp_btn">'.get_field('compare_button').'</a>';
       $html .= "</div>";
           };
           wp_reset_postdata();
       };
       $html .= '</div>';
   
       return $html;
       }
   
       // register shortcode
       add_shortcode('crypto', 'wpb_demo_shortcode');
       ```
   

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

 *  [Jacob Peattie](https://wordpress.org/support/users/jakept/)
 * (@jakept)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/using-shortcode-in-href-under-another-shortcode/#post-14924123)
 * You can run shortcodes in PHP with the `apply_shortcodes()` function:
 * `
    $html .= ‘[‘.get_field(‘compare_button’).’](https://wordpress.org/support/topic/using-shortcode-in-href-under-another-shortcode/&apos; . apply_shortcodes( &apos;[alike_link]&apos; ) . &apos;?output_format=md)‘;
 *  Thread Starter [suman260](https://wordpress.org/support/users/suman260/)
 * (@suman260)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/using-shortcode-in-href-under-another-shortcode/#post-14924322)
 * can I put shortcode in href using this function

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

The topic ‘using shortcode in href under another shortcode’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [suman260](https://wordpress.org/support/users/suman260/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/using-shortcode-in-href-under-another-shortcode/#post-14924322)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
