[-]
Tags
wordpress gurus please help me out


Hi Guest, kindly Login Or Register To Unlock More Advanced Features In Wapforum


Wordpress Gurus Please Help Me Out
(1.2k )
#1
Hello. Dear my fellow webmasters how can I add post view inside content I have tried but it's not counting the view

I have added the post view to function.php and I placed the shortcode to my content.php

It's just showing 0Views

Front page pls @flexible


Attached Files Thumbnail(s)
   


#2
@Forumhub

Add The Following Codes To Your Functions.php File

// function to display number of posts.
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0 View";
}
return $count.' Views';
}

// function to count views.
function setPostViews($postID) {
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}

// Remove issues with prefetching adding extra views
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);

// Add to a column in WP-Admin
add_filter('manage_posts_columns', 'posts_column_views');
add_action('manage_posts_custom_column', 'posts_custom_column_views',5,2);
function posts_column_views($defaults){
$defaults['post_views'] = __('Post Views By Codtechinix');
return $defaults;
}
function posts_custom_column_views($column_name, $id){
if($column_name === 'post_views'){
echo getPostViews(get_the_ID());
}
}

Then Add This Following Codes To The File That Displays Post
Find The While Post Loop And Replace With

while(have_posts()){
the_post();
setPostViews(get_the_ID());
?>

At The Top Before The Html Codes Below

From The code Added To Your functions.php File, You Can See every post view counts At The backend when You open The Post Section

But To display It At The Frontend Add This Code Where You Want It to Be See
In The Post

echo getPostViews(get_the_ID());
?>

Any Error Or Help Reply Here I will Help You Out
#Codetechinix_To_The_World

@Forumhub
Check Out https://akwamuzik.com.ng

Forumhub likes this post

#3
(22-02-2020, 02:36 PM)Forumhub Wrote: Hello. Dear my fellow webmasters how can I add post view inside content I have tried but it's not counting the view

I have added the post view to function.php and I placed the shortcode to my content.php

It's just showing 0Views

Front page pls @flexible

What's. Your site built in??
What cms??


#4
(24-02-2020, 11:38 PM)CODETECHINIX Wrote:
You Must Reply To This Post!. Before You Can See The Download Link
Login Or Register
To See The Hidden Link

Add The Following Codes To Your Functions.php File

// function to display number of posts.
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0 View";
}
return $count.' Views';
}

// function to count views.
function setPostViews($postID) {
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}

// Remove issues with prefetching adding extra views
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);

// Add to a column in WP-Admin
add_filter('manage_posts_columns', 'posts_column_views');
add_action('manage_posts_custom_column', 'posts_custom_column_views',5,2);
function posts_column_views($defaults){
$defaults['post_views'] = __('Post Views By Codtechinix');
return $defaults;
}
function posts_custom_column_views($column_name, $id){
if($column_name === 'post_views'){
echo getPostViews(get_the_ID());
}
}

Then Add This Following Codes To The File That Displays Post
Find The While Post Loop And Replace With

while(have_posts()){
the_post();
setPostViews(get_the_ID());
?>

At The Top Before The Html Codes Below

From The code Added To Your functions.php File, You Can See every post view counts At The backend when You open The Post Section

But To display It At The Frontend Add This Code Where You Want It to Be See
In The Post

echo getPostViews(get_the_ID());
?>

Any Error Or Help Reply Here I will Help You Out
#Codetechinix_To_The_World

@Forumhub
Check Out https://akwamuzik.com.ng

That's good bro thanks for your help


#5
(01-03-2020, 02:04 AM)Forumhub Wrote:
You Must Reply To This Post!. Before You Can See The Download Link
Login Or Register
To See The Hidden Link

Add The Following Codes To Your Functions.php File

// function to display number of posts.
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0 View";
}
return $count.' Views';
}

// function to count views.
function setPostViews($postID) {
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}

// Remove issues with prefetching adding extra views
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);

// Add to a column in WP-Admin
add_filter('manage_posts_columns', 'posts_column_views');
add_action('manage_posts_custom_column', 'posts_custom_column_views',5,2);
function posts_column_views($defaults){
$defaults['post_views'] = __('Post Views By Codtechinix');
return $defaults;
}
function posts_custom_column_views($column_name, $id){
if($column_name === 'post_views'){
echo getPostViews(get_the_ID());
}
}

Then Add This Following Codes To The File That Displays Post
Find The While Post Loop And Replace With

while(have_posts()){
the_post();
setPostViews(get_the_ID());
?>

At The Top Before The Html Codes Below

From The code Added To Your functions.php File, You Can See every post view counts At The backend when You open The Post Section

But To display It At The Frontend Add This Code Where You Want It to Be See
In The Post

echo getPostViews(get_the_ID());
?>

Any Error Or Help Reply Here I will Help You Out
#Codetechinix_To_The_World

@Forumhub
Check Out https://akwamuzik.com.ng

That's good bro thanks for your helpGLAD TO HEAR THAT


#6
Good one but if you are using Wordpress, some templates come with such feature by default, you can just slide a button to enable post view count but I guess the template you are using is lacking such features. Meanwhile, I wonder why you need a post view that easily tells your competitors which page that ranks on your page.

Forumhub likes this post

#7
(02-03-2020, 03:50 PM)Julius2 Wrote: Good one but if you are using Wordpress, some templates come with such feature by default, you can just slide a button to enable post view count but I guess the template you are using is lacking such features. Meanwhile, I wonder why you need a post view that easily tells your competitors which page that ranks on your page.

You are right though


Share This Post To The World






Users browsing this thread: 1 Guest(s)
Goto First Post In This Thread



Possibly Related Threads...
Thread Author Replies Views Last Post
  HELP: Serious Help Needed On My Ultimate Affiliate Pro Plugin korevibes 2 749 29-10-2019, 02:03 PM
Last Post: korevibes
Thumbs Up TUTORIAL: Who Is Online, Lets Help On Coding, Not Just About Cloning (come In) khodex 7 1.7k 22-10-2019, 08:55 AM
Last Post: Gentlebee
  HELP: Pls Help Me Review This Forum Talkland forum 0 854 01-05-2019, 12:24 PM
Last Post: Talkland forum
  SHARED: Free Wordpress Mp3 Tag Code In Php Scorpido 3 2.5k 26-04-2019, 09:53 PM
Last Post: phanteez
  HELP: Please I Need The Help Of The Buses In The Building Concerning My Website MIZTERJAGABAN 0 1.1k 07-04-2019, 12:44 AM
Last Post: MIZTERJAGABAN
  HELP: Abeg Oo Make Una Help okaigun 0 1.2k 09-02-2019, 09:51 AM
Last Post: okaigun
  HELP: Could You Please Tell Me Which Kind Of Website And Hosting Is This??? Danilo 0 1.8k 14-11-2018, 04:38 PM
Last Post: Danilo




Advertisement