[SmartCrawl] Add admin columns for keywords and description

I would like to know if I can have admin columns with keywords and description in pages and post lists.

A snippet or function would be very helpful. Checking keywords against pages is becoming a pain as I have to quick-edit and then check which keyword is assigned to what page.

This is a very common feature and is available in all other SEO plugins and after using SmartCrawl for so many months I really don’t wish to make a switch.

Please advice.

  • Adam Czajczyk
    • Support Gorilla

    Hi mustafa

    I hope you’re well today and thank you for your question!

    We currently have information about Robots Meta and SEO and Readability analysis statuses there (depending on active SmartCrawl modules) and you can enable/disable displaying them in “Screen Options”.

    However, you’re right – there’s no description and keywords columns there yet. I’ve already passed that idea to our developers directly but I’d like to get your opinion:

    Should those columns be enabled (visible) by default or we should rather keep them hidden unless you specifically decide to enable them?

    I’m asking because while I can see how useful they could be, I can also imagine that – especially with some other plugins adding their own information there – showing the there “out of the box” could possibly cause quite a “clutter” on the post/page list :slight_smile:

    What do you think?

    Best regards,

    Adam

  • Konstantinos Xenos
    • Rubber Duck Debugger

    Hey mustafa & Julian :slight_smile: ,

    I’ve made a mu-plugin to show the description & keywords as requested on the Posts / Pages table lists. I’ve also talked with our developers and we might add this as an extra feature on an upcoming release as well to be natively supported by the plugin :slight_smile: .

    How to install:

    Always make sure to keep a backup of your site before changing/adding custom code.

    1] Navigate to your /wp-content/ directory and create a new one named mu-plugins if it doesn’t exist.

    2] Inside the mu-plugins folder create a file named class-wpmudev-wds-c-columns.php

    3] Edit the file and copy / paste this code snippet inside.

    <?php

    /**
    * Plugin Name: SmartCrawl - Show Description & Keywords on Posts/Pages list tables.
    * Plugin URI: https://premium.wpmudev.org/
    * Description: SmartCrawl - Show Description & Keywords on Posts/Pages list tables.
    * Author: Konstantinos Xenos @ WPMUDEV
    * Author URI: https://premium.wpmudev.org/
    * License: GPLv2 or later
    */

    if ( ! defined( 'ABSPATH' ) ) {
    exit;
    }

    if ( ! class_exists( 'WPMUDEV_WDS_C_COLUMNS' ) ) {

    class WPMUDEV_WDS_C_COLUMNS {

    private static $_instance = null;

    public static function get_instance() {
    if ( is_null( self::$_instance ) ) {
    self::$_instance = new WPMUDEV_WDS_C_COLUMNS();
    }

    return self::$_instance;
    }

    /**
    * Class constructor.
    */
    private function __construct() {
    add_filter( 'manage_posts_columns', array( $this, 'wds_c_columns' ) );
    add_filter( 'manage_pages_columns', array( $this, 'wds_c_columns' ) );
    add_action( 'manage_posts_custom_column', array( $this, 'wds_c_columns_data' ), 10, 2 );
    add_action( 'manage_pages_custom_column', array( $this, 'wds_c_columns_data' ), 10, 2 );
    }

    /**
    * Add new columns.
    */
    public function wds_c_columns( $columns ) {
    $columns['wds_c_description'] = 'Description';
    $columns['wds_c_keywords'] = 'Keywords';

    return $columns;
    }

    /**
    * Show column data.
    */
    public function wds_c_columns_data( $column_name, $post_ID ) {
    if ( function_exists( 'smartcrawl_get_value' ) ) {
    if ( 'wds_c_description' === $column_name ) {
    echo smartcrawl_get_value( 'metadesc', $post_ID );
    }

    if ( 'wds_c_keywords' === $column_name ) {
    echo smartcrawl_get_value( 'keywords', $post_ID );
    }
    }
    }

    }

    if ( ! function_exists( 'wpmudev_wds_c_columns' ) ) {

    function wpmudev_wds_c_columns() {
    return WPMUDEV_WDS_C_COLUMNS::get_instance();
    };

    add_action( 'plugins_loaded', 'wpmudev_wds_c_columns', 10 );
    }
    }

    4] Save and close the file.

    5] The final path should look like /wp-content/mu-plugins/class-wpmudev-wds-c-columns.php

    6] Everything should work after that automatically.

    I hope this helps for the time being!

    Tell me if you need any further help.

    Regards,

    Konstantinos

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.