ZIPWordPress原创插件:搜索引擎抓取首图seo图片 1.66KB

huayula

资源文件列表:

fixed-seo-image.zip 大约有2个文件
  1. 双击获取更多.url 110B
  2. fixed-seo-image.php 2.7KB

资源介绍:

插件将在网站头部添加适当的meta标签,以便百度等搜索引擎抓取指定的固定图像。
<?php /** * Plugin Name: 抓取 SEO Image * Plugin URI: https://qqmu.com * Description: Set a fixed image for SEO baidu crawling and indexing. * Version: 1.0.0 * Author: QQ沐 * Author URI: https://qqmu.com * License: GPL-2.0+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt */ // 定义常量 define('FIXED_SEO_IMAGE_PLUGIN_URL', plugin_dir_url(__FILE__)); // 注册钩子以在头部添加meta标签 add_action('wp_head', 'fixed_seo_image_add_meta_tag'); function fixed_seo_image_add_meta_tag() { $image_url = get_option('fixed_seo_image_url'); if ($image_url) { echo '<meta property="og:image" content="' . esc_url($image_url) . '" />'; echo '<meta name="twitter:image" content="' . esc_url($image_url) . '" />'; } } // 添加设置页面 add_action('admin_menu', 'fixed_seo_image_add_settings_page'); function fixed_seo_image_add_settings_page() { add_options_page( '固定SEO图片设置', '固定SEO图片', 'manage_options', 'fixed-seo-image-settings', 'fixed_seo_image_settings_page' ); } // 创建设置页面 function fixed_seo_image_settings_page() { if (!current_user_can('manage_options')) { wp_die(__('您没有足够的权限访问此页面。')); } $image_url = get_option('fixed_seo_image_url', ''); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $new_image_url = isset($_POST['fixed_seo_image_url']) ? esc_url_raw($_POST['fixed_seo_image_url']) : ''; update_option('fixed_seo_image_url', $new_image_url); $image_url = $new_image_url; echo '<div class="updated"><p><strong>设置已保存。</strong></p></div>'; } ?> <div class="wrap"> <h1>固定SEO图片设置</h1> <form method="post" action=""> <?php settings_fields('fixed_seo_image_settings'); ?> <table class="form-table"> <tr valign="top"> <th scope="row">固定SEO图片URL:</th> <td> <input type="url" name="fixed_seo_image_url" value="<?php echo esc_url($image_url); ?>" /> <p class="description">输入您希望用作固定SEO图片的URL。</p> </td> </tr> </table> <?php submit_button(); ?> </form> <p style="text-align: center; font-size: 16px; color: #999;">本插件由<a href="https://ds17.cn" target="_blank">大神博客ds17.cn</a>原创,保留所有权利。</p> </div> <?php } // 注册设置 add_action('admin_init', 'fixed_seo_image_register_settings'); function fixed_seo_image_register_settings() { register_setting('fixed_seo_image_settings', 'fixed_seo_image_url'); }
100+评论
captcha
    类型标题大小时间
    ZIP自动控制原理ppt(上海理工大学)34.4MB9月前
    ZIPSTM32F103HAL-LED代码4.08MB9月前
    ZIPSTM32F103LED闪烁4.08MB9月前
    ZIP2024年最新易校网校园综合跑腿小程序源码修复运营版6.4MB9月前
    ZIPWordPress原创插件:文章ID连续 无空ID免费1.48KB9月前
    ZIPWordPress原创插件:背景颜色跑马灯效果1.75KB9月前
    ZIPWordPress原创插件:超链接点击访问统计1.94KB9月前
    ZIPWordPress插件:清理重复文章 保留文章zip1.22KB9月前