i am ussing madara theme (i cant post here the link for my site sorry) this is the demo of my theme https://mangabooth.com/ https://live.mangabooth.com/
if helps this is the extra code for the views i have on functions
/**
* Add columns “views” to table manga_chapters
**/
//add_action("after_switch_theme", "my_manga_add_columns");
//function my_manga_add_columns(){
//global $wpdb;
//$db = WP_MANGA_DATABASE::get_instance();
//if(!$db->column_exists($wpdb->prefix . 'manga_chapters', 'views')){
//$db->alter_add_column($wpdb->prefix . 'manga_chapters', 'views', 'int');
//}
//}
/**
* Show the views
**/
add_action('wp_manga_after_chapter_name', 'my_manga_chapter_name_info', 10, 2);
function my_manga_chapter_name_info($chapter, $manga_id){
$views = manga_get_chapter_views($chapter['chapter_id']);
echo '<i style="margin-right:50px;"><span class="view"><i class="fa fa-eye"></i> ' . $views . '</span></i>';
}
function manga_get_chapter_views($chapter_id){
global $wpdb;
$sql = "SELECT views from {$wpdb->prefix}manga_chapters WHERE chapter_id=%d" ;
$views = $wpdb->get_var($wpdb->prepare($sql, $chapter_id));
return $views ? $views : 0;
}
/**
* Increase the views
**/
add_action('after_manga_single', 'my_manga_chapter_views');
function my_manga_chapter_views(){
$cur_chap = get_query_var( 'chapter' );
$manga_id = get_the_ID();
if($cur_chap != ""){
global $wp_manga_chapter;
$chapter = $wp_manga_chapter->get_chapter_by_slug( $manga_id, $cur_chap );
if($chapter){
$chapter_id = $chapter['chapter_id'];
global $wpdb;
$views = manga_get_chapter_views($chapter_id);
$wpdb->update("{$wpdb->prefix}manga_chapters", array('views'=>++$views), array('chapter_id' => $chapter_id));
}
}
}
-
This reply was modified 3 years, 1 month ago by
vl4d.