- This topic has 13 replies, 2 voices, and was last updated 5 years ago by
Tom.
-
AuthorPosts
-
February 28, 2016 at 1:41 pm #175963
Kristian 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 Foshaug
I 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 #175995Tom
Lead 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?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 28, 2016 at 11:24 pm #176007Kristian Foshaug
I’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 5 years ago by
Kristian Foshaug.
-
This reply was modified 5 years ago by
Kristian Foshaug. Reason: fixed the code-tag
-
This reply was modified 5 years ago by
Kristian Foshaug. Reason: fixed the code-tag
February 29, 2016 at 10:36 am #176117Tom
Lead DeveloperLead DeveloperCan you try the other code that I posted? It should be a better option than changing the loop directly.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 29, 2016 at 12:01 pm #176139Kristian Foshaug
That code completely broke the layout.
(i’m editing index.php as suggested on that page)
February 29, 2016 at 10:29 pm #176205Tom
Lead DeveloperLead DeveloperHmm, do you want this inserted div to be full width, or the same as the other posts?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 29, 2016 at 11:43 pm #176219Kristian Foshaug
Both – 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 #176522Tom
Lead 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>
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 2, 2016 at 3:49 am #176548Kristian Foshaug
I’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 Foshaug
I 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 #176730Tom
Lead 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.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 3, 2016 at 5:50 am #176799Kristian Foshaug
Thanks – that pagination checked worked. 🙂 Now only the issue with the gap in the masonry remains.
March 3, 2016 at 10:44 pm #176955Tom
Lead DeveloperLead DeveloperIs it currently on your site or have you taken it down?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
This reply was modified 5 years ago by
-
AuthorPosts
- You must be logged in to reply to this topic.