Hi @tyealia,
Can you try modifying your current code to this one:
add_filter( 'generate_header_entry_meta_items', function( $items ) {
if ( is_single() || is_page() ) {
$items = array(
'date',
'author',
'categories',
'tags'
);
} return $items;
} );
add_action( 'generate_after_entry_header', 'tu_page_meta' );
function tu_page_meta() {
if ( is_singular( 'page' ) ) : ?>
<div class="entry-meta">
<?php generate_posted_on(); ?>
</div><!-- .entry-meta -->
<?php endif;
}
Hope this helps! Kindly let us know how it goes. 🙂
Works perfectly thank you so so much!
Just one last question. It does this for every page, I have a bunch of privacy policies and about pages I don’t want it to display on. Is there a way to exclude from them? Even if I can exclude all pages tagged with Policies, or under a category like Policies that would work.
I see.
Here is a code you may try instead:
add_filter( 'generate_header_entry_meta_items', function( $items ) {
if ( is_single() || is_page() && !is_page( 1431, 1112, 1113 ) ) {
$items = array(
'date',
'author',
'categories',
'tags'
);
} return $items;
} );
add_action( 'generate_after_entry_header', 'tu_page_meta' );
function tu_page_meta() {
if ( is_singular( 'page' ) && !is_page( 1431, 1112, 1113 ) ) : ?>
<div class="entry-meta">
<?php generate_posted_on(); ?>
</div><!-- .entry-meta -->
<?php endif;
}
I added && !is_page( 1431, 1112, 1113 ) in your conditional statements.
1431, 1112 and 1113 are just placeholders. Kindly replace this with the Page ID of the pages you wish to exclude.
To get the page ID, you may edit the page and check the URL as such:
https://share.getcloudapp.com/WnuyERlx
https://share.getcloudapp.com/Z4u7wbqB
You may also remove either && !is_page( 1431, 1112, 1113 ) if you would prefer it only on one of these functions.
Hope this helps! 🙂
EDIT* found the issue with multiple pages by googling a bit, I added ( array after ispage and now it works! Thanks again fernando
Hi Fernando, thanks a lot! it works for the first page I input, but any subsequent pages input do not work, have tested and it’s only always the first value # input that triggers. Maybe we used the wrong comma syntax or something?
I appreciate your help thus far!!
ex. of a second page entered in doesn’t remove
add_filter( 'generate_header_entry_meta_items', function( $items ) {
if ( is_single() || is_page() && !is_page( 1040, 1042 ) ) {
$items = array(
'date',
'author',
'categories',
'tags'
);
} return $items;
} );
add_action( 'generate_after_entry_header', 'tu_page_meta' );
function tu_page_meta() {
if ( is_singular( 'page' ) && !is_page( 1040, 1042 ) ) : ?>
<div class="entry-meta">
<?php generate_posted_on(); ?>
</div><!-- .entry-meta -->
<?php endif;
}
-
This reply was modified 3 years, 10 months ago by
tyealia.
You’re right! Sorry about that, I forgot to put them in an array.
Can you try this instead?:
add_filter( 'generate_header_entry_meta_items', function( $items ) {
if ( is_single() || is_page() && !is_page( array(1040, 1042) ) ) {
$items = array(
'date',
'author',
'categories',
'tags'
);
} return $items;
} );
add_action( 'generate_after_entry_header', 'tu_page_meta' );
function tu_page_meta() {
if ( is_singular( 'page' ) && !is_page( array(1040, 1042) ) ) : ?>
<div class="entry-meta">
<?php generate_posted_on(); ?>
</div><!-- .entry-meta -->
<?php endif;
}
Kindly let us know how it goes. 🙂