Yep. But Another problem comes in….
I have register new sidebar and create new widget in order to display list of custom posts.
The widget displays only 10 posts (i have 17), and I did not set any limitation in wp_query…
Help?
class AllVideosWidget extends WP_Widget {
function __construct() {
// Instantiate the parent object
parent::__construct( false, 'All Videos Widget' );
}
// Widget output
$args = array(
'post_type' => 'video',
'post_status' => 'publish',
'category_name' => $a['category_name']
);
$query = new WP_Query($args);
if ($query->have_posts()) {
$string = '';
$counter = 0;
$video_list = array (
'video_title' => '',
'video_description' => '',
'video_url' => ''
);
while ($query->have_posts()) {
$query->the_post();
$video_title = get_field('video_title');
$video_description = get_field('video_description');
$video_url = get_field('video_url');
str_replace("watch?v=", "embed/", $video_url);
$video_list["video_title"][] = $video_title;
$video_list["video_description"][] = $video_description;
$video_list["video_url"][] = $video_url;
$counter++;
}// end while
} // end if have post
wp_reset_postdata();
$html = "<div class='widget widget_box_slide'>";
$html.='<h4 class="widget-title">All videos</h4>';
$html.='<div class="textwidget"><p>';
for ($i=0; $i < $counter ; $i++) {
$html.= "<a href="
. $video_list["video_url"][$i] .">"
. $video_list["video_title"][$i] . "</a><br>";
}
$html.='</p></div>';
$html.= "</div>";
echo $html;
}
function update( $new_instance, $old_instance ) {
// Save widget options
}
function form( $instance ) {
// Output admin widget options form
}
}