[ad_1]
I have a custom page where I am loading in the posts via an Ajax call. I can see on the front end the shortcode is rendering the correct HTML but when I inspect it there are no styles being applied to it. I am assuming it has to do with my Ajax call as I have another static page with the same shortcode and it works fine.
This is the shortcode I am using:
<?php echo do_shortcode("[yasr_overall_rating size="small" postid='".get_the_ID()."']"); ?>This is the HTML being rendered from that shortcode:
<!--Yasr Overall Rating Shortcode-->
<div class="yasr-overall-rating">
<div class=" yasr-rater-stars" id="yasr-overall-rating-rater-5f2c365025414" data-rating="1.3" data-rater-starsize="16">
</div>
</div>
<!--End Yasr Overall Rating Shortcode-->My Ajax call:
jQuery(document).ready(function($) {
let offset = 0;
let isLoading = false;
let params = new URLSearchParams(window.location.search);
let initialSearchTerm = params.get('tool') || '';
$('#ai-tool-filter #search').val(initialSearchTerm);
function loadPosts(search = initialSearchTerm, sort="date", category = '', pricing = '') {
if(isLoading) return;
isLoading = true;
$('#loading-indicator').show();
$.ajax({
url: frontendajax.ajaxurl,
data: {
action: 'load_posts',
search: search,
sort: sort,
category: category,
pricing: pricing,
offset: offset
},
success: function(response) {
if(response.trim() !== "") {
if(offset === 0) {
$('#posts-container').html(response);
} else {
$('#posts-container').append(response);
}
offset += 12;
}
$('#loading-indicator').hide();
isLoading = false;
},
error: function() {
$('#loading-indicator').hide();
isLoading = false;
}
});
}
loadPosts(initialSearchTerm);
$(window).scroll(function() {
if ($(window).scrollTop() + $(window).height() > $('#posts-container').height() - 100) {
loadPosts($('#ai-tool-filter #search').val(), $('#ai-tool-filter #sort').val(), $('#ai-tool-filter #category').val(), $('#ai-tool-filter #pricing').val());
}
});
$('#ai-tool-filter #search').on('input', function() {
offset = 0;
loadPosts($(this).val(), $('#ai-tool-filter #sort').val(), $('#ai-tool-filter #category').val(), $('#ai-tool-filter #pricing').val());
});
$('#ai-tool-filter #sort, #ai-tool-filter #category, #ai-tool-filter #pricing').on('change', function() {
offset = 0;
loadPosts($('#ai-tool-filter #search').val(), $('#ai-tool-filter #sort').val(), $('#ai-tool-filter #category').val(), $('#ai-tool-filter #pricing').val());
});
$("#ai-tool-filter #category").selectize({
allowEmptyOption: true,
placeholder: 'All Categories',
onChange: function(value) {
offset = 0;
loadPosts($('#ai-tool-filter #search').val(), $('#ai-tool-filter #sort').val(), value, $('#ai-tool-filter #pricing').val());
}
});
});
