Implement Infinite Scroll on Single Posts

Posted in: Newsmag
Post count: 17

Hi, I would like to implement infinite scrolling on single posts, is there a tested plugin for this? Will the embedded ads work as fine?

Thanks.

Post count: 6600

Hi,

We haven’t made any test using plugin like that.
Not really sure where would you want the infinite scroll feature. If you would want this for related articles section you could try to call a block customized by you using the VC page builder and render it via the do shortcode function in posts’s template replacing the related posts area.
I haven’t tried to do this so I can’t guarantee this will also work but you could give it a try.

Thanks

Post count: 17

Hi Lucian,

I tried a few plugins and nothing worked:

https://wordpress.org/plugins/unlimited/
https://wordpress.org/plugins/infinite-scroll/

Those work on other themes. Also, to be clearer, here’s what I want to accomplish – specifically in SINGLE POSTS (it’s actually a popular feature due to popularity of mobile devices):

Post count: 6600

Hi,

We haven’t tested the theme using any of those plugins so I can’t provide an accurate answer on this.
I suggest you also address the issues you have using them to plugins authors and make sure that you sue them right.

The theme already has a built in infinite scroll pagination for blocks which you can use to display your content and use the infinite scroll pagination feature.
You can configure a block to use the infinite scroll pagination and on templates on which you can’t use the page builder add the block shortcode inside the template where you need this.
Here is an example for using block 13 with infinite scroll pagination on single post page after the related posts section:

– use VC page builder to customize the block: http://screencast.com/t/MYIDubqBqFJ
– switch to classic mode and get the block shortcode: http://screencast.com/t/tymN00V7m
– add the shortcode to post template, you’d have to edit the loop-single.php template and add the block shortcode using the do_shortcode function, like this: http://screencast.com/t/Qod46BQhTZtt
* here is the code I’ve used: http://pastebin.com/yRjEcaD2
– the result: http://screencast.com/t/kcqFH6hM

Thansk

Post count: 33

How to make infinite scroll on single post like this: http://goo.gl/wU87A1
Thanks in advance for your replay

Post count: 7909

Hi,

Unfortunately the theme doesn’t have infinite load feature for post pages, it has ajax pagination only for blocks(next/prev, infinite,load more). The only way to achieve infinite load on post with our theme is to use block shortcode like Lucian suggested above.

Thanks!

Post count: 99

Hi,

I have tried using the shortcode to add the blocks into the single post layout loop-single.php.
It does work well but how do you make it corresponding to the category of that particular post.

Post count: 99

Also,

The shortcode look normal on the homepage Homepage.
When I use that block shortcode into the single loop page, the layout look different with 3 columns instead 2 columns with medium thumbnails Single Post page

Post count: 6535

Hi

Please provide your site url so I can have a closer look.
Thanks!

Post count: 99

Here is the dev site: Developments Site

Post count: 6535

Hi

Block’s layout can be corrected when it’s used on posts following this configuration:
– in Visual composer set a 2/3 row: http://screencast.com/t/KOy8eW1F
– insert this shortcode in do_shortcode function: http://screencast.com/t/xwyyFSQo
– add this css in theme panel > custom code > custom css: http://screencast.com/t/i4cv7jhH7Vs

.single .td-pb-row .td-pb-row .td-pb-span8 {
width: 100%;
}

Thanks!

Post count: 99

Thank you for the fast reply.

My other question is how to set the block13 in the single post that related to the same category when I set it to be infinite load?

Thank you again for your support.

Post count: 6535

Hi

You can choose the desired category from block’s settings in Visual Composer when you prepare the shortcode: http://screencast.com/t/tDcvaVshh By setting a specific category in indicated field the theme will disply posts only from that category.
If this is not what you mean please provide more details about what you’re trying to do.

Thanks!

Post count: 99

That setting is only for specific category.
What I mean is that from homepage I have many blocks with different categories so when clicking to any post it will display that post content and for block13 to show the same category post listing.

Hope you understand my question.

Thank you for your support.

Post count: 6535

Hi

You can change category id depending by post’s category using this cod: http://screencast.com/t/lEWHIm5y4x

    <?php
    $category_detail=get_the_category($td_mod_single->post->ID);//$post->ID
    foreach($category_detail as $cd){
       $cat_name = $cd->cat_ID;
    }
    echo do_shortcode('[vc_row][vc_column width="2/3"][td_block_13 category_id="' . $cat_name . '" limit="2"]                       [/vc_column][/vc_row]');
    ?>

This code insert post’s category id inside shortcode and should work fine.
Thanks!

  • This reply was modified 10 years by Andrei L..
Post count: 99

– How do I offset the current post with the block13 that’s doing the infinite load and it seems like it duplicate the article.

– One other thing, in the Post Page I added 3 blocks after the article content. Right now the blocks are display to all articles. How can I set the 3 blocks to show only to a selected category.

Example:
reading from category id=1, the 3 blocks will show block1=cat id=4, block2=cat id=7, block3=cat id=13
reading from category id=4, the 3 blocks will show block1=cat id=1, block2=cat id=5, block3=cat id=9
reading from category id=6, the 3 blocks will show block1=cat id=2, block2=cat id=8, block3=cat id=10

I hope you can understand my questions.

Thank you for your support.

Post count: 6535

Hi

This can be achieved only if you generate a specific shortcode for each category and use some conditions in order to display it. Also you can use a similar code with the above one to create an $exclude_current_post variable and also use it in shortcode as I did with category id.
Please note that this customiztion requires some coding skills in order to be achieved and if you’re not aware of the steps you need to take in this regard my advice is to look for someone who can help you whit implementation as we can’t offer customization services at the moment.

Thanks!

Post count: 99

Hello Andrei,

Thank you for your suggestion, I will look up a professional to help me with the crossed links for the single post page.

You have mentioned that that I can do the $exclude_current_post for the duplication of the infinite load, can you please show me how to accomplish that obstacle?

Thank you for your support.

Post count: 6535

Hi

Basically you have to get the post id into a variable using then include it in block’s shortcocde as I did with category id. Your code could be like this.

<?php
$exclude_current_post = $td_mod_single->post->ID;
echo do_shortcode('[td_block_13 post_ids="'. -$exclude_current_post .'"]');
?>

Thanks!

  • This reply was modified 10 years by Andrei L..
Post count: 99

Hello

I currently have this code in the loop-single.php to show the same category articles.

<?php
$category_detail=get_the_category($td_mod_single->post->ID);//$post->ID
foreach($category_detail as $cd){
$cat_name = $cd->cat_ID;
}
echo do_shortcode('[vc_row][vc_column width="2/3"][td_block_13 category_id="' . $cat_name . '" limit=""][/vc_column][/vc_row]');
?>

How do I combine this code
<?php
$exclude_current_post = $td_mod_single->post->ID;
echo do_shortcode('[td_block_13 post_ids="'. -$exclude_current_post .'"]');
?>

So it won't get conflicted.

Thank you for your support.

Post count: 6535

Hi

The final codes should look like this:

<?php
    $category_detail=get_the_category($td_mod_single->post->ID);//$post->ID
    foreach($category_detail as $cd){
        $cat_name = $cd->cat_ID;
    }
    $exclude_current_post = $td_mod_single->post->ID;
    echo do_shortcode('[vc_row][vc_column width="2/3"][td_block_13 post_ids="'. -$exclude_current_post .'" category_id="' . $cat_name . '" limit=""][/vc_column][/vc_row]');
    ?>

Thanks!

Post count: 99

Thank you for your help Andrei, the code work very well.

One problem with out contents is that we have some sensitive categories that we don’t want to show the blocks and infinite load on the single page. Here is the code


<?php echo do_shortcode('[vc_row][vc_column width="2/3"][td_block_2 custom_title="Hoa Kỳ" category_id="61" limit="6" ajax_pagination="next_prev"][td_block_2 custom_title="Little Saigon" category_id="64" limit="6" ajax_pagination="next_prev"][td_block_2 custom_title="Việt Nam" category_id="66" limit="6" ajax_pagination="next_prev"][vc_separator][/vc_column][/vc_row]'); ?>

<?php
$category_detail=get_the_category($td_mod_single->post->ID);//$post->ID
foreach($category_detail as $cd){
$cat_name = $cd->cat_ID;
}
$exclude_current_post = $td_mod_single->post->ID;
echo do_shortcode('[vc_row][vc_column width="2/3"][td_block_13 post_ids="'. -$exclude_current_post .'" category_id="' . $cat_name . '" limit=""][/vc_column][/vc_row]');
?>

Can you please show me how I can exclude those categories out. Example: Cat ID = 1, 2, 3, 4.

Thank you for your support I really appreciated.

Post count: 6535

Hi

I am not sure I understand your request so please provide more details about what you’re trying to do and maybe i can helps.
Thanks!

Post count: 99

Right now all the posts are using the default post template.
I added the above codes to loop-single.php so every post will show that.
My concern is that I have a few categories that don’t want to show the extra blocks, so my question is there anyway to exclude the blocks from those categories?

I found a temp. solution for that is I have to go into each post that I don’t want to show the block and choose a different post template from the post page itself.

If you have a better solution please help me out.

Thank you for your support.

Post count: 6535

Hi

I assume that you want to exclude posts from some specific categories from being displayed in that block. If this is the case you just have to pass the ids in block’s shortcode, here is an example:

echo do_shortcode('[vc_row][vc_column width="2/3"][td_block_13 post_ids="'. -$exclude_current_post .'" category_id="' . $cat_name . ', -1, -2, -3" limit=""][/vc_column][/vc_row]');

Hope this helps.
Thanks!

Viewing 25 posts - 1 through 25 (of 33 total)
The forum ‘Newsmag’ is closed to new topics and replies.