// Add Shortcode
function entradas_shortcode( $atts ) {
// Attributes
extract( shortcode_atts(
array(
'catId' => '',
), $atts )
);
// Code
// WP_Query arguments
$args = array (
'post_type' => 'post',
'post_status' => 'publish',
'cat' => $catId,
'order' => 'DESC',
'orderby' => 'date',
);
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) {
echo "<ul>";
while ( $query->have_posts() ) {
$query->the_post();
<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
}
echo "</ul>";
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
}
add_shortcode( 'post_titulo', 'entradas_shortcode' );