Post Info don't show on CPT


Hello Thierry,

I'm using the last version of Beans (1.3.1-rc).

I've created a "job" custom post type and a single-job.php template.

Everything works very well, except one thing : post info (date, author, etc.) don't appear by default. Is it a issue/bug ? Or is it normal ? If so, what is the best thing to do ?

Thank you in advance for your help !

Mathieu


Hey Mathieu,

This is an intentional behavior, post meta are only added for the post post type. As for pretty much everything is Beans, it is quite flexible and can easily be added for other post type, in this case using the beans_pre_post_meta filter. If you look at its Code Reference, you will see that it says "True to short-circuit, False to let the function run".

So if you want the post meta to be displayed on all post types (including pages etc.), then you can add the following line in your child theme functions.php

add_filter( 'beans_pre_post_meta', '__return_false' );

This never short-circuit and therefore always display post meta. If you need to apply a condition, then you will need to run a callback as follow:

add_filter( 'beans_pre_post_meta', 'example_pre_post_meta' );

function example_pre_post_meta( $pre ) {

 // Don't short-circuit for 'job' post type.
  if ( 'job' === get_post_type() ) {
    return false;
 }

 return $pre;

}

Some other short-circuit filters are available for other post fragments, you may find all that in the Fragments Post Code Reference or straight in Beans code in lib/templates/fragments/post.php.

Happy coding,


Thanks a lot Thierry. Seems that I've some progress to make in the global understanding of Beans... But I'm working on it ! Thanks again !


You are doing very very well, keep learning and producing awesome stuff 😉

Glad to have you part of the Beans community,


The code will show the default post meta. How would we display Custom Post Type taxonomy category (ies) and tags on the CPT posts? (CPT's are made through CPTUI plugin.)

Write a reply

Login or register to write a reply, it's free!