Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joydevpal/cae57440b35a4805f6d2801287d4f3c7 to your computer and use it in GitHub Desktop.
Save joydevpal/cae57440b35a4805f6d2801287d4f3c7 to your computer and use it in GitHub Desktop.

Revisions

  1. joydevpal created this gist Aug 25, 2016.
    20 changes: 20 additions & 0 deletions auto_links_keywords_in_content_excerpt.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    <?php

    /**
    * auto link keywords in post content and excerpt
    */

    function wcs_auto_link_keywords( $text ) {
    $replace = array(
    'wordpress' => '<a href="http://www.wordpress.org">wordpress</a>',
    'google' => '<a href="http://www.google.com">excerpt</a>',
    'facebook' => '<a href="http://www.facebook.com">function</a>'
    );
    $text = str_replace( array_keys($replace), $replace, $text );
    return $text;
    }
    add_filter( 'the_content', 'wcs_auto_link_keywords' );
    add_filter( 'the_excerpt', 'wcs_auto_link_keywords' );


    ?>