Use ajax response in PHP function

Instead of cooking up your own PHP file and trying to bring in WordPress functionality, put the functionality inside of WordPress using the AJAX hooks that are designed to do that sort of thing. More info here: http://codex.wordpress.org/AJAX_in_Plugins

How to filter part of a variable if it is no array?

The documentation is well explicable of the topic, let’s have a look here https://developer.wordpress.org/reference/functions/apply_filters/. In your specific case my_filter is applied no matter what, even if there is no value it. To apply the filter only if is_array() you could insert a specific instruction directly into your filter like: function example_callback( $output ) { if(is_array($output)){ … Read more

Import and use a variable in additional settings of Contact Form 7 [closed]

if only the domain changes, you could try using relative urls: document.location=”/thank-you”; But if the domain you’re redirecting to is different than the page you’re on, a simple way to fix this problem would be to add a customizer value redirect_domain, and then make it a global variable in footer.php <script>var RedirectUrl=<?php echo get_theme_mod(redirect_domain);?></script> then … Read more

Trying to get this function to show below the content

If it was me I’d not echo the text I’d make it a variable e.g. $additional_text = “” then at the end of the function return $additional_text;. if (have_posts()) : while (have_posts()) : the_post(); $additional_text=”<div class=”timeline”>”; $additional_text .= ‘<a href=”‘; $additional_text .= the_permalink(); $additional_text .= ‘”><h3>’; $additional_text .= the_title(); $additional_text .= ‘</h3></a>’; $additional_text .= ‘</div>’; … Read more

WordPress loop put title into variable

Creating variables on the fly like that is not needed. Just use an array instead. $myvars = []; inside your foreach loop you can: $myvars[] = array(‘title’=>$t,’image’=>$v); After your loop you can: //First title, First image echo $myvars[0][‘title’]; echo $myvars[0][‘image’]; //Second title, Second image echo $myvars[1][‘title’]; echo $myvars[1][‘image’]; This way you can always print_r($myvars) and … Read more

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