Last active
July 11, 2020 05:10
-
-
Save SuryawanshiPrajakta/909b9db68f36f8425c7c37a258ca70ee to your computer and use it in GitHub Desktop.
Display custom excerpt
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
1) Create a textarea field and attach it to page - https://cl.ly/060d1cd4d38b | |
2) Add text to your textarea field - | |
3) Add below CSS to hide the default excerpt - | |
.uael-post__excerpt { | |
display: none; | |
} | |
.custom.uael-post__excerpt { | |
display: block; | |
} | |
4) Add the below filter in your functions.php | |
function excerpt_before( $post_id, $settings ) { | |
?> | |
<div class="custom uael-post__excerpt"> | |
<?php echo get_field( 'page_excerpt', $post_id ); ?> | |
</div> | |
<?php | |
} | |
add_action( 'uael_single_post_before_excerpt', 'excerpt_before', 10, 2 ); | |
Note - Please replace the 'page_excerpt' with the ID of your custom field. | |
These steps will hide the original excerpt while displaying custom from the field. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment