0

I want to apply a function if post is updated and if post author id is not 1. For this i tried many functions like

<?php if (get_the_modified_time() != get_the_time()) && ( $author_id != 1 ) : ?>

By this code if post is updated is working but if post author is not 1 not working. Please help me!

closed as off-topic by Michael, TheDeadMedic, Howdy_McGee, Mayeenul Islam, Nicolai Mar 30 '16 at 18:01

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • $author_id is undefined in your code. – fuxia Mar 20 '16 at 23:36
1

Finally i find answer. The perfect code is

<?php $author_id = $post->post_author; if (get_the_modified_time() != get_the_time() && ( $author_id != 1 )): ?>

That's all.

1

With a global $post object you could check the conditions also like this:

global $post;
if ( $post->post_date != $post->post_modified && $post->post_author != 1 ) :
    // your code
endif;

But if you prefer to use just functions then you can do this:

if ( get_the_modified_time() != get_the_time() && get_the_author_meta( 'ID' ) != 1 ) :
    // your code
endif;
0

this should work

<?php if (get_the_modified_time() != get_the_time() && ( $author_id != 1 )): ?>
  • This is not working. – akarim Feb 10 '16 at 15:05
  • 1
    Code only answers are usually marked as "Low Quality". Could you expand on your answer and explain how this is a solution to the current problem? – Howdy_McGee Feb 10 '16 at 16:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.