-
Notifications
You must be signed in to change notification settings - Fork 123
Open
Labels
Description
I would like to have the option to place LiveBlogs at the top of posts rather than below them. We serve mobile stories adaptively and insert sidebar widgets into the content. With the liveblog at the bottom of the content, it gets pushed down by ads and other widgets.
The code that places the liveblog block is in /liveblog.php L1138:
public static function add_liveblog_to_content( $content ) {
...
return $content . wp_kses_post( $liveblog_output );
}
I would prefer:
if ( true === $show_liveblog_at_top ) {
return wp_kses_post( $liveblog_output ) . $content;
} else {
return $content . wp_kses_post( $liveblog_output );
}
I would be happy to fork the repo and write this code if the change is approved.
This would involve adding either a global or a post-level setting (or both) to set/get $show_liveblog_at_top in post meta or options.
For the time being I am adding a filter to my functions.php file. This is a fragile hack and relies on particular HTML existing in the LiveBlog output, but it works for now.
function pm_move_liveblog_to_top( $content ) {
$liveblog_marker = '<div id="wpcom-liveblog-container"';
$start_position = strpos( $content, $liveblog_marker );
if ( false !== $start_position ) {
$pieces = explode( $liveblog_marker, $content );
$content = $liveblog_marker . $pieces[1] . $pieces[0];
}
return $content;
}
add_filter( 'the_content', 'pm_move_liveblog_to_top', 21 );
Charles