Advertisement
hunterthemes

Grid theme tutorial

Aug 4th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. Grid theme tutorial by @hunterthemes
  2.  
  3. First of all, you need to find out the name of the container where posts are; Depending on the theme you’re using it might be #posts, #postcon, #container, #entries etc. (it’s above {block:Posts}). I assume it’s #posts, but if it’s not you need to change #posts in the following tutorial with the name of container div in the theme you’re using. Second, find how single post is named. It can be #post, #entry etc. (it’s under {block:Posts}). Let’s say it’s .entry. Again, change its name if needed.
  4.  
  5. 1) CSS
  6.  
  7. .entry {
  8. Width: 250px;
  9. Padding: 10px;
  10. Margin: 15px;
  11. Border: 1px solid #000;
  12. }
  13.  
  14. /*-- Assuming that the number of columns is 2
  15. width must be a equation of:
  16. number of columns * entry width,
  17. paddings: 2 columns * (10px left padding + 10px right padding),
  18. margins: 2 columns * (15px left margin + 15px right margin) and
  19. border widths: 2 columns * (1px left border + 1px right border)
  20. Ex: 2 * 250px + 2 * 10 + 2 * 10 + 2 * 15 + 2 * 15 + 2 * (1 + 1) = 604px --*/
  21.  
  22. #posts{
  23. Width: 604px;
  24. }
  25.  
  26.  
  27. 2) JAVASCRIPT
  28.  
  29. <!-- You need to paste these scripts after <head> or </style> -->
  30.  
  31. <!-- Jquery -->
  32. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  33.  
  34. <!-- Masonry -->
  35. {block:IndexPage}
  36. <script src="http://static.tumblr.com/6hsqxdt/QBym35odk/jquery.masonry.js"></script>\
  37. {/block:IndexPage}
  38.  
  39. <!-- If there’s no infinite scrolling in the theme you’re using add this too -->
  40. <script>
  41. $(document).ready(function(){
  42. var $container = $('#posts');
  43. $container.imagesLoaded(function() {
  44. $container.masonry({
  45. itemSelector: '.entry'
  46. });
  47. });
  48. $container.infinitescroll({
  49. itemSelector: ".entry",
  50. navSelector: "#pagination",
  51. nextSelector: ".next",
  52. loadingImg: "",
  53. loadingText: "<em></em>",
  54. bufferPx: 10000,
  55. extraScrollPx: 12000,
  56. }, function(newElements) {
  57. var $newElems = $(newElements).css({
  58. opacity: 0
  59. });
  60. $newElems.imagesLoaded(function() {
  61. $newElems.animate({
  62. opacity: 1
  63. });
  64. $container.masonry('appended', $newElems,
  65. true);
  66. });
  67. });
  68. });
  69. </script>
  70.  
  71. <!-- If there is infinite scrolling in the theme you’re using add this too ->
  72.  
  73. <script src="http://static.tumblr.com/wgijwsy/u2vm2hxv6/jquery.infinitescroll.min.js"></script>
  74.  
  75. <script type="text/javascript">
  76. $(window).load(function(){
  77. var $wall = $('#posts');
  78. $wall.imagesLoaded(function(){
  79. $wall.masonry({
  80. itemSelector: '.entry',
  81. isAnimated : false
  82. });
  83. });
  84.  
  85. $wall.infinitescroll({
  86. navSelector : '#pagination',
  87. nextSelector : '#pagination a',
  88. itemSelector : '.entry',
  89. bufferPx : 2000,
  90. debug : false,
  91. errorCallback: function() {
  92. $('#infscr-loading').fadeOut('normal');
  93. }},
  94. function( newElements ) {
  95. var $newElems = $( newElements );
  96. $newElems.hide();
  97. $newElems.imagesLoaded(function(){
  98. $wall.masonry( 'appended', $newElems,{isAnimated: false}, function(){$newElems.fadeIn('slow');} );
  99. });
  100. }); $('#posts').show(500);
  101. });
  102. </script>
  103.  
  104. 3) HTML
  105.  
  106. <div id=”posts”>
  107. {block:Posts}
  108. <div id=”entry”>
  109. /* post types go here */
  110. </div>
  111. <!—End entry-->
  112. {/block:Posts}
  113. </div>
  114. <!—End posts-->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement