Reputation: 1932
I'm using Wordpress and would like to hide the word 'Protected' that is with the title 'Protected: Pavanjot & Amandeep’s Wedding' I'd like the rest of the title to remain as is.
I'm guessing using custom css I can target the below code to hide the word? I'm unsure on how to achieve this though.
<header class="entry-header page-header">
<h1 class="entry-title">Protected: Pavanjot & Amandeep’s Wedding</h1>
</header>
I'd like to hide the word, or remove it, so the remaining text aligns left and does not leave a gap.
Any help is great thank you.
Upvotes: 0
Views: 176
Reputation: 53674
I don't think you can do that with CSS without modifying the markup (and then you could just remove the text), but you can do it with a couple of lines of JS.
<h1 class="entry-title">Protected: Pavanjot & Amandeep’s Wedding</h1>
<script>
var entryTitle = document.querySelector('.entry-title'),
text = entryTitle.innerHTML;
entryTitle.innerHTML = text.substring(text.indexOf(" "), text.length);
</script>
Upvotes: 1
Reputation: 889
If this is your post title, then place this function in your functions.php, your issue will be solved.
function change_title($title) {
if (strpos($title, 'Protected:') !== false) {
$title = str_replace("Protected:","",$title);
}
return $title;
}
add_filter('the_title', 'change_title');
Hope, this may be useful for you.
Upvotes: 0