When using our Timeline Express – Popups Add-On there are times when you have announcements on the timeline that contain no actual content, and when the ‘Read More’ link is clicked the popup is empty with the title and date visible but no content, confusing the users of your site.

To help out your readers, you can remove the ‘Read More’ links from the announcement containers, which prevents users from accessing the popup. This can be done using some nifty JavaScript to dynamically remove the ‘Read More’ links when the containers contain no content in them.

We’ve gone ahead and taken the liberty to write out a sample script that can be used to remove the ‘Read More’ links from your announcement containers that have no content.

Code Sample

You will want to add this code into your themes functions.php file, exactly as it’s written below. Ideally, you would want to add the code inside of the tags below into a separate JavaScript file and then you would want to use wp_enqueue_script() to load the script on the appropriate page, to help minimize JavaScript conflicts with your theme or other plugins running on your site. But adding it directly into your themes functions.php file will work as well.

Note: This script will remove the ‘Read More’ links from the timeline, when your announcements have no content. However, the announcement popup will still be visible and accessible to your users if they use the navigation links at the bottom of each popup container. You can turn off the popup navigation links to prevent users from accessing the popups with no content by going to ‘Timeline Express > Settings > Popups Add-On’ and unchecking the option for ‘Prev/Next Links’.
International Users: In the script below you’ll want to replace ‘Read More’ with the string of the read more link on your site. In English this is ‘Read More’ but on internationalized sites this string may be something else.

 * Remove the 'Read More' links from the announcement containers
 * when the announcement content is empty
 * Note: This should be written in a separate .js file and enqueued
 * on the appropriate page to prevent conflicts
 * @return mixed HTML markup for the script
function remove_readmore_empty_popups() {

	<script type="text/javascript">

	jQuery( document ).ready( function() {

		var $timeline = jQuery( '.timeline-express' );

		$timeline.children( 'div' ).each( function() {

			var $content  = jQuery( this ).find( '.the-excerpt' ).text().replace( 'Read more', '' ).trim(),
			    $readmore = jQuery( this ).find( '.popups-read-more-link' );

			if ( '' === $content ) {



		} );

	} )



add_action( 'wp_head', 'remove_readmore_empty_popups' );