1

In MODX, there's a checkbox on posts that will hide it from the main navigation and the post query. This is a very good way of making the post private for reviewing or simply having the post accessible only if you know the link.

I'm using custom post types and I want to add custom fields to hide or unhide this post whenever I want to. What's the best way to do this?

1 Answer 1

0

You can create a Custom Field radio button called hide_from_menus with values yes or no t then use Query posts by custom fields.

Then in your query, add meta_key and meta_value. Example:

      $args=array(
        'post_type' => custom-post-type,
        'post_status' => 'publish',
        'posts_per_page' => -1,
        'meta_key'    => 'hide_from_menus',
        'meta_value'  => 'yes' 
      );

Be sure though that you update all your posts (re-publish) so that it will have the key value that you specified.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.