Custom fields randomly stop working

get_the_ID() is a post tag. It is meant to be used inside a Loop. Per a comment above you are using it outside the Loop. No, it’s not inside Loop. The code is simply posted within another div, which holds slides for a slideshow. get_the_ID like most post tags depends on a global variable called … Read more

Load code for custom fields only on admin pages?

Loading this code won’t have big impact on loading times. Of course you should make sure, that this code is only executed when it should be… But yes, it should be possible. Just make sure you don’t use it to early (when is_admin() return incorrect value). EDIT The code you’ve posted here should work just … Read more

Custom Field add markup to line breaks

I believe this is what you are after: // define $post_id, $key, $single $multipleLineValue = get_post_meta($post_id, $key, $single); // Convert into an array where desired code can be added to the output $multipleLineValue = explode(“\n”,$multipleLineValue); $output = “”; foreach ($multipleLineValue as $lineValue) { $output .= “<span>”.$lineValue.”</span><br>”; } echo $output;

Echo custom field value

Repost for any future googlers from @StenW ‘s wordpress plugin support thread: Github user @atnon made a very similar modification to the code 10 days ago, also using custom-fields (though giving the image a link rather than putting a link in the caption). You can see this code in his pull request. I re-wrote his … Read more

Show message if statement is false – foreach

OK, it’s a lot of guessing, because I can’t see the rest of your code, but something like this should work, I hope… <?php $value = get_post_custom_values(“kpm_UploadFile”); $url = ($value[0]); $tokens = explode(“https://wordpress.stackexchange.com/”, $url); $dlvalue = $tokens[sizeof($tokens)-1]; if (current_user_can(‘read’)) { $found = 0; foreach ($files_array as $key => $val) { if ($dlvalue == $val) { … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)