Support » Plugin: Pods - Custom Content Types and Fields » Page With My PHP Code Now Displaying Differently

  • Resolved burtons

    (@burtons)


    I’m not sure if this is a WordPress problem, a Woocommerce problem, or a Pods problem. The code below allowed me to show a Pods custom field at the bottom of a Woocommerce product page. It was working just fine until recently. I really don’t know PHP at all, but was able to hobble this together from examples of other code that I found. With this code active, now the page displays in a frame. The product photos do not show and the WordPress logged-in admin bar does not display. I also get this message where the field would be displayed: The site is experiencing technical difficulties.

    Any ideas as to why this would now suddenly be the case or any other insights would be greatly appreciated!

    add_action( 'woocommerce_after_single_product', 'display_pod_product_bottom', 30 );
      
    function display_pod_product_bottom() {
      echo '' . get_field('product_page_bottom_pod');
      // Note: 'product_page_bottom_pod' is the slug of the Pods Field
    }

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hello @burtons
    get_field() isn’t a Pods function and never was. Aren’t you mistaking Pods for ACF?
    Regards, Jory

    burtons

    (@burtons)

    Thank you Jory. That bit of information helps. I modified the code from something I found that was made for ACF. Interestingly it worked fine as long as I had ACF installed, but when I deleted ACF if stopped functioning. I am now trying to figure out what I can use instead of get_field().

    Any further insights or solutions would still be greatly appreciated!

    Thanks, Sidney

    Plugin Author Jim True

    (@jimtrue)

    Field is our pods function, but you have to open a Pods object for that. You should probably be using get_post_meta which is the preferred WP method if you’re on the current post

    Plugin Author Jim True

    (@jimtrue)

    You could also use Pods Templates with Auto Templates set to the woocommerce_after_single_product

    Check out the Grow Beyond Video:
    https://docs.pods.io/videos/grow-beyond-posts-pages-introduction-pods-framework/

    Thank you, Jim. I was able to sort it out after you pointed me in the right direction.
    I used this code:

    add_action( 'woocommerce_after_single_product', 'display_pod_product_bottom', 30 ); 
      
    function display_pod_product_bottom() {
    	$product_page_bottom_pod = get_post_meta( get_the_ID(), 'product_page_bottom_pod', true );
    	echo $product_page_bottom_pod;	
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.