Need help with wp_postmeta fields!

This topic contains 32 reply and 5 voices, and was last updated by lwrkrol 10 years, 8 months ago
Viewing 15 Posts - 1 through 15 (of 32 total)
Author Posts
April 9, 2013 at 8:57 pm 1977
lwrkrol

Hi there! I recently purchased a WordPress Theme that uses a custom taxonomy called “Items”, and I want to use WP User Frontend Pro to provide the frontend-editing for it. Now I do see several custom taxonomies showing up in the form editor, but there’s one field that I can’t get to work, and that’s the Google Map/Streetview field.

When I check PHPmyAdmin, I find the following field: _ait-dir-item in wp_postmeta

With the content: 

a:19:{s:7:”address”;s:17:”Street”;s:11:”gpsLatitude”;s:17:”12.341251949999999″;s:12:”

gpsLongitude”;s:17:”12.34779700000025″;s:18:”streetViewLatitude”;s:17:”22.46046022895586″;

s:19:”streetViewLongitude”;s:17:”22.006520910937523″;s:17:”streetViewHeading”;

s:1:”0″;s:15:”streetViewPitch”;s:1:”0″;s:14:”streetViewZoom”;s:1:”0″;s:9:”telephone”;s:0:”";

s:5:”email”;s:17:”tester@retroga.me”;s:3:”web”;s:0:”";s:11:”hoursMonday”;s:0:”";s:12:”hoursTuesday”;s:0

:”";s:14:”hoursWednesday”;s:0:”";s:13:”hoursThursday”;s:0:”";s:11:”hoursFriday”;s:0:”";s:13:”hoursSaturday

“;s:0:”";s:11:”hoursSunday”;s:0:”";s:18:”alternativeContent”;s:4:”Test”;}

I was wondering how I could access those variables, so that I can make this work with the theme.

Thanks in advance!

April 9, 2013 at 9:18 pm 1978
Tareq Hasan Tareq Hasan

The data you posted, is the post meta. From the theme (single.php), you can get the data by using: [php]
$location = get_post_meta( $post->ID, ‘_ait-dir-item’, true );
[/php]

Seems like it’s an array, you can view the contents by print_r( $location );.

I am not sure how is this related with your “Items” taxonomy and what’s exactly wrong happening with the taxonomy?

April 10, 2013 at 5:08 am 1986
retroga_me retroga_me

Hi Tareq, thanks for the quick reply!
First of all I’ve got to say that you’ve made quite an awesome plugin, so there’s that :).
I might have my WordPress lingo all messed up, so I’ll try to explain it as good as I can.

The theme I am currently using is called WP Directory, and it comes with a custom post type called “Item”, which supposedly is the ait-dir-item. The theme has some built-in Google Maps magic that allows you to show a map with a marker, or a streetview in your header.

When creating a new Item, you can select several custom fields, amongst one is the Google Maps/Streetview field.

I would like to have that entire form on the frontend so that people can add their own Items without having to go to the backend of WordPress. I’ve tried setting the meta keys to the ones shown in my previous post (like address etc.) but somehow I’m not writing the variable to the ait-dir-item array.

I’ve set the custom post type in the plugin, so I would’ve thought it would write to the custom post meta keys too. Since it’s an array, would I have to enter anything special in the meta key field?

If you need any more information, let me know :).

Cheers.

April 10, 2013 at 10:41 am 1989
Tareq Hasan Tareq Hasan

From the plugins built in Google Maps meta field, it’s not possible to save the exact information in exact format as this theme saves. But in can be adapted I guess.

The plugin comes with some actions/filters and with the help of these action/filters you can achieve those. You can use the plugins Google map for taking the data and manipulate it to save it in the themes meta format. Or you can display your themes Geo data meta box in the plugins form and bind to the plugins action hook and save them.

If you are not a developer, I guess you need help from a developer to achieve this. Take a look in this developer docs and how I made Pronamic Google Maps plugin to work with my plugin.

