Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter omoadrodel

    (@omoadrodel)

    Any response for this issue?

    Thread Starter omoadrodel

    (@omoadrodel)

    Still, not working I’m using an elementor plugin on my site https://www.screencast.com/t/MpdTibNOpG.

    Thread Starter omoadrodel

    (@omoadrodel)

    Yes I’m using the latest version on it. https://www.screencast.com/t/yL9k1jgnNF

    • This reply was modified 3 years, 10 months ago by omoadrodel.
    Thread Starter omoadrodel

    (@omoadrodel)

    is my code is still unreadable ?

    
    !*short code for display my testimonial post *!
    function testimonial(){
    $testimonial = ''; global $post;
    $args = get_posts( array('post_type' => 'testimonial', 'posts_per_page' => 2, 'page' => 1 ) );
    	foreach ($args as $post) {
    		$image = get_field('field_5d9668d733e48',$post);
    		$company = get_field('field_5d9668e633e4a',$post);
    		$site = get_field('field_5d9668f233e4b',$post);
    		$position = get_field('field_5d9668dd33e49',$post);
    		$content = get_field('field_5d9668b133e46',$post);
    		$title = get_field('field_5d967b46823eb',$post);
    		$testimonial .='
    		<div class="testimonial-container twelve columns">
    			<div class="four columns omega image box-container">
    				<img src="'.$image['url'].'" alt="'.$image['title'].'" />
    			</div>
    			<div class="twelve columns alpha info box-container">
    				<h4>'.$title.'</h4>
    				<p class="name">'.get_field('field_5d9668a833e45',$post).'</p>
    				<ul>
    					'.( $position != '' ? '<li>' . $position . '</li>' : '' ) .' 
    					'.( $company != '' ? '<li><a href="' .$site. '">' . $company . '</a></li>' : '' ) .'
    				</ul>
    				<div class="content twelve columns alpha">
    					<p>'.$content.'</p>
    				</div>
    			</div>
    		</div>
    		';
    	}
    	$testimonial .='
    	<div id="mypost"></div>
    	<div class="twelve columns bottom">
    		<p class="no-more-post"><strong>No More Post Found</strong></p>
    		<p><img src="'. get_stylesheet_directory_uri() . '/images/spinner.apng' .'" alt="spinner" /></p>
    		<button id="load_more">View More</button>
    	</div>';
    	wp_reset_postdata();
    	return $testimonial;
    }
    add_shortcode('testimonial','testimonial');
    
    !* the function for load more post
    function more_post_ajax(){
    global $wpdb;
        $ppp = (isset($_POST["ppp"])) ? $_POST["ppp"] : 3;
        $page = (isset($_POST['pageNumber'])) ? $_POST['pageNumber'] : 0;
        $args = array(
            'post_type' => 'testimonial',
            'posts_per_page' => $ppp,
            'paged'    => $page,
        );
    
        $loop = new WP_Query($args);
        if ($loop -> have_posts()) :  
        	while ($loop -> have_posts()) : $loop -> the_post();
          		$image = get_field('field_5d9668d733e48',$loop->ID);
    			$company = get_field('field_5d9668e633e4a',$loop->ID);
    			$site = get_field('field_5d9668f233e4b',$loop->ID);
    			$position = get_field('field_5d9668dd33e49',$loop->ID);
    			$content = get_field('field_5d9668b133e46',$loop->ID);
    			$title = get_field('field_5d967b46823eb',$loop->ID);
    			$name = get_field('field_5d9668a833e45',$loop->ID);
    
    			if( !empty($image) ){
    			$images = '<img src="'.$image['url'].'" alt="'.$image['title'].'" />';
    			}
    			else {
    				$images = '<img src="'.get_stylesheet_directory_uri() . '/images/default.png' .'" alt="'.$name.'" />';
    			}
    			 echo'
    			<div class="testimonial-container twelve columns">
    				<div class="four columns omega image box-container">
    					'.$images.'
    				</div>
    				<div class="twelve columns alpha info box-container">
    					<h4>'.$title.'</h4>
    					<p class="name">'.$name.'</p>
    					<ul>
    						'.( $position != '' ? '<li>' . $position . '</li>' : '' ) .' 
    						'.( $company != '' ? '<li><a href="' .$site. '">' . $company . '</a></li>' : '' ) .'
    					</ul>
    					<div class="content twelve columns alpha">
    						<p>'.$content.'</p>
    					</div>
    				</div>
    			</div>
    			';
        endwhile;
        endif;
        wp_reset_postdata();
        die();
    }
    
    add_action('wp_ajax_nopriv_more_post_ajax', 'more_post_ajax');
    add_action('wp_ajax_more_post_ajax', 'more_post_ajax');
    
    !* calling for ajax and js 
     function my_enqueue() {
    
        wp_enqueue_script('ajax-script', get_stylesheet_directory_uri() . '/loadmore.js', array('jquery'), '1.0.0', true );
    	wp_localize_script( 'ajax-script', 'ajax_posts', array(
    	    'ajax_url' => admin_url( 'admin-ajax.php' ),
    	    'noposts' => __('No older posts found', 'twentyfifteen'),
    	));
       
    }
    add_action( 'wp_enqueue_scripts', 'my_enqueue' );
    
    /* this is my ajax 
    var ppp = 10; // Post per page
    var pageNumber = 1;
    jQuery(document).ready(function($) {
        $('#load_more').on('click', function(){    
            $.ajax({
                url : ajax_posts.ajax_url,
                type: "POST",
                data : {
                    'action' : 'more_post_ajax',
                    'pageNumber' : pageNumber,
                    'ppp' : ppp,
                }
                ,beforeSend : function ( xhr ) {
                 $('.spinner-loading').fadeIn(1000); 
                  $("#load_more").fadeOut(100);
                },
                error: function(response) {
                    console.log(response);
                },
                success: function(response) {
                    var $response = $(response);
                    if($response.length){
                        $('#mypost').append($response);
                        $('.spinner-loading').fadeOut(100);
                        $("#load_more").fadeIn(500);
                        pageNumber++;  
                    }else{
                        $("#load_more").fadeOut(100);
                        $('.spinner-loading').css("display","none");
                        $(".no-more-post strong").fadeIn(1000).fadeOut(2000);
                        $(".no-more-post").css("padding-top","30px");
                    }
                }
            });
        });
    });

    can you help me how to work on it , or what should i change on this code?

    Thread Starter omoadrodel

    (@omoadrodel)

    Can you help me how to work on it @jdembowski i’m new on this . Thanks for reply. I already put and id in my button . <Button id=”load_more”>View More</Button>. It’s work but the existing post would display , i would like to display only the post that doesn’t display yet.

    Example
    Post1
    Post2
    When i click the button
    Post3
    Post4
    Should display only

    But on this code when i click the button the existing post1 and post2 will display also

    short code for display my post

    function testimonial(){
    $testimonial = ''; global $post;
    $args = get_posts( array('post_type' => 'testimonial', 'posts_per_page' => 2, 'page' => 1 ) );
    	foreach ($args as $post) {
    		$image = get_field('field_5d9668d733e48',$post);
    		$company = get_field('field_5d9668e633e4a',$post);
    		$site = get_field('field_5d9668f233e4b',$post);
    		$position = get_field('field_5d9668dd33e49',$post);
    		$content = get_field('field_5d9668b133e46',$post);
    		$title = get_field('field_5d967b46823eb',$post);
    		$testimonial .='
    		<div class="testimonial-container twelve columns">
    			<div class="four columns omega image box-container">
    				<img src="'.$image['url'].'" alt="'.$image['title'].'" />
    			</div>
    			<div class="twelve columns alpha info box-container">
    				<h4>'.$title.'</h4>
    				<p class="name">'.get_field('field_5d9668a833e45',$post).'</p>
    				<ul>
    					'.( $position != '' ? '<li>' . $position . '</li>' : '' ) .' 
    					'.( $company != '' ? '<li><a href="' .$site. '">' . $company . '</a></li>' : '' ) .'
    				</ul>
    				<div class="content twelve columns alpha">
    					<p>'.$content.'</p>
    				</div>
    			</div>
    		</div>
    		';
    	}
    	$testimonial .='
    	<div id="mypost"></div>
    	<div class="twelve columns bottom">
    		<p class="no-more-post"><strong>No More Post Found</strong></p>
    		<p><img src="'. get_stylesheet_directory_uri() . '/images/spinner.apng' .'" alt="spinner" /></p>
    		<button id="load_more">View More</button>
    	</div>';
    	wp_reset_postdata();
    	return $testimonial;
    }
    add_shortcode('testimonial','testimonial');
    
    !* the function for load more post
    function more_post_ajax(){
    global $wpdb;
        $ppp = (isset($_POST["ppp"])) ? $_POST["ppp"] : 3;
        $page = (isset($_POST['pageNumber'])) ? $_POST['pageNumber'] : 0;
        $args = array(
            'post_type' => 'testimonial',
            'posts_per_page' => $ppp,
            'paged'    => $page,
        );
    
        $loop = new WP_Query($args);
        if ($loop -> have_posts()) :  
        	while ($loop -> have_posts()) : $loop -> the_post();
          		$image = get_field('field_5d9668d733e48',$loop->ID);
    			$company = get_field('field_5d9668e633e4a',$loop->ID);
    			$site = get_field('field_5d9668f233e4b',$loop->ID);
    			$position = get_field('field_5d9668dd33e49',$loop->ID);
    			$content = get_field('field_5d9668b133e46',$loop->ID);
    			$title = get_field('field_5d967b46823eb',$loop->ID);
    			$name = get_field('field_5d9668a833e45',$loop->ID);
    
    			if( !empty($image) ){
    			$images = '<img src="'.$image['url'].'" alt="'.$image['title'].'" />';
    			}
    			else {
    				$images = '<img src="'.get_stylesheet_directory_uri() . '/images/default.png' .'" alt="'.$name.'" />';
    			}
    			 echo'
    			<div class="testimonial-container twelve columns">
    				<div class="four columns omega image box-container">
    					'.$images.'
    				</div>
    				<div class="twelve columns alpha info box-container">
    					<h4>'.$title.'</h4>
    					<p class="name">'.$name.'</p>
    					<ul>
    						'.( $position != '' ? '<li>' . $position . '</li>' : '' ) .' 
    						'.( $company != '' ? '<li><a href="' .$site. '">' . $company . '</a></li>' : '' ) .'
    					</ul>
    					<div class="content twelve columns alpha">
    						<p>'.$content.'</p>
    					</div>
    				</div>
    			</div>
    			';
        endwhile;
        endif;
        wp_reset_postdata();
        die();
    }
    
    add_action('wp_ajax_nopriv_more_post_ajax', 'more_post_ajax');
    add_action('wp_ajax_more_post_ajax', 'more_post_ajax');
    
    !* calling for ajax and js 
     function my_enqueue() {
    
        wp_enqueue_script('ajax-script', get_stylesheet_directory_uri() . '/loadmore.js', array('jquery'), '1.0.0', true );
    	wp_localize_script( 'ajax-script', 'ajax_posts', array(
    	    'ajax_url' => admin_url( 'admin-ajax.php' ),
    	    'noposts' => __('No older posts found', 'twentyfifteen'),
    	));
       
    }
    add_action( 'wp_enqueue_scripts', 'my_enqueue' );
    
    /* this is my ajax 
    var ppp = 10; // Post per page
    var pageNumber = 1;
    jQuery(document).ready(function($) {
        $('#load_more').on('click', function(){    
            $.ajax({
                url : ajax_posts.ajax_url,
                type: "POST",
                data : {
                    'action' : 'more_post_ajax',
                    'pageNumber' : pageNumber,
                    'ppp' : ppp,
                }
                ,beforeSend : function ( xhr ) {
                 $('.spinner-loading').fadeIn(1000); 
                  $("#load_more").fadeOut(100);
                },
                error: function(response) {
                    console.log(response);
                },
                success: function(response) {
                    var $response = $(response);
                    if($response.length){
                        $('#mypost').append($response);
                        $('.spinner-loading').fadeOut(100);
                        $("#load_more").fadeIn(500);
                        pageNumber++;  
                    }else{
                        $("#load_more").fadeOut(100);
                        $('.spinner-loading').css("display","none");
                        $(".no-more-post strong").fadeIn(1000).fadeOut(2000);
                        $(".no-more-post").css("padding-top","30px");
                    }
                }
            });
        });
    });
    • This reply was modified 6 years, 6 months ago by omoadrodel.
    • This reply was modified 6 years, 6 months ago by omoadrodel.
    • This reply was modified 6 years, 6 months ago by Jan Dembowski. Reason: Fixed formatting again. ;)
    Thread Starter omoadrodel

    (@omoadrodel)

    function more_post_ajax(){
    global $wpdb;
        $ppp = (isset($_POST["ppp"])) ? $_POST["ppp"] : 3;
        $page = (isset($_POST['pageNumber'])) ? $_POST['pageNumber'] : 0;
    	$cat = (isset($_POST['cat'])) ? $_POST['cat'] : '';
    
        $args = array(
            'post_type' => 'testimonial',
            'posts_per_page' => $ppp,
            'paged'    => $page,
            'cat' => $cat,
        );
    
        $loop = new WP_Query($args);
    
        $out = '';
    
        if ($loop -> have_posts()) :  while ($loop -> have_posts()) : $loop -> the_post();
            echo  '<div class="small-12 large-4 columns">
                    <h1>'.get_the_title().'</h1>
                    <p>'.get_the_content().'</p>
             </div>';
    
        endwhile;
        endif;
        wp_reset_postdata();
        die();
    } here's my load more function rather
    
    and my js 
    var ppp = 3; // Post per page
    var pageNumber = 1;
    var cat = 6;
    jQuery(document).ready(function($) {
        $('#load_more').on('click', function(){    
            $.ajax({
                url : ajax_posts.ajax_url,
                type: "POST",
                data : {
                    'action' : 'more_post_ajax',
                    'pageNumber' : pageNumber,
                    'ppp' : ppp,
                    'cat' : cat,
                }
                ,beforeSend : function ( xhr ) {
                 $('.spinner-loading').fadeIn(1000); 
                  $("#load_more").fadeOut(100);
                },
                error: function(response) {
                    console.log(response);
                },
                success: function(response) {
                    var $response = $(response);
                    if($response.length){
                        $('#mypost').append($response);
                        $('.spinner-loading').fadeOut(100);
                        $("#load_more").fadeIn(500);
                        pageNumber++;  
                    }else{
                        $("#load_more").fadeOut(100);
                        $('.spinner-loading').css("display","none");
                        $(".no-more-post strong").fadeIn(1000).fadeOut(2000);
                        $(".no-more-post").css("padding-top","30px");
                    }
                }
            });
        });
    });

    can you help me on this please Thanks

    • This reply was modified 6 years, 6 months ago by omoadrodel.
    • This reply was modified 6 years, 6 months ago by Jan Dembowski. Reason: Formatting
Viewing 6 replies - 1 through 6 (of 6 total)