Skip to content

Instantly share code, notes, and snippets.

@artemrogov
Created January 29, 2018 03:13
Show Gist options
  • Save artemrogov/b217a472f38eda5b7a0373ac32966d78 to your computer and use it in GitHub Desktop.
Save artemrogov/b217a472f38eda5b7a0373ac32966d78 to your computer and use it in GitHub Desktop.
add short code in cms wordpress
wpcf7_add_shortcode("pages","page_handler");
function page_handler(){
$html = ' ';
$posts = get_posts(array(
'showposts'=>12,
'post_type' => 'our-doctor',
'order'=>'ASC',
'order_by' => 'date'
));
if ($posts):
$html = '<select name = "pages">';
if (isset($_GET['vrach'])){
$vrach = $_GET['vrach'];
$html.='<option value="'.$vrach.'" selected>'.$vrach. '</option>';
}
else if (empty($vrach) && !isset($_GET['vrach'])){
?>
<?php
foreach($posts as $post){
$html .= '<option value="'.$post->post_title.'">'.$post->post_title. '</option>';
}
}
$html .= '</select>';
endif;
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment