How can i do it work?
-
Hello, I need the ajax loader just in my categories, I’ve created my shortcode:
[ajax_load_more post_type="post, page" category="autotech,lajme,magazina,shneta,sport" button_label="Shfleto m? shum?" button_loading_label="Duke u ngarkuar..." container_type="ul"]
But where must i place it?
-
For categories you would add the shortcode to your archive page.. category.php or archive.php.
In the plugin, there is an example section showing you exactly how to implement with categories.
Where must i put the shortcode exactly in category.php ?
I’ve put it here
$category = get_the_category(); $category_id = ''; if( isset($category[0]->cat_ID) ){ $category_id = esc_attr( $category[0]->cat_ID ); } [ajax_load_more post_type="post, page" category="autotech,lajme,magazina,shneta,sport" button_label="Shfleto m? shum?" button_loading_label="Duke u ngarkuar..." container_type="ul"] ?>
But it is not working
Did you check out the examples section in the plugin admin? You need to pass the category dynamically.
Yes i’ve checked them but i don’t get it where do put my shortcode exactly in category.php
Here is my category code
<?php get_header(); global $themeum_options; ?> <section id="main"> <?php get_template_part('lib/sub-header')?> <div class="container"> <div class="row"> <div id="content" class="site-content col-md-9" role="main"> <?php global $themeum_options; $count = $themeum_options['slide-number']; $count_post = $themeum_options['post-number']; if (!is_numeric($count)) { $count = 6; } if (!is_numeric($count_post)) { $count_post = 6; } $style = ''; if( !isset($themeum_options['style-select']) ){ $style = 'style1'; }else{ $style = esc_attr( $themeum_options['style-select'] ); } $category = get_the_category(); $category_id = ''; if( isset($category[0]->cat_ID) ){ $category_id = esc_attr( $category[0]->cat_ID ); } ?> <div id="themeum-carousel" class="carousel slide" data-ride="carousel"> <ol class="carousel-indicators"> <?php $args = array( 'cat' => $category_id, 'meta_key' => 'thm_featured', 'meta_value' => '1', 'posts_per_page' => $count ); $query = new WP_Query( $args ); $i=0; while ( $query->have_posts() ) : $query->the_post(); if( $i==0 ){ echo '<li data-target="#themeum-carousel" data-slide-to="'.$i.'" class="active"></li>'; }else{ echo '<li data-target="#themeum-carousel" data-slide-to="'.$i.'"></li>'; } $i++; endwhile; wp_reset_postdata(); ?> </ol> <div class="carousel-inner" role="listbox"> <?php $i=0; while ( $query->have_posts() ) : $query->the_post(); $image =''; if ( has_post_thumbnail() ) { $img = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'newedge-thumb' ); $image ='style="height:537px;background: url('.esc_url($img[0]).') no-repeat;background-size: cover;"'; }else { $image ='style="height:537px;background: #333;"'; } $post_data = ''; $post_color = ''; if(rwmb_meta("thm_post_color") != "" ){ $post_color = rwmb_meta("thm_post_color"); } $post_data .= '<div class="themeum-latest-featured-post-item common-post-item">'; $post_data .= '<div class="overlay '.esc_attr( $post_color ).' yes"></div>'; $post_data .= '<div class="common-post-item-in" '.$image.'></div>'; $post_data .= themeum_social_share( get_the_ID() ); $post_data .= themeum_bookmark_button( get_the_ID() ); $post_data .= '<div class="common-post-item-intro">'; $post_data .= '<span class="entry-category '.themeum_rnd_cat_color().'">'; $post_data .= '</span>'; $post_data .= '<h3 class="entry-title"><a href="'.get_permalink().'">'. get_the_title() .'</a></h3>'; $post_data .= '</div>';//common-post-item-intro $post_data .= '</div>';//common-post-item if( $i==0 ){ echo '<div class="item active">'; echo $post_data; echo '</div>'; }else{ echo '<div class="item">'; echo $post_data; echo '</div>'; } $i++; endwhile; wp_reset_postdata(); ?> </div> </div> <?php $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; $args = array( 'category' => $category_id, 'posts_per_page' => $count_post, 'paged' => $paged, 'post_status' => 'publish' ); $posts = get_posts($args); $output = ''; if ($style == 'style1') { if(count($posts)>0){ $output .= '<div id="themeum-area" class="lates-featured-post">'; $j=1; $x=0; $total_post = count($posts); foreach ($posts as $key=>$post): setup_postdata($post); // post overlay color $post_color = ''; if(rwmb_meta("thm_post_color") != "" ){ $post_color = rwmb_meta("thm_post_color"); }else{ $post_color = 'black'; } if( $j==1 || $x == 3 ){ $output .= '<div class="row">'; $x=0; } $output .= '<div class="latest-featured-post-small col-sm-4">'; if ( has_post_thumbnail() ) { $img = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'newedge-small' ); $image ='style="height:253px;background: url('.esc_url($img[0]).') no-repeat;background-size: cover;"'; } else { $image ='style="height:253px;background: #333;"'; } $output .= '<div class="themeum-latest-featured-post-item common-post-item">'; $output .= '<div class="overlay '.esc_attr( $post_color ).' yes"></div>'; $output .= '<div class="common-post-item-in" '.$image.'></div>'; $output .= themeum_social_share( get_the_ID() ); $output .= themeum_bookmark_button( get_the_ID() ); $output .= '<div class="common-post-item-intro">'; $output .= '<span class="entry-category '.themeum_rnd_cat_color().'">'; $output .= '</span>'; $output .= '<h3 class="entry-title"><a href="'.get_permalink().'">'. get_the_title() .'</a></h3>'; $output .= '</div>';//common-post-item-intro $output .= '</div>';//common-post-item $output .= '</div>'; //latest-featured-post-small if( $x == 2 || $total_post == $j ){ $output .= '</div>'; //row global $themeum_options; if( $themeum_options['category-ads'] == 1){ if (function_exists('themeum_advertiser')) { if( $themeum_options['category-slug'] == '' ){ $output .= '<div class="cat-add">'; $output .= themeum_advertiser('themeumall'); $output .= '</div>'; }else{ $output .= '<div class="cat-add">'; $output .= themeum_advertiser( $themeum_options['category-slug'] ); $output .= '</div>'; } } } } $x++; $j++; endforeach; wp_reset_postdata(); $output .= '</div>'; //lates-featured-post } } elseif ($style == 'style2') { if(count($posts)>0){ $output .= '<div class="lates-featured-post">'; $j=1; $x=0; $total_post = count($posts); foreach ($posts as $key=>$post): setup_postdata($post); // post overlay color $post_color = ''; if(rwmb_meta("thm_post_color") != "" ){ $post_color = rwmb_meta("thm_post_color"); }else{ $post_color = 'black'; } if( $j==1 || $x == 3 ){ $output .= '<div class="row">'; $x=0; } $output .= '<div class="latest-featured-post-small col-sm-4">'; if ( has_post_thumbnail() ) { $img = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'newedge-small' ); $image ='style="height:200px;background: url('.esc_url($img[0]).') no-repeat;background-size: cover;"'; } else { $image = ''; } $output .= '<div class="themeum-latest-featured-post-item common-post-item common-post-item-text">'; $output .= '<div class="overlay '.esc_attr( $post_color ).' yes"></div>'; $output .= '<div class="common-post-item-in" '.$image.'></div>'; $output .= themeum_social_share( get_the_ID() ); $output .= themeum_bookmark_button( get_the_ID() ); $output .= '</div>';//common-post-item $output .= '<div class="common-post-item-intro-text">'; //if ( $show_category == 'yes'){ $output .= '<span class="entry-category '.themeum_rnd_cat_color().'">'; $output .= themeum_pre_cat_list( get_the_ID() ); $output .= '</span>'; //} $output .= '<h3 class="entry-title"><a href="'.get_permalink().'">'. get_the_title() .'</a></h3>'; $output .= '</div>';//common-post-item-intro $output .= '</div>'; //latest-featured-post-thumb if( $x == 2 || $total_post == $j ){ $output .= '</div>'; //row global $themeum_options; if( $themeum_options['category-ads'] == 1){ if (function_exists('themeum_advertiser')) { if( $themeum_options['category-slug'] == '' ){ $output .= '<div class="cat-add">'; $output .= themeum_advertiser('themeumall'); $output .= '</div>'; }else{ $output .= '<div class="cat-add">'; $output .= themeum_advertiser( $themeum_options['category-slug'] ); $output .= '</div>'; } } } } $x++; $j++; endforeach; wp_reset_postdata(); $output .= '</div>'; //lates-featured-post } } echo $output; $page_num = 0; $args = array( 'category' => $category_id, 'posts_per_page' => -1, 'post_status' => 'publish' ); $totalposts = get_posts($args); if(count($totalposts)!=0 && $count != 0 ){ $page_num = ceil( count($totalposts)/$count ); }else{ $page_num = 1; } themeum_pagination( $page_num ); ?> </div> <!-- #content --> <?php get_sidebar(); ?> </div> <!-- .row --> </div> <!-- .contaainer --> </section> <?php get_footer(); ?>
Looks like a very complicated category page… with carousels and a post listing?
The way it’s currently coded I cant tell you exactly where it should go… because Im not sure what your theme looks like.
<?php $cat = get_category( get_query_var( 'cat' ) ); $category = $cat->slug; echo do_shortcode('[ajax_load_more category="'.$category.'"]'); ?>
Here have a look https://www.xhepi.com/lajme/ maybe you can help me out
Any solution?
Sorry, missed your last post…
Unfortunately this will require some custom development to get the same look and feel as your website.If you want to hire us to work on your website you can use the form on the Ajax Load More website.
https://connekthq.com/plugins/ajax-load-more/support/
- The topic ‘How can i do it work?’ is closed to new replies.