Hot answers tagged

1

You can use the function get_the_author_meta() to get the emailaddress of the author of the current post and the wp_mail()function to send an e-mail <?php $timelimit=1 * 604800; //1 week * seconds per day $post_age = date('U') - get_post_time('U'); if ($post_age < $timelimit) : ?> // Current <?php elseif ($post_age > $timelimit) : $...


1

There are three problems 1. echo and php tags within an echo Change your first echo from: echo '<img src="http://img.youtube.com/vi/<?php echo get_post_meta($post->ID,'video_url',true);?>/0.jpg"/>'; to this: echo '<img src="http://img.youtube.com/vi/' . get_post_meta($post->ID,'video_url',true) . '/0.jpg"/>'; 2. if statement ...


1

I would suggest checking out a geolocation service to lookup the location of the users IP address, such as freegeoip.net. In order to do this you would need to make a rest api get request either through php or javascript. To get the ip address of the visiting user you can read in <?php echo $_SERVER['REMOTE_ADDR']; ?> then send that off to the ...


1

Your problem is that current_user_can() takes a capability not a user role. So, to check for an administrator, for example, you might use: if ( current_user_can( 'manage_options' ) ) { ... } because ordinarily only admins can manage options. You'd have to tie your custom user roles to capabilities that correspond to their roles, which are defined for ...


1

Note that did_action only takes one input argument: the name of the action hook. The scope of your if sentence is also unclear. I don't think you want to use did_action at all here, it doesn't give you the number of emails. You can try the following instead: if ( $unread = do_shortcode( '[input-unread]' ) ) printf( "<span class='new badge'>%s&...


1

You should do this in the shortcode/plugin itself. An easy way to do it may be something like this: // if the shortcodes empty: if ( empty( $shortcode_content ) ) { // set a default nothing found message $shortcode_content = 'Sorry! Nothing found'; } return $shortcode_content;


1

If I understand you right you just want to use a '?' type of if statement: $output = '<div class="w-blog-entry" style="padding:0;"> <div class="w-blog-entry-h"> <div class="l-subsection color_dark" style="background-image: url('.$the_thumbnail.'); background-position: center center; ...



Only top voted, non community-wiki answers of a minimum length are eligible