Community Forums › Forums › Archived Forums › General Discussion › Post Meta not appearing on custom post types
Tagged: Custom Post Type, post meta not showing
- This topic has 1 reply, 1 voice, and was last updated 7 years, 6 months ago by David Borrink.
-
AuthorPosts
-
October 4, 2016 at 8:17 pm #194240David BorrinkParticipant
I have added a custom post type called "news" to a site, and also a custom taxonomy of "news categories" and "news tags" for it. They're showing up fine in the dashboard and I've assigned a test category and tag to one post to test. On the archive for "news", the posts show up, but the post meta does not.
I found the genesis_post_meta function in the post.php file and what stood out to me was the line that said...
* By default, only does post meta on posts.
That seems to be my problem. It also says,
* @return null Return early if post type lacks support.
I've dug around the WordPress codex and have done searches to see how to add this support for my custom post type but I can't find anything. What do I need to do to have the entry meta show up? It's fine on blog posts, and I'm using the Genesis Sample as my base for this project.
Here is all my code for adding the custom post type and taxonomy to my site:
//* Add a custom post type add_action( 'init', 'mpp_post_type' ); function mpp_post_type() { // Project custom post type register_post_type( 'news', array( 'labels' => array( 'name' => __( 'News' ), 'singular_name' => __( 'News Item' ), 'add_new_item' => __( 'Add New News Item' ), 'edit_item' => __( 'Edit News Item'), 'view_item' => __( 'View News Item'), 'taxonomies' => array( 'news-category','news-tag' ), ), 'has_archive' => true, 'public' => true, 'show_ui' => true, // defaults to true so don't have to include 'show_in_menu' => true, // defaults to true so don't have to include 'rewrite' => array( 'slug' => 'news' ), 'supports' => array( 'title', 'editor', 'author', 'excerpt', 'comments', 'genesis-seo', 'thumbnail','genesis-cpt-archives-settings' ), ) ); } // hook into the init action and call create_news_taxonomies when it fires add_action( 'init', 'create_news_taxonomies', 0 ); // create two taxonomies, News Categories and New Tags for the post type "news" function create_news_taxonomies() { // Add new taxonomy, make it hierarchical (like categories) $labels = array( 'name' => _x( 'News Categories', 'taxonomy general name', 'textdomain' ), 'singular_name' => _x( 'News Category', 'taxonomy singular name', 'textdomain' ), 'search_items' => __( 'Search News Categories', 'textdomain' ), 'all_items' => __( 'All News Categories', 'textdomain' ), 'parent_item' => __( 'Parent News Category', 'textdomain' ), 'parent_item_colon' => __( 'Parent News Category:', 'textdomain' ), 'edit_item' => __( 'Edit News Category', 'textdomain' ), 'update_item' => __( 'Update News Category', 'textdomain' ), 'add_new_item' => __( 'Add New News Category', 'textdomain' ), 'new_item_name' => __( 'New News Category Name', 'textdomain' ), 'menu_name' => __( 'News Categories', 'textdomain' ), ); $args = array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'news-category' ), ); register_taxonomy( 'news-categories', array( 'news' ), $args ); // Add new taxonomy, NOT hierarchical (like tags) $labels = array( 'name' => _x( 'News Tags', 'taxonomy general name', 'textdomain' ), 'singular_name' => _x( 'News Tag', 'taxonomy singular name', 'textdomain' ), 'search_items' => __( 'Search News Tags', 'textdomain' ), 'popular_items' => __( 'Popular News Tags', 'textdomain' ), 'all_items' => __( 'All News Tags', 'textdomain' ), 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __( 'Edit News Tags', 'textdomain' ), 'update_item' => __( 'Update News Tag', 'textdomain' ), 'add_new_item' => __( 'Add New News Tag', 'textdomain' ), 'new_item_name' => __( 'New News Tag Name', 'textdomain' ), 'separate_items_with_commas' => __( 'Separate News Tags with commas', 'textdomain' ), 'add_or_remove_items' => __( 'Add or remove News Tags', 'textdomain' ), 'choose_from_most_used' => __( 'Choose from the most used News Tags', 'textdomain' ), 'not_found' => __( 'No News Tags found.', 'textdomain' ), 'menu_name' => __( 'News Tags', 'textdomain' ), ); $args = array( 'hierarchical' => false, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'update_count_callback' => '_update_post_term_count', 'query_var' => true, 'rewrite' => array( 'slug' => 'news-tag' ), ); register_taxonomy( 'news-tag', 'news', $args ); }
October 5, 2016 at 8:20 pm #194280David BorrinkParticipantI discovered that I had two errors in the code as my taxonomies array and rewrites had the wrong spelling. I had “news-category” in those two while my taxonomy is called “news-categories”.
But that didn’t help. Still no entry meta display. But entry info is showing at the top of the posts. Why entry meta isn’t showing is odd. I’ve found posts where people are showing how to remove entry metas. I’d just like to know why mine isn’t showing.
My HTML says
<footer class="entry-footer"></footer>
. In a regular blog post there is a<p class="entry-meta">
inside there. -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.