Me consta que probablemente sea un problema de devolución. Así que dividí el contenido, uno en una función llamada thelist
y el otro es una función real que lo devuelve. El código sigue la pregunta.Código corto que aparece en la parte superior del contenido en lugar de en el lugar donde lo necesito
El shortcode real funciona, excepto que el contenido aparece en la parte superior antes que el resto del contenido. Pensé que el retorno now_include_post
lo arreglaría, pero no es así. ¿Alguien puede ayudar?
function thelist() {
if (have_posts()) : while (have_posts()) : the_post();
?>
<div id="post-<?php the_ID(); ?>" <?php post_class('thumb'); ?>>
<a href="<?php the_permalink() ?>" class="thumb-link">
<?php
if (!post_password_required()) {
if (has_post_thumbnail()) {
the_post_thumbnail();
}
} else {
?>
<img src="<?php bloginfo('template_url') ?>/img/locked.png" />
<?php } ?>
</a>
<h2>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
</h2>
</div>
<?php /* end post */ ?>
<?php
endwhile;
endif;
wp_reset_query();
}
?>
<?php
function now_include_post($atts) {
$thepostid = intval($atts[id]);
query_posts("p=$thepostid");
$output .= thelist();
return $output;
}
Eso es realmente excepcional. ¡Muchas gracias por su ayuda y ese enlace! – user1368968
Es 2014 y después de 2 años tu respuesta sálvame :) ¡Gracias! –
Funciona para mí. Gracias –