Genesis_custom_loop next page link does not work on homepage.

Community Forums Forums General Discussion Genesis_custom_loop next page link does not work on homepage.

This topic is: not resolved

This topic contains 4 replies, has 4 voices, and was last updated by  bittheory 6 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #77837

    webmaster@uthsc.edu
    Participant
    Post count: 13

    I’ve created a template with a custom loop and set it as my homepage. Everything works fine when the page is not set as the homepage, but when I do, the ‘next page’ link stops working.

    This is because, when I set the page as the homepage, the next page link drops the page slug from the link.
    So, instead of
    http://mysite.com/my-custom-loop-page/page/2/
    it gets changed to
    http://mysite.com/page/2/
    and the loop just starts over again.

    What I really need is someway to conditionally change the next page link so that it will work on the homepage.
    If it’s any help, here’s the template:

    /* Template Name: Newsroom */ 
    
    /*Use the Genesis custom loop to create loop for my custom post type
     *For parameters see: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters*/
    function newsroom_custom_loop() {
    
    		global $paged;
    		global $query_args;
    
    		$args = array(
    		'thumb' => true,
    		'post_type' => 'post',
    		'author' => '16',
    		'paged' => $paged,
    		'posts_per_page' => 8
    		);
    		
    	return genesis_custom_loop( wp_parse_args($query_args,$args) );
    }
    
    add_filter( 'genesis_loop', 'newsroom_custom_loop');
    
    genesis();
    • This topic was modified 10 months, 2 weeks ago by  webmaster@uthsc.edu. Reason: added code markup
    • This topic was modified 10 months, 2 weeks ago by  webmaster@uthsc.edu. Reason: added code markup
    #91197

    Susan
    Moderator
    Post count: 9255

    Hi! Since it’s been a while since you posted your question, I hope you were able to get it resolved.

    If not, please report back here, and I will try to assist, or will escalate.

    Thanks!


    Susan @ Graphically Designing I offer theme customizations I tweet!
    I’ve taken up the challenge! – help me answer some of the unanswered posts

    #100847

    bittheory
    Member
    Post count: 4

    Hi,

    Hope it’s okay to post. I have the same problem – the page slug is dropped in pagination buttons when page is set as homepage and posts do not advance but the same page works when not set as hompage. Did you resolve the problem and if so, how?

    Regards,
    Fred

    • This reply was modified 6 months, 1 week ago by  bittheory.
    • This reply was modified 6 months, 1 week ago by  bittheory.
    #101580

    davebonds
    Member
    Post count: 13

    Try adding your page slug as a pagename parameter to the query args. Replace sample-page with your page slug:

    'pagename' => 'sample-page',

    So this:

    $args = array(
    		'thumb' => true,
    		'post_type' => 'post',
    		'author' => '16',
    		'paged' => $paged,
    		'posts_per_page' => 8
    		);

    Becomes this:

    $args = array(
    		'thumb' => true,
    		'post_type' => 'post',
    		'author' => '16',
    		'pagename' => 'sample-page', 
    		'paged' => $paged,
    		'posts_per_page' => 8
    		);
    #102234

    bittheory
    Member
    Post count: 4

    Hidavebonds,

    Thanks for that. Sorry for the delay in responding. Going to go try that out – I’m guessing that combining the above with is_front_page will allow for customizing it only for home. Might need to also check if a static page is used as well. Or I could be over complicating things. Will play with it and see what happens!

    Regards,
    Fred

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.