-
-
Save lamsmallari/3e6592dfb9eef93ce127a186f2db8074 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
/** | |
* Get all type posts | |
* | |
* @return void | |
* @author alispx | |
**/ | |
function alispx_get_type_posts_data( $post_type = 'post' ) { | |
$posts = get_posts( array( | |
'posts_per_page' => -1, | |
'post_type' => $post_type, | |
)); | |
$result = array(); | |
foreach ( $posts as $post ) { | |
$result[] = array( | |
'value' => $post->ID, | |
'label' => $post->post_title, | |
); | |
} | |
return $result; | |
} | |
add_action( 'vc_before_init', 'alispx_post_finder_integrateWithVC' ); | |
function alispx_post_finder_integrateWithVC() { | |
vc_map( array( | |
'name' => esc_html__( 'Alispx Post Finder', 'alispx' ), | |
'base' => 'alispx_post_finder', | |
'class' => 'alispx-ico', | |
'icon' => 'alispx-ico', | |
'category' => esc_html__( 'Features', 'alispx' ), | |
'admin_enqueue_css' => array( get_template_directory_uri . '/your-path/alispxvc.css' ), | |
'description' => esc_html__( 'Alispx Post Finder', 'alispx' ), | |
'params' => array( | |
array( | |
'type' => 'autocomplete', | |
'class' => '', | |
'heading' => esc_html__( 'Post Name', 'alispx' ), | |
'param_name' => 'id', | |
'settings' => array( 'values' => alispx_get_type_posts_data() ), | |
), | |
) | |
) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment