The error is indicating that a method function (get_attribute()
) is attempting to be called on a variable that is set to null
. This means that the $product_object
variable is not populated with an instance of a class that has a method definition for get_attribute()
, but rather is null
.
You’ll need to figure some other way to get the current product object. If you’re in the admin editing a product, then you can get the product ID from a query parameter, and create the object using wc_get_product()
. If you’re on the frontend looking at a single product, then you can get the product ID from get_queried_object_ID()
.
Related Posts:
- Inserting Gravity Form checkbox values into Advanced Custom Fields [closed]
- The values of custom fields are not available functions.php
- Problem with ACF shortcode with Repeater Field in WordPress? [closed]
- ACF: how do I get the fields and its values of a specific group?
- Download PDF after CF7 form submission
- How to create an ACF shortcode with Repeater Field in WordPress? [duplicate]
- HTML Special Characters in URL string [closed]
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- How can I count ACF sub_field with a certain value
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Delete images from media library when user deletes an image from ACF Gallery
- Advance custom fields variable with if statement & Function
- PHP/CSS: Shortcode won’t display correctly, and only displays in the head (before content)
- Page returning ID from array, how to return the correct values for post in acf wordpress
- ACF Date fileds to Age Convert [closed]
- Custom WordPress Function – Adding items from Foreach Loop into an array and Updating Field based on array of IDs (ACF + WooCommerce)
- Creating posts with php-script + csv
- ACF number less than comparison not working
- Display all values of custom a field created with ACF on a page
- start_lvl Ignored in Custom walker_nav_menu
- Allowed memory size of 268435456 bytes exhausted (tried to allocate 7146491840906359738 bytes)
- How do I make my function add variables/values to the $post object?
- How do I get the author’s page url from their ID?
- Calculate percentage of post by category
- Change comments form title on a page by page basis
- Creating wordpress user registration form
- Get the title before comma
- How do I know what variables are passed in a filter/action and what their meaning is?
- “Can’t use function return value in write context” error
- Display 4 chronological posts starting with a random post
- my function doesn’t return my post from today
- Wrap each shortcode in array to div
- Warning: array_pop() expects parameter 1 to be array, boolean given
- How to Display Image Meta underneath EVERY image in EVERY post
- ACF: Only get first row of a Repeater Field
- get_the_terms – only top level
- Have CSS Class Added with `is_page()` WP function
- Slide in Panel WordPress Post
- Run a filter when a walker runs
- Swapping wp_dropdown_categories function with wp_category_checklist
- Display fields as values in array from external SQL DB
- Passing the custom field values in the wp_get_current_user array function
- Populate dropdown with Child Pages based on Parent Page chosen
- How can I remove a function that has been added to wordpress with add_filter?
- Get value from shortcode to do something
- PHP 8, AJAX mail form to function.php doesn’t work
- Custom shortcode outputs plain text instead of HTML at top of post
- how can i use $_COOKIE[] + PostID to execute the below code?
- What’s the uses of wp_cache_set() or wp_cache_add()?
- Create Page To Count Comments For Each Post In WordPress Site
- Can’t find infinite loop cause
- how to make custom ajax handler?
- How to disable controls in theme customizer?
- Moving code from theme header to functions.php
- Best way to use a large array in function
- Setting user nickname and displayname to shortened email
- ::before on open/close function [closed]
- Creating a mobile site by adding a new class to the body tag from functions.php
- Export Form Data to a CSV then send it as an attachment – contact form 7
- Issue with fetching mysql data and displaying results via shortcode in webpage
- How do I create a function that modifies a message in the wp-login.php file?
- Cant display an image via PHP in wordpress
- Template Loop – add switch case php
- Call to undefined function error in plugin
- How do I correct the code in php? [closed]
- Image rotation issue (horizontal picture uploading as vertical) — Exif issue?
- Unable to Call More than One Meta Box Output
- How can I alter this code to accept a slug as well as an ID?
- Menu not styling. New menus functionality giving me a headache
- Disclaimer that will show every refresh of the page
- Dynamically switch file in get_template_directory_uri() | Function [closed]
- Adding an “Upgrade Subscription” button to an Elementor page
- Dropdown category field inside repeatable metabox
- Retrieve alt text by referencing the img src
- Custom function that re-writes page title breaks when the Yoast plugin is activated
- Ajax filter with loadmore button
- Set ACF on order during checkout
- update_user_meta as multiple value but with same meta key
- Delete post meta by serialized meta value
- Get field value and use as variable in php
- Create a temporal post
- How to bind each “the_content” elements to a custom variables
- Trying to publish a little bit of Javascript on the homepage AND at the bottom
- Add parent menu item in sub-menu in custom nav_walker
- How can I copy an ACF field to AIOSEO field? [closed]
- Custom Bulk Actions handler not firing
- Get field in readable word
- How can disable wordpress emails notifications?
- Else if Statement for Advanced Custom Fields [closed]
- Custom Taxonomy as Link
- How to fix blank pagination links?
- main menu page redirects to user ID
- How to have Function of a plugin using global vars into a shortcode?
- adsense code showing on random post thumb
- How can I clear the theme mod settings?
- Cant get theme to change footer color through theme customizer
- How to extend the page editor?
- How do I get Roboto Google Font to display normal font-style? [closed]
- WP Custom tables query
- In WordPress how do you remove render-blocking CSS manually without a plugin?