In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how WordPress displays ads in articles that have been published for more than 15 days. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.
How does WordPress display ads in articles that have been published for more than 15 days?
WordPress displays ads in articles that have been published for more than 15 days.
Suppose we need to display ads in articles that have been published for more than 15 days, and we only need to set up the code to do it today.
Step one:
The function is easy to implement, using the PHP editor to open the functions.php file of the current template.
Copy the following code into it:
The code is as follows:
Function is_old_post ($post_id=null) {$days = 15; global $wp_query; if (is_single () | | is_page ()) {if (! $post_id) {$post_id= $wp_query- > post- > ID;} $current_date = time (); $offset = $days * 60mm 60mm 24; $post_id= get_post ($post_id); $post_date = mysql2date ('Upright Magnum postcards-> post_date); $cunning_math = $post_date + $offset; $test = $current_date-$cunning_math If ($test > 0) {$return = true;} else {$return = false;}} else {$return = false;} return $return;}
Step 2:
Open the single.php file and copy the following code in:
The code is as follows:
< ?php if(is_old_post()){ ?>INSERT AD CODE HERE
< ?php } ?>After the modification, the ad will only be displayed in the log with a release date of more than 15 days, which can be modified. In the code copied into functions.php, there is a sentence: $days= 15; here the value of $days=num; num can be set at will.
Thank you for reading! So much for the way WordPress displays ads in articles that have been published for more than 15 days. I hope the above content can be helpful to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.