Add Your Own Meta

This is a Developer Level doc.

If you're unfamiliar with PHP and/or editing files, codes and templates, as well as with resolving possible conflict, please seek help from a professional. Under our Support Policy, we don't provide support for modifications and customization.

Default single blog post meta tags include: author, published date, category and comments. You can add your own meta tags using the following PHP snippet:

 * Add your own meta
 * By default, this new meta will be disabled, so you need to enable it in the customizer.
function my_blog_meta_choices( $return ) {

	// Add your meta name
	$return['my-meta'] = esc_html__( 'My Meta', 'oceanwp' );

	// Return
	return $return;

add_filter( 'ocean_blog_meta_choices', 'my_blog_meta_choices' );

If you want to add this new meta in your single posts, follow these steps:

Create a partials folder in your child theme, in this folder, create another one named single.
Copy the meta.php file from oceanwp/partials/single/ in the same folder of the child theme.
Open this file in your text editor and add the following code into the foreach:

If you are using the OceanWP 2.0.9 version or later, adjust the code to match the correct and new function used to display icons oceanwp_icon :

<?php if ( 'my-meta' === $section ) { ?>
	<li class="my-meta"></span><?php oceanwp_icon( 'user' ); ?><?php echo esc_html( the_author_posts_link() ); ?></li>
<?php } ?>

If your icon is not visible after the code change, make sure you have added it to the OceanWP theme icons array.

The code below should be use used on OceanWP version 2.0.8 or lower:

<?php if ( 'my-meta' == $section ) { ?>
	<li class="meta-my-meta"><i class="icon-layers"></i><?php esc_html_e( 'My Meta', 'oceanwp' ); ?></li>
<?php } ?>

All PHP snippets should be added via a child theme's functions.php file.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.