April 10, 2013 at 10:36 pm 2010
retroga_me retroga_me

Thanks, I’ll give it a try! Not new to programming, but new to PHP so I consider this a good excersize :).

April 13, 2013 at 2:07 am 2124
retroga_me retroga_me

I just tried and tried again, but it’s still not working.

Tareq, I see for instance that the wpuf_form is also saved as a serialized array. Is there a way to have WP User Frontend Pro save its data in a serialized array somehow, just like wpuf_form?

April 13, 2013 at 2:47 am 2127
Tareq Hasan Tareq Hasan

The trick you need to use is, when you are submitting the form, all the submitted values can be found in $_POST variable. So binding a function to the action wpuf_add_post_after_insert, you’ve to create an array and save it to the _ait-dir-item meta key by update_post_meta( $post_id, '_ait-dir-item', $your_array );. That way, your array will be saved in serialized form just like the theme did.

April 13, 2013 at 6:16 pm 2154
retroga_me retroga_me

Hi Tareq, thanks for the reply! What you’re saying makes total sense, apart from the fact that I myself aren’t capable of such PHP magic . I don’t want to coerce you into spelling it out entirely for me (although it would be appreciated), but I guess I’ll take a book on PHP and get myself accustomed with WordPress a bit more on the code level and leave the custom post item editing in the backend for now.

Thanks for your help so far though, love the plugin and the level of support!

April 16, 2013 at 7:35 pm 2307
retroga_me retroga_me

Well… so far nothing new… Although is there a way to add a complete metabox to the frontend in one go? All of the info seems to be saved in _ait-dir-item_metabox

April 16, 2013 at 8:13 pm 2309
Tareq Hasan Tareq Hasan

Meta box is also a function, so it can be added directly by calling that function to the plugin hook.

April 16, 2013 at 8:16 pm 2311
retroga_me retroga_me This reply has been marked as private.
April 17, 2013 at 10:24 am 2337
retroga_me retroga_me

Ok… Here goes:

I got this function:

http://pastebin.com/3SurHf5z

I pasted that in wpuf-functions.php, then the theme told me I could not redefine that function, so I deleted it from the theme’s functions.php

And it still doesn’t work. Now to be fair, I think I’m hacking too much at it :P.

April 17, 2013 at 12:44 pm 2358
Tareq Hasan Tareq Hasan

I think you are searching the wrong thing. Can you paste the function that displays the location meta box in the theme?

April 17, 2013 at 1:15 pm 2362
retroga_me retroga_me

Hi Tareq!

This might be it:

http://pastebin.com/A1vrdzUz

It’s in functions-dir.php of the theme.

Sorry for all the hassle. If I get it to work though, I’ll do my best to promote the plugin with the theme users, since they’re all hoping that I can get it to work with the theme :).

Best regards,

Vincent

April 17, 2013 at 2:18 pm 2367
Tareq Hasan Tareq Hasan

You want to show the same meta box to the frontend, right? That’s not the page I was looking for. Wrong file 😉

April 17, 2013 at 2:55 pm 2368
retroga_me retroga_me

From what I can see they’re using
http://www.farinspace.com/wpalchemy-metabox/
to make the metaboxes somehow.

$dirItemOptions = new WPAlchemy_MetaBox(array

(

‘id’ => ‘_ait-dir-item’,

‘title’ => __(‘Options for item’, ‘ait’),

‘types’ => array(‘ait-dir-item’),

‘context’ => ‘normal’,

‘priority’ => ‘core’,

‘config’ => dirname(__FILE__) . ‘/’ . basename(__FILE__, ‘.php’) . ‘.neon’,

‘js’ => dirname(__FILE__) . ‘/’ . basename(__FILE__, ‘.php’) . ‘.js’,

));

Also, here’s the dir-item.php:

http://pastebin.com/S81NhtU1

Viewing 15 Posts - 1 through 15 (of 32 total)