Support » Plugins » An Alternative To do_shortcode

  • Resolved scarekrow76


    Hi Everyone. Please bear with me, as I’m not 100% sure what I need…

    I am using a class within a custom plugin to provide a custom post type. As part of the post type there are five meta keys for storing an address (e.g. building, street, city, state, zip).

    To keep the loop as simple as possible, I want to offer an easy way to return the whole address as a single string.

    At the moment I have achieved this by adding a shortcode to the custom post type and calling it from wihtin the loop via do_shortcode.

    Can anyone suggest a better/simplier way to achieve the same result?

Viewing 1 replies (of 1 total)
  • Well, I found one alternative – but not sure if its reccommend…

    I added a hook to the the_post action which appended an extra value to the $post object.

    add_action('the_post', array(&$this, 'the_post'));

    function the_post($post)
    		global $post;
    		$custom = get_post_custom($post->ID);
    		$building = $custom['building'][0];
    		$street = $custom['street'][0];
    		$city = $custom['city'][0];
    		$county = $custom['county'][0];
    		$postcode = $custom['postcode'][0];
    		$address = new AircooledBugsAddress($building, $street, $city, $county, $postcode);
    		$post->post_event_address = $address->get_formatted_address();
    		return $post;
Viewing 1 replies (of 1 total)
  • The topic ‘An Alternative To do_shortcode’ is closed to new replies.