How to send email when my plugin is activated?

I offer you an idea that I have already used something like this. I wanted to know the sites that my plugin uses, I created a cron job allow me to send me an email every week : add_action(‘init’, function() { $time = wp_next_scheduled(‘dro_cron_hook’); wp_unschedule_event($time, ‘dro_cron_hook’); if (!wp_next_scheduled(‘dro_cron_hook’)) { wp_schedule_event(time(), ‘everyweek’, ‘dro_cron_hook’); } }); add_filter(‘cron_schedules’, … Read more

the_time() cannot be placed correctly

<p> <?php the_time() ?> </p> It helps with separation of concerns and increases readability of code as well as being consistent with WordPress coding standards and the default coding style. The first method you attempted is completely invalid, the_time() only accepts 1 parameter, the date format. The second method has roots in validity, but the_time() … Read more

Show only posts from todays date [duplicate]

If you just want posts from today, it’s super easy and right in the WP codex: <?php $today = getdate(); $args = array( ‘date_query’ => array( array( ‘year’ => $today[‘year’], ‘month’ => $today[‘mon’], ‘day’ => $today[‘mday’], ), ), ); $custom_query = new WP_Query( $args ); ?> <?php if ($custom_query->have_posts()) : while ($custom_query->have_posts()) : $custom_query->the_post(); ?> … Read more

Is it a bad idea to CHMOD 777 all the files on your site?

My original comment: Is chmod 777 a good idea? if it’s not absolutely necessary (which if your server’s users and groups are properly configured it’s usually not) then avoid it. is it as terrible and the omg you’re gonna get hacked any second now disaster everyone makes it out to be? not quite, but again … Read more

Post count by meta_key meta_value [closed]

// retrieve all meta_values with key ‘state’ from database $state_posts = $wpdb->get_results(” SELECT meta_value FROM “. $wpdb->prefix.”postmeta WHERE meta_key = ‘state’ ORDER BY meta_value ASC”, ARRAY_A ); // define counting array $state_count = array(); // iterate through meta_values, count the occurence of each state foreach ( $state_posts as $state_post ) { if ( isset ( … Read more

Hide the contents for specific post

Your code doesn’t seem to be trying to hide the content, but you can use the_content filter to return an empty content if you are on a specific post page. For example: add_filter(‘the_content’, ‘hide_post_contents’); function hide_post_contents( $content ) { if( is_single(3) ) { return ”; } return $content; } Also, there is a mistype in … Read more

Move specific javascript to the footer

It is generally not recommended to put move javascript files to the footer, especially WordPress dependencies. WordPress and plugins require and expect dependencies to be in the header and things can go awry if they aren’t. There are workarounds for this, but in many cases if you do move things to the footer and a … Read more