Get template part with CPT and Custom Taxonomy conditionals

Your order of your if/else statement is wrong. You would want to have your complex condition (or most important condition) at the top and the simplest (or least important condition) at the bottom. if/else statements work on the basis that the first condition that hits true will be executed. In your example above, if you … Read more

Remove any product that is featured from regular display loop [WooCommerce]

Use the pre_get_posts filter to remove your sticked product from the product loop. add_action( ‘pre_get_posts’, ‘exclude_stycky_product’ ); function exclude_sticky_product(){ // target only the main query if ( ! is_admin() && $query->is_main_query() ) { $query->set(‘ignore_sticky_posts’); $query->set(‘meta_value’, ‘1’); } } Hope it helps you !

upload image only

I edited code if (!function_exists(‘wp_generate_attachment_metadata’)){ require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/file.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/media.php’); } if ($_FILES) { foreach ($_FILES as $file => $array) { $mime = $_FILES[$file][‘type’]; $filesize = $_FILES[$file][‘size’]; $maxsizef = 524288; if($filesize > $maxsizef) $error_array[] = ‘error size, max file size = 500 KB’; if(($mime != … Read more

How to display the featured post on the category page?

The problem is not in code to Displaying Feature post in category page. the problem is to add feature post meta into post. First, checked() by default echo, so you have to pass false attribute to prevent echo. function add_featured_meta_box($post){ $featured = get_post_meta($post->ID, ‘_featured-post’, true); echo “<label for=”_featured-post”>”.__(‘Feature this post?’, ‘foobar’).”</label>”; echo “<input type=”checkbox” name=”_featured-post” … Read more

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