Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

if in category but only with post meta

It looks like you just have an operator precedence issue.

Your logic here will always return true if $stat == ‘Sold Stat’ regardless of the result of in_category(‘secret-category’).

Try this, the extra parenthesis will force the || statement to be evaluated separately:

    if (in_category('secret-category') && ($stat == 'NFS Stat' || $stat == 'Sold Stat')) {
        echo 'Do something here.';
    }

Related Posts:

  1. Customize rel=canonical tag for single blog post
  2. Post meta not working
  3. How to add category to: ‘wp-admin/post-new.php’?
  4. Setting Custom Sort Order of Posts within a Category
  5. Add a checkbox to post screen that adds a class to the title
  6. Convert custom fields to post categories
  7. Update all posts automatically when using post_meta
  8. How to change the layout and styling of posts according to their category in WordPress?
  9. Prevent duplicate posts in wp_insert_post using custom fields
  10. Better post meta efficiency?
  11. Add default content to post (for specific category)
  12. Add custom field to all posts in specific category
  13. Show One Category on Post
  14. Add custom field to category of custom post type
  15. Change post format using custom field
  16. Sanitizing `wp_editor();` Values for Database, Edit, and Display
  17. Do I use custom post type or something else?
  18. Add custom fields to post programmatically
  19. Custom Theme Want To Remove One Category From All Displays
  20. What Is meta_id In wp_postmeta?
  21. Add custom field automatically (add_post_meta) with value based on number of words of article
  22. Edit custom post type admin menu link
  23. Deleted category by mistake, all posts now have categorized category. Can i revert that?
  24. How can I sort posts by the date and a custom meta field?
  25. How can i limit the number of posts created per category?
  26. WordPress custom Query for Posts in Category display posts multiple times
  27. Categories list into registration form
  28. Getting value from get_post_custom
  29. Add a custom meta box in the post options that loads some html code in the header
  30. Calling Different Custom Post Timestamps in a table
  31. WordPress Multisite – Create Default Post and New Category On New Site Install
  32. Set Default Category to Username
  33. Cannot retrieve a custom RSS field from posts
  34. Redirect to another page using contact form 7? [closed]
  35. How to I retrieve the ID from the Posts page?
  36. Edit multiple custom post types while saving a new or edited post
  37. Display post number by category
  38. Saving Post Data in Another Database
  39. How to call posts under a specific category on static front page?
  40. Add multiple meta keys to a post at once
  41. Static pages not working
  42. saving/reading custom field value does not work – no value gets POSTed
  43. Simple Custom Metabox Not Saving
  44. How to display only one category in a custom post type?
  45. Get post category as a separate string and url
  46. Can I style single post that are in multiple catergories?
  47. Only the most recent post is showing on my category page (working on localhost, not live site)
  48. How to bulk Update URLs to new values?
  49. Adding an option to post editor to show a site disclaimer or message
  50. Is there a way to save different data when USER interacts with the same POST?
  51. How do you update post date (year only) in a separate custom field?
  52. Re-order Category Meta-data
  53. Custom post styling per category?
  54. WP_Query sort by meta_value_num or date
  55. Show custom post category for single post
  56. Add Categories To Custom Post
  57. Creating Ordered Query using Meta_key
  58. Static text above category page
  59. Order posts by separate menu order for different sub-categories
  60. How to only allow post to be deleted if custom field doesn’t exist
  61. Show a Category Specific Info Box
  62. Delete old post with new post
  63. Add default content to post (for specific category)
  64. Display ONLY Latest Post From Several Categories
  65. First Custom Post Custom Fields Empty After New Custom Post
  66. How to Do Custom Fields to Output a Definition List
  67. How enter custom post meta or custom field on box post list archive page?
  68. Taxonomy Category category.php not working
  69. Post’s arent displaying
  70. Only show posts belonging to multiple cateogries at same time
  71. Site ‘Categories’: save an admin global setting with post metadata [closed]
  72. I have a website issue I am trying to resolve
  73. Retrieving posts by their date and category
  74. Get latest post from categories
  75. How to create a playlist for audio associated with posts per category
  76. When sending a newsletter -not with wordpress- the server has 100% cpu [closed]
  77. Are post, page and category IDs unique to each other?
  78. Retrieve data from post meta meta_key having ‘_product_fq_image’ while having author_id and post type is PRODUCT
  79. Change the background of each post according to the category
  80. Insert data from custom created PHP page into wp_postmeta table
  81. Optimize CPT-function with a loop
  82. Post-Archive like a page in a specific subdirectory
  83. Programmatically add posts from specific category to menu
  84. Adding a meta box to determine the sidebar [closed]
  85. The loop starting at a certain ID
  86. WP_Query of Category Not Showing First Post
  87. Add post tags to previously created custom post type
  88. If custom field is empty, use one from a previous post
  89. Can WordPress handle following functionalities?
  90. Post is in descendant category not working in home.php
  91. WordPress displays post on subcategory only
  92. How to get posts ordered by using their categories?
  93. Get a term each custom post type
  94. Remove Featured Image from posts in specific category?
  95. Change default post style to columns
  96. Post titles and thumbnails as links to custom post types?
  97. How to show a featured image inside a post in only 1 single category
  98. Custom Post Type, post-formats associated to custom post type > 404 archives
  99. Hide parts of the post content after typing it’s name or searching it by category
  100. SQL Bulk Move old posts by one author to another category
Categories posts Tags categories, custom-field, customization, post-meta, posts
css to fit image by HEIGHT
ajax request in wordpress

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress