I am a beginner to wordpress (and to php for that matter).
I am trying to understand some of the basics, and building a little e-commerce store using a plugin called “Jigoshop.”
I’m reading through the source files and seeing a bunch of useful functions- things like a “is_featured” function that returns true if the product has a product meta that marks it as featured; or a reference to all products that I can use without having to set up my own by querying the posts and filtering out those that are not products.
I have a custom-template file that I am using for the storefront (homepage), and I would like to access some of these functions to simplify the code I have to write, but it seems I don’t have access to them.
My questions is:
Are functions and objects defined in a plugin useable in my theme templates (or custom templates; I’m using a child theme right now)?
2 s
Yes, you can use functions from plugins in your theme. Please use the function_exists() function to make sure that the function does exit. I used the Breadcrumbs Plus in one of the themes like this:
<?php
if (function_exists('breadcrumbs_plus'))
{
$breadcrumb_options = array(
'prefix' => '<div id="breadcrumb">',
'suffix' => '</div>',
'title' => 'Du er her: ',
'home' => 'Forside',
'sep' => "https://wordpress.stackexchange.com/",
'front_page' => false,
'bold' => false,
'blog' => __('Blog', 'rev'),
'echo' => true
);
breadcrumbs_plus($breadcrumb_options);
}
?>