I am working on a webpage on Wordpress and I wanted to insert a slider with the posts from 6 blogs. The posts would be chosen by me, for that I am using Advanced Custom Fields plugin for that. The php part works properly, but I don't get the js working. Here is my html code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jquery.flexslider.js"></script>
<script>
$(window).load(function() {
$(".flexslider").flexslider({
animation: "slide",
});
});
</script>
Here is the html for the slider:
<div id="grey" class="row main-post">
<div class="flexslider">
<ul class="slides">
<?php
echo get_chosen_post();
echo get_chosen_post_1();
echo get_chosen_post_2();
?>
</ul>
</div>
</div>
And one of the functions for retrieving the posts from the fields:
function get_chosen_post() {
global $wpdb;
$post_title = get_field('post_title');
$blog = get_field('blog_number');
switch_to_blog( $blog );
$posts = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}posts WHERE post_type='post' AND post_status='publish' AND post_title LIKE '$post_title' LIMIT 1");
foreach($posts as $post) {
//Thumbnail
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large' );
$url = $thumb['0'];
$html .= '<div class="col-xs-12 col-sm-6 col-lg-4 mainpost "><div class="main-center"><a class="img-wrapper" href="'.get_permalink( $post->ID ).'"><img class="main-post-img" src="'.$url.'"></img></a></div></div>';
$html .= '<div class="col-xs-12 col-sm-6 col-lg-4 mainpost no-padding"><div class="main-center mobile-text-fix">';
//Title
$html .= '<h4><a href="'.get_permalink($post->ID).'" title="'.$post->post_title.'">'.$post->post_title.'</a></h4>';
//Excerpt
$html .= '<p>'.$post->post_excerpt.'</p>';
$html .= '</div></div>';
}
switch_to_blog(1);
return $html;
}
The query works fine, I use the LIKE statement to avoid errors if the post title contains quotes. My slider doesn't work, it just shows all the posts that I chose and the links to them, but no slider. I would appreciate your help, thank you!