Created
October 12, 2015 06:45
-
-
Save Aziz-Rahman/77a77390937504132041 to your computer and use it in GitHub Desktop.
Example table prefix in wp multisite/ not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( is_multisite() ) : | |
global $wpdb, $table_prefix; | |
$table_name = $table_prefix . 'postmeta'; // output wp_#_postmeta (multisite) # = id multisite (automatic) | |
$select_data = $wpdb->get_results( "SELECT meta_value FROM $table_name WHERE meta_value = '$warrior_url_topic'" ); | |
$check_url_exists = $wpdb->num_rows; | |
foreach ( $select_data as $obj ) { | |
$wp_data = $obj->meta_value; | |
} | |
else : | |
global $wpdb; | |
$table_name = $wpdb->base_prefix . 'postmeta'; // output wp_postmeta (not multisite) | |
$select_data = $wpdb->get_results( "SELECT meta_value FROM $table_name WHERE meta_value = '$warrior_url_topic'" ); | |
$check_url_exists = $wpdb->num_rows; | |
foreach ( $select_data as $obj ) { | |
$wp_data = $obj->meta_value; | |
} | |
endif; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment