קוד שמוצא את כל הפוסטים שיש בהם שורטקוד מסויים
function wpb_find_shortcode($atts, $content=null) {
ob_start();
extract( shortcode_atts( array(
'find' => '',
), $atts ) );
$string = $atts['find'];
$args = array(
's' => $string,
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php
}
echo '</ul>';
} else {
echo "Sorry no posts found";
}
מכניסים ל functions וקוראים לו מפוסט בשורטקוד
[shortcodefinder find="some_shortcode"]
ואז הוא מציג לך את כל הפוסטים שיש בהם את השורטקוד some_shortcode