Enable "highlighted image" on specific Wordpress pages

Asked

Viewed 493 times

2

I used the following command to enable "highlighted images" in my site posts in Wordpress:

// HABILITANDO IMAGENS DESTACADAS EM POSTS
add_theme_support('post-thumbnails', array('post'));

How to enable this function on some specific pages of the site? I don’t want to enable on all pages. Just, for example, on the "About" page and on the "Contact Us" page".

  • 1

    To enable the pages just add the type page in the array: add_theme_support('post-thumbnails', array('post','page'));. header.php what page is being accessed, and whether or not to show the highlighted image.

1 answer

0

This refinement can only be done with CSS or Javascript.

The action is applied only on the pages wp-admin/post.php and wp-admin/post-new.php.
The global $current_screen has the Post Type information that is being shown.
And the global $post has information about the current post where we check the permalink, p.ex.: http://site.com/contato.

add_action( 'admin_footer-post.php', 'metabox_sopt_279492' );
add_action( 'admin_footer-post-new.php', 'metabox_sopt_279492' );

function metabox_sopt_279492() {
    global $current_screen, $post;
    if ( 'page' != $current_screen->id ) 
        return; 

    $checkpages = array( 'sobre', 'contato' );
    if( in_array( $post->post_name, $checkpages ) )
        return;
    ?>
    <script type="text/javascript">
        jQuery(document).ready( function($) {   
            $('#postimagediv').remove(); 
        });
    </script>
    <?php
}
  • Deleted answer ok. obg: https://answall.com/q/288920/8063

  • I imagine it’s only a matter of time before your Golden hammer in [tag:javascript], good luck!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.