Site logo

Archived topic

tag archive has no read more label

31 replies · Started by Aaron on February 25, 2022

Viewing posts 16–30 of 32

It is actually not a custom post type, it is the default renamed Post Post-Type. I did


function plgd_adjustPostLabel()
{
    global $menu;
    global $submenu;
    $menu[5][0] = 'Products';
    $submenu['edit.php'][5][0] = esc_html__('All Products', 'plgd');
    $submenu['edit.php'][10][0] = esc_html__('Create Product', 'plgd');
    $submenu['edit.php'][16][0] = esc_html__('Tags', 'plgd');
}
function plgd_adjustPostObject()
{
    global $wp_post_types;
    $wp_post_types['post']->menu_icon = 'dashicons-store';
    $labels = &$wp_post_types['post']->labels;
    $labels->name = esc_html__('Products', 'plgd');
    $labels->singular_name = esc_html__('Product', 'plgd');
    $labels->add_new = esc_html__('Add New', 'plgd');
    $labels->add_new_item = esc_html__('Add New Product', 'plgd');
    $labels->edit_item = esc_html__('Edit Product', 'plgd');
    $labels->new_item = esc_html__('New Product', 'plgd');
    $labels->view_item = esc_html__('View Product', 'plgd');
    $labels->view_items = esc_html__('View Products', 'plgd');
    $labels->search_items = esc_html__('Search Products', 'plgd');
    $labels->not_found = esc_html__('No products found.', 'plgd');
    $labels->not_found_in_trash = esc_html__('No products found in Trash.', 'plgd');
    $labels->all_items = esc_html__('All Products', 'plgd');
    $labels->archives = esc_html__('Product Archive', 'plgd');
    $labels->attributes = esc_html__('Product Attributes', 'plgd');
    $labels->insert_into_item = esc_html__('Insert into product', 'plgd');
    $labels->uploaded_to_this_item = esc_html__('Uploaded to this product', 'plgd');
    $labels->featured_image = esc_html__('Product image', 'plgd');
    $labels->set_featured_image = esc_html__('Set product image', 'plgd');
    $labels->remove_featured_image = esc_html__('Remove product image', 'plgd');
    $labels->use_featured_image = esc_html__('Use as product image', 'plgd');
    $labels->filter_items_list = esc_html__('Filter products list', 'plgd');
    $labels->items_list_navigation = esc_html__('Products list navigation', 'plgd');
    $labels->items_list = esc_html__('Products list', 'plgd');
    $labels->item_published = esc_html__('Product published.', 'plgd');
    $labels->item_published_privately = esc_html__('Product published privately.', 'plgd');
    $labels->item_reverted_to_draft = esc_html__('Product reverted to draft.', 'plgd');
    $labels->item_scheduled = esc_html__('Product scheduled.', 'plgd');
    $labels->item_updated = esc_html__('Product updated.', 'plgd');
    $labels->item_link = esc_html__('Product Link', 'plgd');
    $labels->item_link_description =esc_html('A link to a Product.', 'plgd');
    $labels->menu_name = esc_html__('Products', 'plgd');
    $labels->name_admin_bar = esc_html__('Procduct', 'plgd');

}

add_action('admin_menu', 'plgd_adjustPostLabel');
add_action('init', 'plgd_adjustPostObject');

removing the add_action calls did not help.

Excerpt is enabled and works with the core query block

Hmmm... odd one. If i switch from Excerpt to Content then it works correctly.
What happens if you add a manual excerpt to one of the posts ?

OK so that part of the excerpt functions are still working ( manual excerpts don't automatically display Read More ) which i kinda expected it not to... still a head scratcher as to why no auto excerpt is displayed.

Before we start looking at other options - can you confirm there is not a Plugin conflict by temporarily disabling all plugins apart from GPP and GB

I just rechecked. I disabled all plugin apart from GPP GB and GBP, and switched to the parent GP theme. Still no auto excerpt and read more...

I will keep it in this state for now, so we can make absolutely sure it's not some custom code or plugin.

Can you try creating a new 'product' post and just add plain text - no container blocks or other block content. As it may be related to how WP deals with nested block content in the excerpt

Which version of WP are you running ?

5.9.1

Hmmm... i thought they had patched that... seems it won't work with content inside containers 2 levels deep.
What happens if you add this PHP Snippet:

add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
function tu_excerpt_metabox_more( $excerpt ) {
    $output = $excerpt;

    if ( !has_excerpt() && '' === $output ) {
        $output = sprintf( '%1$s <p class="read-more-button-container"><a class="button" href="%2$s">%3$s</a></p>',
            $excerpt,
            get_permalink(),
            __( 'Read more', 'generatepress' )
        );
    }
	
    return $output;
}

This should output the button if there is no excerpt.

The alternative to this is to create your own Content Template:

https://docs.generatepress.com/article/block-element-content-template/

What happens if you add this PHP Snippet:

See https://plgd-trading.com/product/tag/86-arabica/

1: Post without Block Content, no manual excerpt; 2 Buttons
2: Post with Block-Content, manual excerpt; 0 Buttons
3: Post with Block Content, no manual excerpt: 1 Button

Made a change to the snippet above so it also checks if the auto excerpt if empty.

And to note - this line:

__( 'Read more', 'generatepress' )

Is where you can change the label.

Simplest method is a little CSS:

.entry-summary p:not(.read-more-container) {
    display: none;
}
This archived topic is closed to new replies.