Adding an intro to the Add Listing page

This topic contains 1 reply, has 2 voices, and was last updated by  Paolo 9 years, 3 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #28971

    John Allsopp
    Expired Member
    Post count: 399

    For a recent project I found it necessary to add some text on the “Add Listing” page. I thought i would share in case anyone else is interested.

    The basic concept is to just add something to a hook before the form fields. In it’s simplest form it would go something like:

    
    
    // Add help context text on the add-listing page
    add_action( 'geodir_before_main_form_fields', 'my_add_listing_intro' );
    function my_add_listing_intro() {
    	echo '<div class="my-add-listing-intro"><p>Some text</p></div>';
    }

    I took this a stage further by adding a different message depending on the CPT being used:

    
    
    // Add help context text on the add-listing page
    add_action( 'geodir_before_main_form_fields', 'my_add_listing_intro' );
    function my_add_listing_intro() {
    	$listing_type = $_REQUEST['listing_type'];
    
    	if ( $listing_type == 'gd_church' ) {
    		$intro_text = 'the name of your Church';
    	}
    	elseif ( $listing_type == 'gd_school' ) {
    		$intro_text = 'the official name of your School';
    	}
    	elseif ( $listing_type == 'gd_shop' ) {
    		$intro_text = 'your business name';
    	}
    
    	echo '<div class="my-add-listing-intro"><p>The <em>Listing Title</em> field should be ' . $intro_text .'</p></div>';
    }

    Hopefully somebody might find this useful.

    #28977

    Paolo
    Site Admin
    Post count: 31206

    Thanks John, code recipes are always welcome! 🙂

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

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

Open Support Ticket