Add code to all places

This topic contains 6 replies, has 3 voices, and was last updated by  P O 4 years ago.

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

Open Support Ticket
  • Author
    Posts
  • #540010

    P O
    Expired Member
    Post count: 501

    I need to have

    <!--DoThis-->

    in the start of all places description.

    That triggers a special function I have. I can go edit all places and add

    <!--DoThis-->

    so everything works, but the idea is to avoid that and being able to manage it for all.

    Is there a way I can add my custom HTML for that?

    How can I have it in all places?

    Thanks.

    #540070

    Alex Rollin
    Moderator
    Post count: 27815

    You can bulk edit via Export -> Import

    #540073

    P O
    Expired Member
    Post count: 501

    I can’t be exporting and importing places with all the risks it involves for something like this.

    Maybe a function to insert what I need at the beginning of every place text?

    That way I have the function to have it or to revert it.

    Thanks.

    #540094

    Naveen Giri
    Moderator
    Post count: 1559

    Hello,

    You can use this filter.
    it will add that string before post content on gd single page.
    not need to worry about adding it for every place from the backend.

    
    
    
    add_filter( 'the_content', function( $content ) {
    	$post_type = geodir_get_current_posttype();
    	if ( ! geodir_is_gd_post_type( $post_type ) && !geodir_is_page('detail') ) return $content;
    	
    	return '<!--DoThis-->'.$content;
    });
    

    Thanks

    #540098

    P O
    Expired Member
    Post count: 501

    Thank you Naveen.

    That means the text in every place single page, correct?

    If I want to remove it I just have to remove the function?

    Thank you.

    #540103

    Naveen Giri
    Moderator
    Post count: 1559

    Yup, that’s right.
    Please copy the latest code, I have added one more check for detail page.

    #540169

    P O
    Expired Member
    Post count: 501

    I will test it.

    Thank you.

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

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

Open Support Ticket