Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter adrianistrate

    (@adrianistrate)

    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;
    //}
    Thread Starter adrianistrate

    (@adrianistrate)

    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:

    1. Download the plugin zip file
    2. Unzip de plugin
    3. Go to solid-post-likes\views and find SolidPostLikesPublic.php file
    4. Open the file with a text editor
    5. Go to oacs_spl_display_like_button function
    6. at the end of the function you will find an if statement that specify to show the button only on single posts.
    7. Comment that IF statement and instead of that simply return $output;
    8. Save the file
    9. Zip back the entire content
    10. 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.

    Thread Starter adrianistrate

    (@adrianistrate)

    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.

Viewing 3 replies - 1 through 3 (of 3 total)