php - Get custom post type category and list all posts with the same category -


the problem have follows:

  • i have custom post type named 'x'.

  • it has few categories named 'category_1', 'category_2', 'category_3' etc.

  • by logic of website, 1 post can have 1 category or no category @ all.

on page single-x.php (single-posttypename.php) want check, if post has category @ all, if has, want other posts same category, , provide them sub-navigation. if post not have category nothing.

<ul>   <li class="active"><a href="link-to-post1">post1</a></li>   <li><a href="link-to-post2">post2</a></li>   ... </ul> 

for current post, want add class active act navigation.

you can have check this

$x= $_post['x']; if(isset($x) && $x!='') {  $customise_category = $x;  }  else        {        $customise_category = '';        } 

you can use $customise_category needed.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -