The product ID is necessary to display a specific product via the product-shortcode.
There are generally 2 ways to find out the product ID.
1) the product URL in the backend, there you can find the product ID:
2) You add the product ID into the product overview. This can be done with just a few lines of code. When using the ChildTheme, simply add the code using the functions.php:
[pastacode lang=”php” manual=”add_filter(‘manage_product_posts_columns’%2C%20’at_product_id_row’)%3B%0Afunction%20at_product_id_row(%20%24defaults%20)%20%7B%0A%20%20%20%20%24defaults%5B’product_id’%5D%20%20%3D%20__(‘Produkt-ID’%2C%20’affiliatetheme-backend’)%3B%0A%20%20%20%20return%20%24defaults%3B%0A%7D%0A%0Aadd_action(%20’manage_product_posts_custom_column’%2C%20’at_product_id_row_action’%2C%2010%2C%202%20)%3B%0Afunction%20at_product_id_row_action(%20%24column_name%2C%20%24post_id%20)%20%7B%0A%20%20%20%20if%20(%24column_name%20%3D%3D%20’product_id’)%20%7B%0A%09%09echo%20%24post_id%3B%0A%20%20%20%20%7D%20%20%20%0A%7D” message=”” highlight=”” provider=”manual”/]
Preferably all the way to the end.
If you are not using the ChildTheme you can also add it as a plugin. Simply access your installation via FTP and create the folder “mu-plugins” in the folder “wp-plugins”. Afterwards you can create a file there (e.G product_id.php) and add the following code:
[pastacode lang=”php” manual=”add_filter(‘manage_product_posts_columns’%2C%20’at_product_id_row’)%3B%0Afunction%20at_product_id_row(%20%24defaults%20)%20%7B%0A%09%24defaults%5B’product_id’%5D%20%3D%20__(‘Produkt-ID’%2C%20’affiliatetheme-backend’)%3B%0A%09return%20%24defaults%3B%0A%7D%0A%0Aadd_action(%20’manage_product_posts_custom_column’%2C%20’at_product_id_row_action’%2C%2010%2C%202%20)%3B%0Afunction%20at_product_id_row_action(%20%24column_name%2C%20%24post_id%20)%20%7B%0A%09if%20(%24column_name%20%3D%3D%20’product_id’)%20%7B%0A%09%09echo%20%24post_id%3B%0A%09%7D%0A%7D” message=”” highlight=”” provider=”manual”/]
After that you save the data. Now you will see a new register that displays the product ID under the register “Products” in your backend.
Additional information about adding functions can be found HERE.
War dieser Artikel hilfreich?
Keine Kommentare vorhanden