- This topic has 10 replies, 3 voices, and was last updated 4 years, 5 months ago by
Chris.
-
AuthorPosts
-
December 13, 2018 at 1:51 pm #755936
Chris
Right now I have infinite scroll that shows all my blog posts.
My settings–>reading is set to 1 post to display. The home page displays all of my posts
How do I only show 1 blog post on the home page?
Second I want to have buttons at the bottom of my posts like Seth Godin’s Blog Page. How do I create code to do that?
https://seths.blog/2018/06/the-two-simple-secrets-to-good-ideas/
December 13, 2018 at 3:43 pm #756014Leo
StaffCustomer SupportHi there,
Sorry I’m not sure if I understand.
If you only want to show 1 post at the time, why would you need to use infinite scroll?
As for buttons, are you just referring to the style or you want the Next and Back text instead of the default post titles?
Let me know ๐
December 13, 2018 at 8:07 pm #756105Chris
Ok turns out I do need infinite scroll Seth’s home page has infinite posts.
For my blog posts…How do I get buttons like this? at the bottom of a blog post page?
https://drive.google.com/file/d/1bGqQMm4I4_Alh-DFOt–caKSTNP94nYe/view?usp=sharing
For my home page…How do I get a divider and a star count?
https://drive.google.com/file/d/1nb4tyLdwtsofe_TilUrTY2r4CZ0X8rdu/view?usp=sharing
December 14, 2018 at 8:51 am #756773Leo
StaffCustomer SupportFor the buttons, can you answer my question above:
As for buttons, are you just referring to the style or you want the Next and Back text instead of the default post titles?
For dividers, any chance you can link me to the page in question?
The link you provided isn’t working.
December 14, 2018 at 10:02 pm #757204Chris
https://s3.us-east-2.amazonaws.com/chrisawhite/pictures/Seth’s+Blog.png
I want the buttons to say next, back, and random
like this
https://seths.blog/2018/06/the-two-simple-secrets-to-good-ideas/
December 15, 2018 at 9:51 am #757611Tom
Lead DeveloperLead DeveloperTo add the buttons, you can do something like this:
add_filter( 'next_post_link', function( $output, $format, $link, $post ) { if ( ! $post ) { return ''; } $next = sprintf( '<a class="next-post button" href="%1$s" title="%2$s">Next</a>', get_permalink( $post ), $post->post_title ); $currentID = get_the_ID(); $args = array( 'numberposts' => 1, 'order' => 'ASC', 'orderby' => 'rand', 'post__not_in' => array( $currentID ), ); $random_post = get_posts( $args ); $random_post = sprintf( '<a class="button random-post" href="%1$s" title="%2$s">Random</a>', get_permalink( $random_post[0]->ID ), get_the_title( $random_post[0]->ID ) ); return $random_post . $next; }, 10, 4 ); add_filter( 'previous_post_link', function( $output, $format, $link, $post ) { if ( ! $post ) { return ''; } $prev = sprintf( '<a class="button previous-post" href="%1$s" title="%2$s">Previous</a>', get_permalink( $post ), $post->post_title ); return $prev; }, 10, 4 );
Then you’ll need to style them however you need.
Let me know if that does it or not ๐
December 15, 2018 at 11:58 pm #757948Chris
Do I put this in the editor single post php? or somewhere else?
December 16, 2018 at 9:15 am #758264Leo
StaffCustomer SupportOne of these methods:
Adding PHP: https://docs.generatepress.com/article/adding-php/
December 16, 2018 at 11:14 pm #758684Chris
ok I did code snippets. I don’t see any change even after clearing website cache
December 17, 2018 at 8:34 am #759244Tom
Lead DeveloperLead DeveloperMake sure post navigation is turned on in Customize > Layout > Blog.
December 17, 2018 at 4:48 pm #759648Chris
Didn’t work
I went to layout > blog > turned on all the options
cleared my cache and nothing happened
I have this as my code in snippets to run everywhere
add_filter( ‘next_post_link’, function( $output, $format, $link, $post ) {
if ( ! $post ) {
return ”;
}$next = sprintf(
‘Next‘,
get_permalink( $post ),
$post->post_title
);$currentID = get_the_ID();
$args = array(
‘numberposts’ => 1,
‘order’ => ‘ASC’,
‘orderby’ => ‘rand’,
‘post__not_in’ => array( $currentID ),
);$random_post = get_posts( $args );
$random_post = sprintf(
‘Random‘,
get_permalink( $random_post[0]->ID ),
get_the_title( $random_post[0]->ID )
);return $random_post . $next;
}, 10, 4 );add_filter( ‘previous_post_link’, function( $output, $format, $link, $post ) {
if ( ! $post ) {
return ”;
}$prev = sprintf(
‘Previous‘,
get_permalink( $post ),
$post->post_title
);return $prev;
}, 10, 4 ); -
AuthorPosts
- You must be logged in to reply to this topic.