Retrieve WordPress root directory path?

Looking at the bottom of your wp-config.php file in the wordpress root directory will let you find something like this: if ( !defined(‘ABSPATH’) ) define(‘ABSPATH’, dirname(__FILE__) . “https://stackoverflow.com/”); For an example file have a look here: http://core.trac.wordpress.org/browser/trunk/wp-config-sample.php You can make use of this constant called ABSPATH in other places of your wordpress scripts and in … Read more

How To Include CSS and jQuery in my WordPress plugin?

For styles wp_register_style( ‘namespace’, ‘http://locationofcss.com/mycss.css’ ); Then use: wp_enqueue_style(‘namespace’); wherever you want the css to load. Scripts are as above but the quicker way for loading jquery is just to use enqueue loaded in an init for the page you want it to load on: wp_enqueue_script(‘jquery’); Unless of course you want to use the google … Read more

WordPress query single post by slug

From the WordPress Codex: <?php $the_slug = ‘my_slug’; $args = array( ‘name’ => $the_slug, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘numberposts’ => 1 ); $my_posts = get_posts($args); if( $my_posts ) : echo ‘ID on the first post found ‘ . $my_posts[0]->ID; endif; ?> WordPress Developper Resources Get Posts

Get custom product attributes in Woocommerce

Edited: The woocommerce_get_product_terms is deprecated since Woocommerce version 3 Go with the following as @datafeedr wrote in his answer: global $product; $koostis = array_shift( wc_get_product_terms( $product->id, ‘pa_koostis’, array( ‘fields’ => ‘names’ ) ) ); or even more compact: global $product; $koostis = $product->get_attribute( ‘pa_koostis’ ); Original answer: $result = array_shift(woocommerce_get_product_terms($product->id, ‘pa_koostis’, ‘names’));