I can't get the titles of my custom post.
this is what i'm doing:
//IN functions.php
function fluid_scripts() {
wp_enqueue_script('lateral-fluid', get_template_directory_uri().'/js/lateral-fluid.js', array('jquery'));
wp_localize_script( 'lateral-fluid', 'ajaxFluid', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));
}
add_action('init', 'create_post_type');
function create_post_type(){
resgister_post_type ( 'portfolio',
array (
'labels' => array(
'name' => __('beds'),
'singular_name' => __('bed')
),
'public' => true,
'has_archive' => true,
)
);
}
add_action( 'wp_ajax_nopriv_lateral_fluid', 'my_lateral_fluid' );
add_action( 'wp_ajax_lateral_fluid', 'my_lateral_fluid' );
function my_lateral_fluid() {
//echo "test";
$args = array(
"post_type" => "portfolio",
"posts_per_page" => -1
);
$portfolio_query = new WP_Query($args);
while($portfolio_query->have_post() ){
$portfolio_query->the_post();
echo "<li>" . get_the_title() . "</li>";
}
wp_die();
}
I check in my admin-ajax.php url with my action: http://localhost/wordpress/wp-admin/admin-ajax.php?action=lateral_fluid, and it didn't display anything. If I uncomment //echo "test"; it display test. I already add 5 custom-post with their titles.
Why I don't get the titles of my custom-post (portfolio). What I'am missing?
Thanks in advanced