So you are auto inserting "[ad]" at start and end of post content and this gets saved with the post?
Then at runtime "[ad]" gets replaced with the actual advertisement.
What do you see when you open a post for editing, do you see...
Some posts may have first and some the other.
If that is the case then following script will remove all placeholders.
Save following as adremove.aspx page in blog root.
On first run use "<p>[ad]</p>" replacement and then do a second run with "[ad]" replacement.
<%@ Page Language="C#" %>
<%@ Import Namespace="BlogEngine.Core" %>
protected void Button1_Click(object sender, EventArgs e)
var posts = Post.Posts;
for (int i = 0; i < posts.Count; i++)
Post p = posts[i];
p.Content = p.Content.Replace("<p>[ad]</p>", string.Empty); // first run - comment out for second run
//p.Content = p.Content.Replace("[ad]", string.Empty); // uncomment and use me on second run
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Height="100px"
Text="Remove ads" Width="166px" onclick="Button1_Click" />
If using this script, you would then need to insert ads at runtime at specific positions rather than as placeholder substitution.
However, this starts to get complicated if you are checking for images and possibly other objects(maybe video and such like).
Also what if post is very short and only has a few paragraphs, there are many unknowns.
How about having both placeholder ads at the end of each post and then position first ad absolutely to 'appear' at the top of each post.
This is far from ideal, but much simpler.