wordpress - Conditional execution of function by post date -


below code need executed on posts till particular date, eg. november 11, 2015.

i know if...else condition, don't have idea how create condition. kind of appreciated...

so in fact /this wordpress/ need "format" in way posts till particular date, , posts newer date excluded function below:

function user_content_replace($content) {  $sentences_per_paragraph = 3; // settings  $pattern = '~(?<=[.?!…])\s+~'; // punctuation , trailing space(s)  $sentences_array = preg_split($pattern, $content, -1, preg_split_no_empty); // sentences array  $sentences_count = count($sentences_array); // count sentences  $output = ''; // new content init  // see php modulus for($i = 0; $i < $sentences_count; $i++) {     if($i%$sentences_per_paragraph == 0 && $i == 0) { //divisible settings , first         $output .= "<p>" . $sentences_array[$i] . ' '; // add paragraph , first sentence     } elseif($i%$sentences_per_paragraph == 0 && $i > 0) { //divisible settings , not first         $output .= "</p><p>" . $sentences_array[$i] . ' '; // close , open paragraph, add first sentence     } else {         $output .= $sentences_array[$i] . ' '; // concatenate other sentences     } }  $output .= "</p>"; // close last paragraph  echo $output; } add_filter('the_content','user_content_replace', 99); 

something

function user_content_replace($content) {     global $post;     if (strtotime($post->post_date) <= strtotime('11.11.2015'))     {         $sentences_per_paragraph = 3; // settings         $pattern = '~(?<=[.?!…])\s+~'; // punctuation , trailing space(s)         $sentences_array = preg_split($pattern, $content, -1, preg_split_no_empty); // sentences array         $sentences_count = count($sentences_array); // count sentences         $output = ''; // new content init         // see php modulus         ($i = 0; $i < $sentences_count; $i++)         {             if ($i % $sentences_per_paragraph == 0 && $i == 0) //divisible settings , first             {                 $output .= "<p>" . $sentences_array[$i] . ' '; // add paragraph , first sentence             }             elseif ($i % $sentences_per_paragraph == 0 && $i > 0) //divisible settings , not first             {                 $output .= "</p><p>" . $sentences_array[$i] . ' '; // close , open paragraph, add first sentence             }             else             {                 $output .= $sentences_array[$i] . ' '; // concatenate other sentences             }         }         $output .= "</p>"; // close last paragraph         return $output;     }     else     {         return $content;     } }  add_filter('the_content', 'user_content_replace', 99); 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo