Hi @adrianistrate,
Thanks for reaching out! Could you share your function here? We will try and make it run.
There is no option planned for this yet.
This will always need custom code currently.
Kind regards,
Hello there!
Sure, below is the function that I use, with a template to display the rezults
function filter_projects() {
$catSlug = $_POST['category'];
$ajaxposts = new WP_Query([
'post_type' => 'post',
'posts_per_page' => -1,
'category_name' => $catSlug,
'orderby' => 'menu_order',
'order' => 'desc',
]);
$article_list = '';
if($ajaxposts->have_posts()) {
while($ajaxposts->have_posts()) : $ajaxposts->the_post();
$article_list = get_template_part('templates/project-list-item');
endwhile;
} else {
//$response = 'No posts found…';
//echo $newsletter_top;
exit;
}
echo $article_list;
exit;
}
add_action('wp_ajax_filter_projects', 'filter_projects');
add_action('wp_ajax_nopriv_filter_projects', 'filter_projects');
And project-list-item looks like this
<?php
$image_arr = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'medium_large');
$image_url = $image_arr[0];
$categories_arr = get_the_category(get_the_ID());
$categorie = $categories_arr[0]->cat_name;
?>
<li>
<div class="blog_home_item_container">
<span class="blog_home_post_category"><?= $categorie; ?></span>
<img src="<?= $image_url; ?>" alt="post_image" onclick="location.href='<?= get_permalink() ?>';"/>
<div class="blog_home_item_text">
<label class="blog_home_post_date">
<i aria-hidden="true" class="fas fa-calendar"></i>
<?= get_the_date(); ?>
</label>
<strong class="blog_home_post_title" onclick="location.href='<?= get_permalink() ?>';"><?= the_title(); ?></strong>
<!--<span class="blog_home_post_exerpt"><?= get_the_excerpt(); ?></span>-->
<div class="blog_home_post_info">
<div class="blog_home_post_stats">
<span class="blog_home_post_views"><i aria-hidden="true" class="far fa-eye"></i> <?= do_shortcode('[post-views]'); ?></span>
<span class="blog_home_post_comments"><i class="far fa-comment"></i><?= get_comments_number(get_the_ID()); ?></span>
</div>
<div>
<span><?= do_shortcode('[oacsspl]'); ?></span>
</div>
</div>
</div>
</div>
</li>
I would like to mention that I use the same template in a very similar script that I wrote with Code Snippets and the shortcode works there. The problem seems to be when I filter posts with the function located in functions.php file.
Gin
(@rawdolphe)
Hi, I have a ‘similar’ but much simpler problem with the 2024 Theme:
In my case the shortcode icon is NOT displayed in the Query Loop / Archives, BUT it works fine in the Single Post—either via the shortcode or when added automatically before / after the Content.
Please make it work, thank you 🙂
Yours sincerely,
Gin
Hi @gin
I solved my problem (and pretty sure will work for yours too) by making a change in one of the php files from the plugin.
My complete step by step solution:
- Download the plugin zip file
- Unzip de plugin
- Go to solid-post-likes\views and find SolidPostLikesPublic.php file
- Open the file with a text editor
- Go to oacs_spl_display_like_button function
- at the end of the function you will find an if statement that specify to show the button only on single posts.
- Comment that IF statement and instead of that simply return $output;
- Save the file
- Zip back the entire content
- Upload the new zip archive into your wordpress site
As fas as I’m concerned, my problem was solved and from this point of view I will mark this thread as rezolved.
Gin
(@rawdolphe)
Hi @adrianistrate,
Thank you, very much appreciatted.
Can you please tell me what to enter exactly in part 7 (what does the line of code look like)?
7. Comment that IF statement and instead of that simply return $output;
Thank you,
Gin
Gin
(@rawdolphe)
Something like that?
/** General output */
if ($oacs_spl_show_likes_setting) {
// only show on single posts.
//if(is_singular()) {
return $output;
}
} else {
// and not on archive pages.
return;
}
}
Gin
(@rawdolphe)
Actually, the above returned a fatal error, so I tried the following and now I get a triplicate heart icon, AND it selects / deselects all the posts in the query loop.
/** General output */
if ($oacs_spl_show_likes_setting) {
// only show on single posts.
//if(is_singular()) {
return $output;
}
//} else {
// and not on archive pages.
//return;
//}
}
No worries @adrianistrate, thank you again for your time – I’ll wait for an update and will keep looking for a suitable plugin. It’s just a question of time because many years ago there were many options out there. I don’t know what happened…. 😛 We need a simple bookmark / favorite plugin for Gutenberg!
Yours sincerely,
Gin
Hi @gin
A triplicate heart icon, funny, this is something I haven’t thought about :))
Actually on step 7 you need to comment the entire IF statement and instead of that if, above of it, return the output.
Here is how it looks and works on my end
$oacs_spl_show_likes_setting = carbon_get_theme_option('oacs_spl_show_likes');
return $output;
/** General output */
//if ($oacs_spl_show_likes_setting) {
// // only show on single posts.
// if(is_singular()) {
// return $output;
// }
//} else {
//// and not on archive pages.
// return;
//}
Gin
(@rawdolphe)
Thanks @adrianistrate,
Well, it made no difference; same as before, if you click on a heart it selects all the hearts in the page, then I get a triplicate – which goes away when I refresh the page :), regardless, all hearts are selected in the Query Loop / Archive template.