[help] PHP WordPress Question

MinMary

Active member
Trusted Uploader
Sep 22, 2019
111
33
28
I am using Astra Pro Custom layouts. I have created a hook that only executes my code in specific post types. All PHP code in there works except for this except when I place it in functions.php

Does anyone know how to run this from the plugin?

Code:
add_action('admin_head', 'populating_your_custom_field');
add_action('wp_head', 'populating_your_custom_field');

function populating_your_custom_field(){
  $your_custom_field_value = the_field("field_607aa2cb60022");

  if (empty($your_custom_field_value)) {
    $your_custom_field_value = "Random text for testing";
    update_field("field_607aa2cb60022", $your_custom_field_value);
  }
}

Thanks
 
Last edited:

ddpanda

BlockeD!
Babiato Lover
Trusted Uploader
Banned User
Sep 5, 2019
1,778
2,834
120
old.ddpanda.club
I am using Astra Custom layouts. I have created a hook that only executes my code in specific post types. All PHP code in there works except for this except when I place it in functions.php

Does anyone know how to run this from the plugin?

Code:
add_action('admin_head', 'populating_your_custom_field');
add_action('wp_head', 'populating_your_custom_field');

function populating_your_custom_field(){
  $your_custom_field_value = the_field("field_607aa2cb60022");

  if (empty($your_custom_field_value)) {
    $your_custom_field_value = "Random text for testing";
    update_field("field_607aa2cb60022", $your_custom_field_value);
  }
}

Thanks
its not a correct sub-forum to post your query! moving your post.
 

Groot

Well-known member
Jun 17, 2020
412
415
63
Op. You should ask this in Astra Community at WordPress org!
 

Groot

Well-known member
Jun 17, 2020
412
415
63
@sidasu20 How can you expect me to request support for a nulled plugin?
No, Astra community in WP org is free, you just need reg an account at WP org. Astra' users or supporters can give you ideas to solve your problems, and if you need high level support, pay for it.
Really, I and many members here can help you but I guess you must wait for days. Check code and help others to solve their problems asap not still my passion anymore.
Gluck!
 

MinMary

Active member
Trusted Uploader
Sep 22, 2019
111
33
28
Looks like you're new to WP. I am using the PRO version of Astra for goodness sake. The PRO version has a custom layout functionality which is not available for free. So when you require me to ask for support for premium functionality, clearly you're out of reach. I appreciate the response though it's wrong. WP Community is free for free plugins in WP Plugins repository. If you are using a premium plugin, you have to request support from the author premium support. :rolleyes:
 
  • Like
Reactions: sidasu

Groot

Well-known member
Jun 17, 2020
412
415
63
Looks like you're new to WP. I am using the PRO version of Astra for goodness sake. The PRO version has a custom layout functionality which is not available for free. So when you require me to ask for support for premium functionality, clearly you're out of reach. I appreciate the response though it's wrong. WP Community is free for free plugins in WP Plugins repository. If you are using a premium plugin, you have to request support from the author premium support. :rolleyes:
I'm PHP and WP dev over ten years, not newbie. Really you can ask advanced problems on community at WP org, they just not support if you ask they give the answer asap or must login your website to find & solve your problems, not only supporters of product can help you, many advanced users also help you solve your problems easily!
I did take years to help others solve their advanced problems at WP org and StackOverflow before, but from I move my career from freelance to my own agency, I lost my passion to do it then!
Good luck!
 

frizzel

Well-known member
Trusted Uploader
Jun 13, 2019
485
253
63
Wherever my imagination takes me
Really you can ask advanced problems on community at WP org, they just not support if you ask they give the answer asap or must login your website to find & solve your problems, not only supporters of product can help you, many advanced users also help you solve your problems easily!
Not true, if you ask questions about PRO products, the thread will be quickly blocked by a moderator, as that is not allowed.

Anyway, in answer to OP: you have 2 actions with the same name, only with different hooks. That's not going to work, add only 1 action to the function.
 

MinMary

Active member
Trusted Uploader
Sep 22, 2019
111
33
28
Not true, if you ask questions about PRO products, the thread will be quickly blocked by a moderator, as that is not allowed.

Anyway, in answer to OP: you have 2 actions with the same name, only with different hooks. That's not going to work, add only 1 action to the function.
Thanks for the answer and indeed the clarification!
 

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu