• I add this code to function.php for my [ redundant link removed ]

    <?php
    remove_action('wp_head', 'rsd_link');
    remove_action('wp_head', 'wp_generator');
    remove_action('wp_head', 'feed_links', 2);
    remove_action('wp_head', 'feed_links_extra', 3);
    remove_action('wp_head', 'wlwmanifest_link');
    remove_action('wp_head', 'wp_shortlink_wp_head');
    remove_action('wp_head', 'rest_output_link_wp_head', 10);
    remove_action('wp_head', 'wp_oembed_add_discovery_links', 10); 
    

    But why the default unnecessary code (api, xmlrpc, shortlink, x-pingback, etc) still appear on my headers? ->

    • This topic was modified 5 years, 4 months ago by James Huff.
    • This topic was modified 5 years, 4 months ago by Jan Dembowski.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • If that code is not in a function, it is run when your theme is loaded. It could be that those functions are added after that.
    See https://codex.www.ads-software.com/Plugin_API/Action_Reference for a rough idea of the order of the actions, and then look at when those functions are added to wp_head. The remove_action has to be after it is added, but before it is called.

    Thread Starter bayu-angora

    (@bayu-angora)

    Here is my current code ->

    <?php
    remove_action('wp_head', 'rsd_link');
    remove_action('wp_head', 'wp_generator');
    remove_action('wp_head', 'feed_links', 2);
    remove_action('wp_head', 'feed_links_extra', 3);
    remove_action('wp_head', 'wlwmanifest_link');
    remove_action('wp_head', 'wp_shortlink_wp_head');
    remove_action('wp_head', 'rest_output_link_wp_head', 10);
    remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);

    function jl_remove_post_dates() {
    add_filter('the_date', '__return_false');
    add_filter('the_time', '__return_false');
    add_filter('the_modified_date', '__return_false');
    add_filter('get_the_date', '__return_false');
    add_filter('get_the_time', '__return_false');
    add_filter('get_the_modified_date', '__return_false');
    } add_action('loop_start', 'jl_remove_post_dates');

    function remove_prefix_title( $title ) {
    if ( is_category() ) {
    $title = single_cat_title( '', false );
    } elseif ( is_tag() ) {
    $title = single_tag_title( '', false );
    } elseif ( is_author() ) {
    $title = '<span class="vcard">' . get_the_author() . '</span>';
    }
    return $title;
    }
    add_filter('get_the_archive_title', 'remove_prefix_title');

    function no_wp_logo_admin_bar_remove() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu('wp-logo');
    }
    add_action('wp_before_admin_bar_render', 'no_wp_logo_admin_bar_remove', 0);

    function remove_howdy( $wp_admin_bar ) {
    $my_account=$wp_admin_bar->get_node('my-account');
    $newtitle = str_replace('Howdy,', '', $my_account->title);
    $wp_admin_bar->add_node( array(
    'id' => 'my-account',
    'title' => $newtitle,
    ) );
    }
    add_filter('admin_bar_menu', 'remove_howdy', 25);

    function wpb_login_logo_url() {
    return home_url();}
    add_filter('login_headerurl', 'wpb_login_logo_url');
    function wpb_login_logo_url_title() {
    return 'Bayu Angora';}
    add_filter('login_headertitle', 'wpb_login_logo_url_title');

    function wpb_login_logo() { ?>

    <?php }
    add_action('login_enqueue_scripts', 'wpb_login_logo');

    Can you help how’s the right code?

    Thread Starter bayu-angora

    (@bayu-angora)

    Though I moved the code to below, the unnecessary code still appear.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Default Unnecessary Code Still Appear On Headers’ is closed to new replies.