Archived topic
Structured Data > hatom "missing Author"
27 replies · Started by Henry Bowman on December 27, 2017
Good news! :)
Ok, sorry it still exists on other pages, I thought it will be gone on all pages (35) now.
Ah, well that's a different issue. It's a single post, but you've removed the title, author and date.
I suppose you could remove the class that tells Google to look for those elements:
add_filter( 'post_class', function( $classes ) {
$classes = array_diff( $classes, array( 'hentry' ) );
return $classes;
} );
Ok, that worked, thank you!
But I think I did not remove these parts on purpose. Where could I add them again?
The posts title is not deactivated in the backend, and I thought author and date are already coming from the posts date, and the users name.
The post meta can be removed in "Customize > Layout > Blog". If they're activated in there, maybe you have some custom functions added?
The content title is likely removed using a custom function as well.
"blog" has one drop down "Content type" and is set to "full" ("complete" (translated)).
Following the functions php. The front page title thing is only because one day my title from the front pages title field disappeared.
If this problem is to complicated, please let me know how much this would be for a job.
/*front page title*/
add_filter( 'document_title_parts', function( $title ) {
if ( is_front_page() ) {
$title['title'] = 'My Custom Title';
}
return $title;
} );
/*fix hatom missing author date*/
add_filter( 'post_class', function( $classes ) {
$classes = array_diff( $classes, array( 'hentry' ) );
return $classes;
} );
/**Portfolio Tab**/
function post_type_projects() {
register_post_type(
'portfolio',
array(
'label' => __('Portfolio'),
'public' => true,
'show_ui' => true,
'supports' => array(
'title',
'editor',
'post-thumbnails',
'custom-fields',
'revisions')
)
);
register_taxonomy( 'category-p', 'portfolio',
array(
'hierarchical' => false,
'label' => __('Projects'),
'query_var' => 'category-p',
'rewrite' => array('slug' => 'category-p' )
)
);
}
add_action('init', 'post_type_projects');
function wpbeginner_remove_version() {
return '';
}
add_filter('the_generator', 'wpbeginner_remove_version');
/*emoji*/
function remove_emoji()
{
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('admin_print_scripts', 'print_emoji_detection_script');
remove_action('admin_print_styles', 'print_emoji_styles');
remove_action('wp_print_styles', 'print_emoji_styles');
remove_filter('the_content_feed', 'wp_staticize_emoji');
remove_filter('comment_text_rss', 'wp_staticize_emoji');
remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
add_filter('tiny_mce_plugins', 'remove_tinymce_emoji');
}
add_action('init', 'remove_emoji');
function remove_tinymce_emoji($plugins)
{
if (!is_array($plugins))
{
return array();
}
return array_diff($plugins, array(
'wpemoji'
));
}
/*Footer width*/
add_filter('generate_footer_widget_1_width','tu_custom_footer_1_width');
function tu_custom_footer_1_width(){
// Return the percentage of this widget width - 25% in this case
return'25';
}
add_filter('generate_footer_widget_2_width','tu_custom_footer_1_width');
function tu_custom_footer_2_width(){
// Return the percentage of this widget width - 25% in this case
return'25';
}
add_filter('generate_footer_widget_3_width','tu_custom_footer_1_width');
function tu_custom_footer_3_width(){
// Return the percentage of this widget width - 25% in this case
return'50';
}
/*fonts*/
add_filter( 'generate_typography_default_fonts', 'tu_add_local_fonts' );
function tu_add_local_fonts( $fonts ) {
$fonts[] = 'Raleway';
return $fonts;
}
Ah, if you're using a custom post type they won't load by default.
Check out this solution: https://generatepress.com/forums/topic/post-meta-category-tags-does-not-display-for-custom-post-type/#post-661738
Now I have the title, but not author and date.
In "customizer > layout > blog" author and date are checked.
Do I have to turn on some other settings somewhere?
You'd have to use the code I linked to above. Those elements only display on the post post type by default.
The code from the link above, yes I already entered it into the functions.php:
EDIT: I will simply delete this custom post, and create new blog posts during the next time...
<?php
//
//
// Your code goes below
//
define( 'WP_AUTO_UPDATE_CORE', false );
/*front page title*/
add_filter( 'document_title_parts', function( $title ) {
if ( is_front_page() ) {
$title['title'] = 'My Custom Title';
}
return $title;
} );
/**Portfolio Tab**/
function post_type_projects() {
register_post_type(
'portfolio',
array(
'label' => __('Portfolio'),
'public' => true,
'show_ui' => true,
'supports' => array(
'title',
'editor',
'post-thumbnails',
'custom-fields',
'revisions')
)
);
register_taxonomy( 'category-p', 'portfolio',
array(
'hierarchical' => false,
'label' => __('Projects'),
'query_var' => 'category-p',
'rewrite' => array('slug' => 'category-p' )
)
);
}
add_action('init', 'post_type_projects');
/*add post meta manually because of costum post type*/
add_action( 'generate_after_entry_title', function() {
$post_types = array(
'one-post-type',
'another-post-type',
);
if ( in_array( get_post_type(), $post_types ) ) : ?>
<div class="entry-meta">
<?php generate_posted_on(); ?>
</div><!-- .entry-meta -->
<?php endif;
} );
add_action( 'generate_after_entry_content', function() {
$post_types = array(
'one-post-type',
'another-post-type',
);
if ( in_array( get_post_type(), $post_types ) ) : ?>
<footer class="entry-meta">
<?php
generate_entry_meta();
if ( is_single() ) {
generate_content_nav( 'nav-below' );
}
?>
</footer><!-- .entry-meta -->
<?php endif;
} );
function wpbeginner_remove_version() {
return '';
}
add_filter('the_generator', 'wpbeginner_remove_version');
/*emoji*/
function remove_emoji()
{
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('admin_print_scripts', 'print_emoji_detection_script');
remove_action('admin_print_styles', 'print_emoji_styles');
remove_action('wp_print_styles', 'print_emoji_styles');
remove_filter('the_content_feed', 'wp_staticize_emoji');
remove_filter('comment_text_rss', 'wp_staticize_emoji');
remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
add_filter('tiny_mce_plugins', 'remove_tinymce_emoji');
}
add_action('init', 'remove_emoji');
function remove_tinymce_emoji($plugins)
{
if (!is_array($plugins))
{
return array();
}
return array_diff($plugins, array(
'wpemoji'
));
}
/*Footer width*/
add_filter('generate_footer_widget_1_width','tu_custom_footer_1_width');
function tu_custom_footer_1_width(){
// Return the percentage of this widget width - 25% in this case
return'25';
}
add_filter('generate_footer_widget_2_width','tu_custom_footer_1_width');
function tu_custom_footer_2_width(){
// Return the percentage of this widget width - 25% in this case
return'25';
}
add_filter('generate_footer_widget_3_width','tu_custom_footer_1_width');
function tu_custom_footer_3_width(){
// Return the percentage of this widget width - 25% in this case
return'50';
}
/*fonts*/
add_filter( 'generate_typography_default_fonts', 'tu_add_local_fonts' );
function tu_add_local_fonts( $fonts ) {
$fonts[] = 'Raleway';
return $fonts;
}
You need to update the post types with the names of your types.
So if your post type is named portfolio, you would replace this:
$post_types = array(
'one-post-type',
'another-post-type',
);
With this:
$post_types = array(
'portfolio',
);
Oops, ok that worked.
Thank you very much for your effort!!
You're welcome :)