Target pages using Woo Commerce single product page template

You can use is_product() WooCommerce conditional tag to identify if its single product page. Below is example code which enqueues test.js if its a single product page. You may use and tweak this code snippet further. function mytheme_scripts() { if ( is_product() ) { wp_enqueue_script( ‘test-js’, get_template_directory_uri() . ‘/js/test.js’, array() ); } } add_action( ‘wp_enqueue_scripts’, … Read more

Edit single page from plugin

You could do this with the the_content filter: /** * Adds some text to bottom of the content on ‘season’ pages. * * @param string $content The current content of the season page. * @return string The new content of the season page. */ function add_season_content( $content ) { if ( is_singular( ‘season’ ) && … Read more

Using template file for single post in sub-directory multisite

Use STYLESHEETPATH instead of TEMPLATEPATH. You’ll find the definitions in wp-includes/default-constants.php file. Please have look. So your code block will be like below- //Gets post cat slug and looks for single-[cat slug].php and applies it add_filter(‘single_template’, create_function( ‘$the_template’, ‘foreach( (array) get_the_category() as $cat ) { if ( file_exists(STYLESHEETPATH . “/single-{$cat->slug}.php”) ) return STYLESHEETPATH . “/single-{$cat->slug}.php”; … Read more

How to get adjacent_post custom_field value

I think I solved the problem in this way: I get the custom field data using get_post_meta: <?php $prev_post_type = get_post_meta($prev_post->ID, ‘_product_type’, true);?> and then I use it to customize the link: <a href=”https://wordpress.stackexchange.com/questions/252475/<?php echo get_permalink( $prev_post->ID ); ?>”><?php echo $prev_post_title .” “. $prev_post_type ?></a>

Related Posts with removing some categories

You can use the category__not_in parameter to exlude categories. get_posts uses the WP_QUERY parameters Your code will be : $related = get_posts( array( ‘category__in’ => wp_get_post_categories($post->ID), ‘numberposts’ => 5, ‘post__not_in’ => array($post->ID), ‘category__not_in’ => array(1,2,3,4)’ ) );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)