Tagged: category, meta, single post
Hi,
I would like to achieve the following layout for a single post (standard/business blog):
the category should be over the post title and in the meta tags the slash and the word “in” before the category name should be deleted.
I tried several solutions from the forum, unfortunately most are very old and I can’t get them to work.
Above all I would prefer a snippet/function solution rather than editing theme files.
I have tried this code, but it simply has no effect —> here
This is what it should look like:
Thanks for your help in advance.
Hey BeeCee,
Thanks for your patience and the link to your site, if I try to go to your snippets plugin I see this error: Sorry, you are not allowed to access this page.
Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor, or in your snippets plugin as a php snippet:
function custom_script_move_category() { ?>
<script>
window.addEventListener('DOMContentLoaded', function() {
(function($){
$( '.single-post .entry-content-header' ).each(function() {
$( this ).find( '.blog-categories.minor-meta' ).insertBefore( $(this).find('h1.post-title.entry-title ') );
$( this ).find( '.blog-categories.minor-meta' ).contents().filter(function(){ return this.nodeType == 3; }).remove();
$( this ).find( '.post-meta-infos .text-sep:last-child' ).css({'display':'none'});
});
})(jQuery);
});
</script>
<?php
}
add_action( 'wp_enqueue_scripts', 'custom_script_move_category', 99 );
Best regards,
Mike
Thank you, Mike, for your help.
I just discovered that the “Code Snippets” plugin obviously is not accessible at all, although you’ve got an admin role in the temporary login, I don’t know why this is the case.
But nevertheless your code works perfect so that I have the category above the title of my single post.
Thank you very much.
Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.
Best regards,
Mike