0

//Use: [find_shortcodes code=[gravityform id="8" title="true"]]
add_shortcode('find_shortcodes', 'find_shortcode_pages');
function find_shortcode_pages($atts){
 $atts = shortcode_atts(
    array(
     'code' => '',
    ),
    $atts,
    'show_post'
   );
 $code = $atts['code'];
    $query = new WP_Query( "s='$code'&posts_per_page=-1" );
    $arr = array();
    if ($query->have_posts()){
      while ( $query->have_posts() ) { $query->the_post();
        $arr[] = '<strong>ID:</strong> '.get_the_ID().' <strong>Title:</strong> '.get_the_title().'<br>';
      } 
    }
    //return json_encode($arr);
    return implode(" ",$arr);
}

Jagdish Sarma Edited question April 6, 2023
Add a Comment