php


Woocommerce's functions shortcode


Let's say I want render some element of single product page of woocommerce, on any other page in wordpress exactly the same way. I would like just put a shortcode with a product ID on my page and for example product gallery will render. The problem is that I don't understand PHP in fact but I don't give up.
I figured out that it is possible create a custom function in the file functions.php located in my child theme...
function my_function() {
return 'Hello!!';
}
...and then put my shortcode
add_shortcode('my_shortcode', 'my_function');
The question is How can I put into body of my function a method used by woocommerce? I guess, for this case it is following:
wordpress\wp-content\plugins\woocommerce\templates\single-product\product-image.php
Thanks for help!
WooCommerce already has this shortcode available:
[product id="99"]
[product sku="FOO"]
Please refer to the documentation for more information https://docs.woocommerce.com/document/woocommerce-shortcodes/
Also, if you need this in a template, you can simply add:
echo do_shortcode('[product sku="FOO"]');

Related Links

How to compare a session variable to a row in a table
Access stdClass Object using Ajax
How to add token in url without showing it to the client when opened
sql sum of results
multiple submit on same page with php ajax
mod_rewrite PHP API user resource
Creating pages automatically
How to refresh the current page
php app.yaml google app engine launcher
Selecting only newest related entries from joined table [duplicate]
Laravel Routing with alias
Adding new item in embed form Symfony doesn't work
XML body in php mail
PHP why is dirname() returning a dot?
PHP - Fetch Previous Month from Current Month
Laravel Long-polling chances of showing the data

Categories

HOME
memory
dafny
initialization
whmcs
websocket
nsis
amp
apache-kafka-connect
onvif
anchor
mailing-list
gtk
fireloop
parsley.js
jodatime
google-tasks-api
uima
asciimath
cocos2d-android
spam
social-tables
altium-designer
candlestick-chart
substring
cell
opentext
jpa-2.1
router
unrar
background-color
react-bootstrap-table
django-import-export
cube
envoy
d3.js-v4
epplus
appcode
listjs
cloveretl
buildforge
djcelery
code-rally
cartopy
reset
windows-store
swfupload
suds
ejml
jshint
non-linear-regression
redisson
mongodb-aggregation
sesame
kendo-editor
rational-performance-test
java-2d
libharu
dcount
svnserve
always-on-top
fiber
deferred-rendering
adp
frame-grab
processor
jemdoc
currency-exchange-rates
onepage-checkout
voronoi
msgpack
ambiguity
roxygen2
bootstrap-wysiwyg
explain
python-curses
mxe
baseadapter
fasterxml
adhoc-polymorphism
tabris
back
communicate
miglayout
pre
typesafe-stack
iosched
strdup
coalesce
jquery-cycle
session-0-isolation
red-system
ckeditor.net
ip-geolocation
stretch
audiotoolbox
uitextfielddelegate
autosize
mkannotation
acpi
quartz-core
qtextbrowser
net-use
firefly-mv
botnet
sql-parametrized-query
solandra
mongrel
rational-unified-process
projectpier

Resources

Encrypt Message