Created
January 29, 2018 03:13
-
-
Save artemrogov/b217a472f38eda5b7a0373ac32966d78 to your computer and use it in GitHub Desktop.
add short code in cms wordpress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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