1

I'm setting up a marketplace-style website for local furniture makers and vintage shops, using WordPress with WooCommerce and the WooCommerce Vendor Stores plugin. In order to create more complete vendor profiles, I'm using Advanced Custom Fields to add new fields to the vendor stores, which are taxonomies.

Here's what I've done so far:

  1. Installed ACF and created a field group and custom field.
  2. The custom fields will need to be on my vendor pages, which are set up as taxonomies via the Vendor Stores plugin so I added this code to the template:

    <?php the_field('vendor-style'); ?>
    

Nothing appeared when I uploaded the file, added some info to a vendor profile and saved.

  1. I figured it was something with the taxonomy thing, so I then looked up some info about including terms, and tried this (vendor-store is the taxonomy term).

    <?php the_field('vendor-style', 'vendor-store'); ?>
    
  2. Nothing showed up, so I tried following this advice: ACF fields not showing on a wordpress custom taxonomy page and that didn't work.

When I turned on debugging, I got the following error message on my vendor page:

Notice: Trying to get property of non-object in /nas/wp/www/cluster-2626/foundlocal/wp-content/themes/hub/includes/integrations/woocommerce/template.php on line 124 class="archive tax-shop_vendor term-isabella-sparrow term-52 logged-in admin-bar no-customize-support woocommerce woocommerce-page woocommerce-demo-store ignitewoo_vendor_stores vendor_store isabella-sparrow chrome alt-style-default layout-left-content has-lightbox ">

The line that this error message is referring to is:

$single_layout = get_post_meta( $post->ID, '_layout', true );

Anyone have any suggestions? I'm trying to finish this today, and feel like I'm just spinning in circles at this point.

Community
  • 1
  • 1
  • Is the `$single_layout` line in question within the Loop? – rnevius Oct 26 '14 at 13:24
  • I'm not sure, exactly. And that might be the problem. :-) How would I determine that? I'm sure it's obvious now, but I should mention that I'm pretty new to PHP. – lindsayifill Oct 26 '14 at 13:36
  • Can you try to place a `global $post` above that line, first? – rnevius Oct 26 '14 at 13:38
  • Sure, I just tried that and then got the same error, but with line 125. Here's what that whole bit of code looks like:global $woo_options, $post; $single_layout = get_post_meta( $post->ID, '_layout', true ); $layout = ''; – lindsayifill Oct 26 '14 at 13:42
  • It seems like it's not recognizing `$post` as an object...which it is, as long as you're accessing it within [The Loop](http://codex.wordpress.org/The_Loop). You can determine whether or not it's within the loop by looking for something like `if ( have_posts() ) { while ( have_posts() ) {` above that problematic line. Alternatively, you may try using `get_the_ID()` in place of `$post->ID`. – rnevius Oct 26 '14 at 13:46
  • I just edited/saved without the global $post in there. – lindsayifill Oct 26 '14 at 13:46
  • I didn't see anything like if ( have_posts() ) { while ( have_posts() ) so I tried replacing $post->ID. When I refreshed, the PHP error message was no longer there, but neither were the fields I'd added. (Thank you SO MUCH for this help, by the way.) – lindsayifill Oct 26 '14 at 14:06
  • I was going to add you to a Stack Overflow chat, but it doesn't look like you have enough reputation...Can you walk me through what exactly is going on? The way I'm interpreting it: You created a custom meta in the admin called `'vendor-style'`, and you want this to be rendered on the vendor pages? – rnevius Oct 26 '14 at 14:18
  • Yeah, so I used the Advanced Custom Fields plugin to add custom fields to this "vendor profile" so that I can show things like vendor style, location, extra images, etc. The one weird thing is that vendors (w/this plugin) are set up as taxonomies as opposed to a custom post type. Does that make sense? – lindsayifill Oct 26 '14 at 15:10
  • I'm wondering whether there is code beyond the that I should be including in the template file. In the documentation of ACF, I found this:http://www.advancedcustomfields.com/resources/get_field/. Am I only doing half of what needs to be done if I'm just calling the field w/the_field? – lindsayifill Oct 26 '14 at 15:29
  • Are they taxonomy fields? Example: http://www.advancedcustomfields.com/resources/taxonomy/ – rnevius Oct 26 '14 at 15:32
  • You may want to try replacing it with: `` – rnevius Oct 26 '14 at 15:33
  • I tried replacing the code, and I did try changing the field type to Taxonomy, but while neither generated any php errors, I still can't get the darn things to appear. – lindsayifill Oct 26 '14 at 16:49
  • I'm sure this has to do with the fact that those pages are not actual pages...they're taxonomies. I'm not familiar with the plugin you're using, and it's hard to know more without seeing the back end. I'm more than happy to help; but am not sure the Stack Overflow format is going to work for this one. Feel free to contact me, if you can't figure things out. – rnevius Oct 27 '14 at 08:34

0 Answers0