N
N
Nikitos082016-10-31 17:16:11
PHP
Nikitos08, 2016-10-31 17:16:11

The post id got out in the frontend, what is the reason?

I display parts of the template by checking the product category by id , and this id is displayed in my top corner of the page. What is the problem?

global $wp_query;

$cate = get_queried_object();
$cateID = $cate->term_id;

echo $cateID;

if ( $cateID == "21") {
  woocommerce_get_template( 'content-benzin.php' );
}

elseif ( $cateID == "22") {
  woocommerce_get_template( 'content-disel.php' );
}

elseif ( $cateID == "318") {
  woocommerce_get_template('content-generators.php');
}

elseif ( $cateID == "319") {
  woocommerce_get_template('content-kompressors.php');
}

elseif ( $cateID == "156") {
  woocommerce_get_template('content-motopompy.php');
}

elseif ( $cateID == "467") {
  woocommerce_get_template('content-production.php');
}

else {
  wc_get_template( 'archive-product.php' );
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Vorotnev, 2016-10-31
@Nikitos08

take awayecho $cateID;

S
Svyatoslav Belimov, 2016-11-02
@belimovlab

Are you seriously?! No, really. I agree everyone makes mistakes. Not every time we can all find an obvious mistake that is in front of our eyes. But still.
I just really hope you don't take on freelancing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question