Anyone know which function I can use in the loop to separate and edit posts by ids?
default values:
single.php
file
$dlm128=get_post_meta($post_id,'music128',true);
$dlm320=get_post_meta($post_id,'music320',true);
If specific conditions are met( $constantvalue= "anothervalue" ), I want to update the post; else, I want to leave it the same.
I don't want to alter MySQL; instead, I'd like to change the single.php
file in the post loop.
thanks for your support.
I looked on the internet but couldn't discover a solution.(a function)
CodePudding user response:
If you know the conditions that you're looking for, you should be able to write an IF
statement to match.
if ($constantvalue == "anothervalue") {
// make local changes
}
Can you give an example of what you're trying to do? It's hard to understand the request with such little information.
CodePudding user response:
Try like this hope its working for you.
while(have_posts()):
$ID = get_the_ID();
$data1 = get_post_meta($ID,'meta_key',true);
$data2 = get_post_meta($ID,'meta_key',true);
if($data1 == $data2) {
update_post_meta($ID,'meta_key','meta_value');
}
endwhile;