Last active
October 5, 2018 13:31
-
-
Save BinaryMoon/a5dd78526baf89dbbf84a3d59be4d725 to your computer and use it in GitHub Desktop.
Add a text widget to the recent posts column on the Opti Homepage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Opti Recent Posts Intro | |
* Plugin URI: https://prothemedesign.com | |
* Description: Use a widget to add an intro to the recent posts column. | |
* Author: Ben Gillbanks | |
* Version: 1.0 | |
* Author URI: https://prothemedesign.com | |
*/ | |
function opti_recent_posts_intro() { | |
?> | |
<script> | |
jQuery( document ).ready( | |
function() { | |
var $ = jQuery; | |
var widget_id = '#text-8'; | |
// Move widget contents to above lead story element. | |
if ( $( '#lead-story' ).length > 0 ) { | |
$( widget_id + ' .textwidget' ).addClass( 'recent-posts-intro' ).insertBefore( '#lead-story' ); | |
} | |
// Delete old widget. | |
// This will work on all pages. | |
$( widget_id ).remove(); | |
} | |
); | |
</script> | |
<?php | |
} | |
add_action( 'wp_footer', 'opti_recent_posts_intro', 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment