I am creating wordpress loop to show only posts by specified ID's. I'd like admin to be bale to choose the ID's manually, so I created custom text widget where they can input posts ID's that they want to display. Now I'd like to pass that widget value into WP-Query, but instead of showing posts it only displays the three ID's as numbers. I tried the loop code with typed in ID's and it worked fine, why it doesn't work when I'm including the sidebar with widget? Could anyone help me how to sort this out?
That's the beginning of my query:
<?php
$from_widget = dynamic_sidebar( 'my-widget' );
$include_ids = array( $from_widget );
$query = new WP_Query( array( 'post__in' => $include_ids ) );
?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
....
Aucun commentaire:
Enregistrer un commentaire