- This topic has 13 replies, 2 voices, and was last updated 8 years ago by Tom.
-
AuthorPosts
-
February 28, 2016 at 1:41 pm #175963Kristian Foshaug
Does GeneratePress support in any way an option to add content after X posts? For instance, we want to add a custom content banner between the 5th and 6th post. Currently running masonry so that we have one large post, then two smaller posts per “row”.
Basically something similar that Rockpapershotgun does with their video-banner a few posts down: https://www.rockpapershotgun.com/
our site: http://www.spillhistorie.no
February 28, 2016 at 3:09 pm #175977Kristian FoshaugI found this way: http://wpsites.org/insert-ad-codes-first-second-nth-post-10364/ – perhaps not the best one but…
This leaves a small problem when using Masonry – when making a “full width” custom post, the masonry on the posts above will be uneven if the two posts are not similar lenght, and thus leave a gap before the next full width post comes.
February 28, 2016 at 10:44 pm #175995TomLead DeveloperLead DeveloperAre you using this code?: https://gist.githubusercontent.com/shizhua/b7e38d412f5f94e9b130/raw/c36159e11f825ea998d83d7ba02c19bf03b6bb70/add_action.php
Is it live on your site right now?
February 28, 2016 at 11:24 pm #176007Kristian FoshaugI’ve updated it now so that the issue is live.
Using the second alternative, Method two.
The inserted post is the two-column one below the gap (“Sjekk vår dekning…”)
<?php if ( have_posts() ) : $count=0; ?> <?php /* The loop */ ?> <?php while ( have_posts() ) : the_post(); $count++; ?> <?php get_template_part( 'content', get_post_format() ); ?> <?php if ($count == 2) : ?> Ad Codes after 2nd post <?php endif; ?> <?php endwhile; ?> <?php else : ?> <?php get_template_part( 'content', 'none' ); ?>
- This reply was modified 8 years, 1 month ago by Kristian Foshaug.
- This reply was modified 8 years, 1 month ago by Kristian Foshaug. Reason: fixed the code-tag
- This reply was modified 8 years, 1 month ago by Kristian Foshaug. Reason: fixed the code-tag
February 29, 2016 at 10:36 am #176117TomLead DeveloperLead DeveloperCan you try the other code that I posted? It should be a better option than changing the loop directly.
February 29, 2016 at 12:01 pm #176139Kristian FoshaugThat code completely broke the layout.
(i’m editing index.php as suggested on that page)
February 29, 2016 at 10:29 pm #176205TomLead DeveloperLead DeveloperHmm, do you want this inserted div to be full width, or the same as the other posts?
February 29, 2016 at 11:43 pm #176219Kristian FoshaugBoth – I would like to be able to have some small and some full width. The small ones work perfectly with the code I provided, but as mentioned, the masonry above the full width leaves a gap as shown in the image (because the above post isn’t “long” enough).
March 1, 2016 at 10:18 pm #176522TomLead DeveloperLead DeveloperFor full width, wrap your content in this:
<article class="masonry-post width6"> Your content </article>
For medium width:
<article class="masonry-post width4"> Your content </article>
For small width:
<article class="masonry-post width2"> Your content </article>
March 2, 2016 at 3:49 am #176548Kristian FoshaugI’m probably bad at explaining, sorry :/
I know how to get the proper widths, but the issue is that the posts above the inserted one does not “fill” the masonry vertically – as shown in the first screenshot I shared. I did try to use your suggestion above, but the same thing happens.
March 2, 2016 at 10:33 am #176610Kristian FoshaugI just noticed another bug using this – when using the “display more posts” at the bottom of the page, the added block will display again (just go to the site, scroll down, and click load more – and it will repeat endlessly).
March 3, 2016 at 12:19 am #176730TomLead DeveloperLead DeveloperHmm, that’s because you need to make sure you’re only adding it to the first page along with this check:
Thinking about this – why not just add a post with the “Link” post format (or Aside etc..) and then adjust the date to have it display in a specific position?
Might be a little less hassle with the same result.
March 3, 2016 at 5:50 am #176799Kristian FoshaugThanks – that pagination checked worked. 🙂 Now only the issue with the gap in the masonry remains.
March 3, 2016 at 10:44 pm #176955TomLead DeveloperLead DeveloperIs it currently on your site or have you taken it down?
-
AuthorPosts
- You must be logged in to reply to this topic.