Nathan Nawbi
Forum Replies Created
-
Forum: Plugins
In reply to: how to get all contents from paginated postclosing…
Forum: Plugins
In reply to: how to get all contents from paginated postoh wait. i can use $post->post_content instead.
never mind….Forum: Fixing WordPress
In reply to: replacing content text in the postthank you very much Venugopal!
Apologies that I didn’t explain more specific.
The reason why I am trying to find a efficient way is:for example, in a content, there will be a text “SOMETHING”,
and I want to replace it to be “<div>SOMETHING<span>EVERYTHING</span></div>”.But each word is not the same. that is why I wanted to make a pattern.
so the code I wrote for was to explain that:
function replace_content($content) { $replace_pattern = '#text A-01#' , '#text A-02#'; $replace_pattern = '#text B-01#' , '#text B-02#'; $replace_pattern = '#text C-01#' , '#text C-02#'; $content = str_replace('$replace_pattern(text01)', '<div>$replace_pattern(text01)<span>$replace_pattern(text02)</span></div>',$content); return $content; } add_filter('the_content','replace_content');
to find “#text A-01#” in the content and replace it to be”<div>#text A-01#<span>#text A-02#</span></div>”
each text (like “#text A-01#”) has a matching text (like “#text A-02#”) to be replaced with.
Do you understand what I am trying to say??
Thank you very much for helping me!
Forum: Fixing WordPress
In reply to: replacing content text in the postthanks, Venugopal!
I already know that code will work…
but I have so many text to replace, so I wanted to make it more efficient.
like,function replace_content($content) { $replace_pattern = '#text A-01#' , '#text A-02#'; $replace_pattern = '#text B-01#' , '#text B-02#'; $replace_pattern = '#text C-01#' , '#text C-02#'; $content = str_replace('$replace_pattern(text01)', '<div>$replace_pattern(text01)<span>$replace_pattern(text02)</span></div>',$content); return $content; } add_filter('the_content','replace_content');
Instead of just adding the entire replacing code, I want to add the ‘$replace-pattern’ so it would be easier to manage.
I don’t even know how or if there’s any way to do this…thanks again!
Forum: Fixing WordPress
In reply to: How to find same text as in tags inside the post contentthank you so much Ncej!!!
it works exactly as I wanted!you’re so cool! ??
thanks a lot!