Upfront - Spirit, adding old Meta Data


I have a customer who I'm trying to get back limping after a really bad hack as their old designer offered no theme updates and used several elements which have had nasty security hacks.

So the old guy added code to use post types like audio/video - etc. well the issue at hand is they have an archive of audio that is in this old meta data (280+ items) the data is there, but can't seem to find a way to add the data in.

The old code looked like this:

$post_pod_type = get_post_meta($post->ID, 'post_pod_type', true);
 $post_type_values = get_post_meta($post->ID, 'post_type_values', true);

Then displayed the audio player if the case matched:

switch ($post_pod_type) {
case 'audio':
echo do_shortcode('[audio]' . $post_type_values[$post_pod_type] . '[/audio]');

How can I replicate this functionality? I looked at the theme files, and honestly unsure how to add this properly. Still reading over things myself, but he's in a hurry and has a board that is on the rampage of "how could this of happened".

Any help is appreciated. Even if it's "Read Chapter 27." just looking for guidance.

  • Adam Czajczyk

    Hello ChuckB,

    I hope you're well today and thank you for your question!

    This is indeed quite an unfortunate case. I think however there are way worth trying :slight_smile:

    Assuming that the code you shared here is complete enough I think we could try shortcode/mu-plugin approach here. Take a look at this please:

    function custom_meta_value_shortcode() {
    	global $post;
    	// fetch post meta values
    	$post_pod_type = get_post_meta($post->ID, 'post_pod_type', true);
    	$post_type_values = get_post_meta($post->ID, 'post_type_values', true);
    	//show what's needed
    	switch ($post_pod_type) {
    		case 'audio':
    		$output = do_shortcode('[audio]' . $post_type_values[$post_pod_type] . '[/audio]');
    		/* ... rest of your switch conditions go here the same way as above ... */
    	return $output;
    add_shortcode('the_custom_meta', 'custom_meta_value_shortcode');

    Added as an MU plugin it should give you the shortcode:


    Added to the post directly (via Upfront editor) it should do the job I think. Please note however that this is just an idea so you may want to play with it a bit. I think similar code could also be used as a custom filter for "the_content" instead of shortcode so it would then be automatically added to post.

    Let me now please what do you think about it.

    Best regards,

  • Chuck B.

    Honestly not entirely sure how to implement that, I am not used to the template structure that Upfront uses, went to just replicate the modifications to the single.php and found some very different files.

    I just need this to display only if its audio tagged like it used to be and wrap the audio tag, I see how the shortcode would do that, but is your suggestion just to create a single file plugin which will create the shortcode?

    I don't want it added to a single post, there are nearly 300 posts like this, and I have no strong desire to edit each manually.

    I guess maybe I need a better course on what Upfront can truly do, because I'm honestly just lost.

  • Chuck B.

    Sadly the old code was taken down - site was massively hacked due to poor upkeep and a slew of old plugins which had known exploits.

    I'm just going off the fact that the old theme Blessings (http://themeforest.net/item/blessing-church-wordpress-theme/3582013) was used, highly modified to auto-include the meta data as noted from the example code (which is still attached to the old posts thankfully) so 280+ posts don't need to be edited/re-created :slight_smile: just as it stands no easy way to simply edit the single.php like the previous template had in place.

    I wish I could show you how it worked, but the code above is all I had to work with, hopefully what I've written makes sense - if not I guess I'll just keep digging I guess. I do appreciate the options so far, just looking to be pointed even in the right direction - but would love to have some guidance from an experienced user :slight_smile:

  • Predrag Dubajic

    Hi Chuck,

    Upfront is quite different from other WP themes so editing single.php like before is not a best option here.

    I would suggest following Adam's instructions above and place his first piece of code in mu-plugin.
    To create mu-plugin go to wp-content/mu-plugins/ folder and create .php file in there with any name you like and paste the code in it.
    If you don't mu-plugins folder in there simply create one yourself.

    After that go to edit any of your single posts, add new text element and place [the_custom_meta] in there, and now when saving changes click on All Posts of This Type and save the changes.

    Let us know if this solution works for you.

    Best regards,

  • Chuck B.

    Things kept not working but found that the audio shortcode must of been something more targeted with the particular theme as [audio][/audio] did not work, the offical uses a different format (https://codex.wordpress.org/Audio_Shortcode) in the end here's the functional line for output:

    $output = do_shortcode('[audio src="' . $post_type_values[$post_pod_type] . '"]');

    Minor adjustment but working on all messages now! Thanks a million guys!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.