Reputation: 13
I'm using a wordpress plugin to display real estate data. I need to display a certain snippet of code in the wordpress footer when a certain value is found in the db. Specifics. I already have the footer code displaying using the following function:
// Adds Tucson Association of Realtors required board html to wp_footer()
dynamically.
function wwidx_footer_script() { ?>
<div class="aztarfooter" style="text-align:center;">©2016 Tucson Association of Realtors. All rights reserved. All information deemed reliable, but Not Guaranteed. IDX information is provided exclusively for consumers' personal, non-commercial use and may not be used for any purpose other than to identify prospective properties consumers may be interested in purchasing.<br> <br><img src="https://www.weeboweb.com/wp-content/uploads/2016/10/tarlogo.gif"><br><img src="https://www.weeboweb.com/wp-content/uploads/2017/05/EHO-logo-e1494994377845.jpeg"> <img src="https://www.weeboweb.com/wp-content/uploads/2017/05/MLS_Clear-1-e1494994488609.jpg"></div>
<?php }
add_action( 'wp_footer', 'wwidx_footer_script' );
This function displays the code exactly where and almost how I want. The problem is that I need to make it dynamic. In my DB, there is a table called wp_realty_controlpanel
. In that table, there is a field called controlpanel_masterdb_user
. When the value in that table is "wwidx_az_tar"
I want the code to display, otherwise not. You can see the snippet exactly where I want it here Link.
Any help is appreciated.
Upvotes: 1
Views: 186
Reputation: 4870
function wwidx_footer_script() {
global $wpdb;
$table_name = $wpdb->prefix . "realty_controlpanel";
$results = $wpdb->get_row( "SELECT controlpanel_masterdb_user FROM $table_name WHERE controlpanel_masterdb_user = 'wwidx_az_tar' " );
if( $results->controlpanel_masterdb_user == "wwidx_az_tar" ){ ?>
<div class="aztarfooter" style="text-align:center;">©2016 Tucson Association of Realtors. All rights reserved. All information deemed reliable, but Not Guaranteed. IDX information is provided exclusively for consumers' personal, non-commercial use and may not be used for any purpose other than to identify prospective properties consumers may be interested in purchasing.<br> <br><img src="https://www.weeboweb.com/wp-content/uploads/2016/10/tarlogo.gif"><br><img src="https://www.weeboweb.com/wp-content/uploads/2017/05/EHO-logo-e1494994377845.jpeg"> <img src="https://www.weeboweb.com/wp-content/uploads/2017/05/MLS_Clear-1-e1494994488609.jpg"></div>
<?php
}
}
add_action( 'wp_footer', 'wwidx_footer_script' );
Would you please try above code?
Upvotes: 1