Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LiveBlog at the top of the article #525

Open
cmjaimet opened this issue Sep 13, 2018 · 2 comments · May be fixed by #531
Open

LiveBlog at the top of the article #525

cmjaimet opened this issue Sep 13, 2018 · 2 comments · May be fixed by #531

Comments

@cmjaimet
Copy link

cmjaimet commented Sep 13, 2018

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

@cmjaimet cmjaimet changed the title LiveBlog is always appending below the article LiveBlog at the top of the article Sep 13, 2018
@philipjohn
Copy link
Contributor

How about a filter? We could change the code here to include something like apply_filters( 'liveblog_output_at_bottom', true );.

@alexiskulash alexiskulash self-assigned this Sep 26, 2018
alexiskulash added a commit that referenced this issue Sep 26, 2018
Fixes: #525

Some users would prefer having Liveblog output at the top of their posts rather than the bottom. This filter introduces the simple functionality to choose whether the Liveblog output should be above the content or below it (default).
@alexiskulash alexiskulash linked a pull request Sep 26, 2018 that will close this issue
@cmjaimet
Copy link
Author

cmjaimet commented Oct 24, 2018

Thanks this would solve our problem nicely. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants