0

Remove author using jQuery

Hi, can I remove a author from multiple authors name using jQuery. I am using wordpress. I am trying this code, but this is not working. jQuery(document).ready(function( $ ){ $("a").filter(":contains('Khubaib')").remove(); });

22nd Jan 2021, 12:13 PM
Khubaib Mehmood
2 Respuestas
+ 2
If that doesn't work, there are other ways to remove the author from WordPress posts. Your selector for the author depends a lot on your WordPress theme. Is your site available online? If I can inspect your author element, I might be able to write a more effective CSS selector. If you can get your CSS selector working for JavaScript, CSS should also do the trick. The CSS equivalent to your JavaScript would be: a:contains('Khubaib') { display: none; } A couple solutions are mentioned at: https://www.wpbeginner.com/wp-themes/how-to-remove-author-name-from-wordpress-posts/ I would go with method1 from there because removing author is modifying the layout of your pages and the WordPress theme is responsible for the look and feel that you're modifying. Modifying the theme directly should be slightly more efficient and polished. There is no HTML generated for the author name. It doesn't show the author even for a tiny fraction of a second while loading the page and before the CSS or JavaScript kicks in.
2nd Feb 2021, 10:20 AM
Josh Greig
Josh Greig - avatar
2nd Feb 2021, 1:28 PM
Khubaib Mehmood