Custom archive Item Template

This topic contains 9 replies, has 3 voices, and was last updated by  Naveen Giri 4 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #523404

    anders
    Full Member
    Post count: 121

    Hi,

    I found this example for creating custom Archive Item Template which looks superuseful (the Archive item Per Price Package -example):
    https://wpgeodirectory.com/docs-v2/templates/archive-item/#customizing

    Could you please provide an additional example?
    If possible I plan to use this for having different Archive Item Templates based on the page.

    I tried this without luck (I want to use a different Archive Item Template for gd_place when on frontpage and I have created the extra page for this):

    function gd_snippet_customgdplace_archive_item_page_id( $page_id, $post_type ) {
    global $gd_post;
    if ( ! empty( $gd_post ) && 'gd_place' == get_post_type() ) {
    		if (  is_front_page() ) { // MATCH PACKAGE ID
    			$page_id = 251; // ARCHIVE ITEM PAGE ID from PAGES
    		}
    		else {
    			$page_id = 253;
    		}
    }
    return $page_id;
    }
    add_filter('geodir_archive_item_page_id', 'gd_snippet_customgdplace_archive_item_page_id', 10, 2);

    Thanks!

    #523411

    Kor
    Moderator
    Post count: 16516

    Hi Anders,

    Thanks for your post. Allow me to forward this to a developer for further assistance.

    #523415

    Naveen Giri
    Moderator
    Post count: 1559

    Hi anders,

    Please try following code and check if it works as per your expectation.

    
    
    
    function gd_snippet_customgdplace_archive_item_page_id( $page_id, $post_type ) {
    	if ( 'gd_place' == $post_type && is_front_page() ) { // MATCH PACKAGE ID
    		$page_id = 251; // ARCHIVE ITEM PAGE ID from PAGES
    	} else {
    		$page_id = 253;
    	}
    	return $page_id;
    }
    add_filter('geodir_archive_item_page_id', 'gd_snippet_customgdplace_archive_item_page_id', 10, 2);
    

    Thanks

    #523425

    anders
    Full Member
    Post count: 121

    Thank you Naveen,

    But it’s very strange, after I included that in my child theme, my templates stopped behaving like they did before and it doesn’t help if i remove it again.

    At my frontpage I have a gd_listings -shortcode for our gd_nyheter CPT and for this I have a custom archive item template at which I include a gd_listings shortcode for gd_place …and this is why I needed to customize gd_place template based on the page.
    however after I run the included snippet, the archive item template for gd_nyheter doesn´t display any gd_place anymore. Does it make any sense?

    Thanks!

    #523429

    Naveen Giri
    Moderator
    Post count: 1559
    This reply has been marked as private.
    #523437

    anders
    Full Member
    Post count: 121
    This reply has been marked as private.
    #523438

    anders
    Full Member
    Post count: 121
    This reply has been marked as private.
    #523493

    Naveen Giri
    Moderator
    Post count: 1559
    This reply has been marked as private.
    #523511

    anders
    Full Member
    Post count: 121
    This reply has been marked as private.
    #523517

    Naveen Giri
    Moderator
    Post count: 1559
    This reply has been marked as private.
Viewing 10 posts - 1 through 10 (of 10 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket