Jump to content
Sign in to follow this  
jankowalski

WP-PostViews display count

Recommended Posts

jankowalski

Hey! I would like to display the number of views in the post byline information thanks to WP-PostViews plugin. WP-PostViews user guide says: 1) Open wp-content/themes//index.php 2) You may place it in archive.php, single.php, post.php or page.php also. 3) Find: <?php while (have_posts()) : the_post(); ?> 4) Add Anywhere Below It (The Place You Want The Views To Show): <?php if(function_exists('the_views')) { the_views(); } ?> I found some instructions on this forum for platform pro, but it is very diferent to framework and do not apply. I understand I should use a "hook" but I don't know how to proceed. Can anyone tell me please? Thank you for your help.

Share this post


Link to post
Share on other sites
batman

Now I copy you a rangelone??s example (he is one Moderator and ask you a live link in this "http://www.pagelines.com/forum/discussion/21347/hide-sidebar-for-individual-post-pages#Item_10" to help you better with your particular case, there are a lot of different code add and plugin installed in each user, it can modify the recommendation) ;)The rangelone??s tutorial:

add_action('brandnav_after_nav', 'brandnav_icons');
	function brandnav_icons() { ?>
	
  • facebook.png;
  • twitter.png;
<?php }[/code]

[b]Notice this first part:[/b] add_action('brandnav_after_nav', 'brandnav_icons'); function brandnav_icons() { ?> [b]brandnav_after_nav[/b] is the hook. This is what determines where your desired content is placed. It's pretty easy to understand since hooks are named accordingly. In this case, brandnav_after_nav means that the content you place in this hook will be placed after the brand navigation. Does that make sense? [b]brandnav_icons[/b] is the name given to the content you want to add. You can name it however you'd like, but it's best to give it a descriptive name so that you know what it's for. This name is supposed to go in two places (as shown in the code above).


Life is too short to remove USB safely ...

Share this post


Link to post
Share on other sites
batman

@Catrina is a honor for me post all Catrina / simple_mama / Simon / Danny / rangelone / jamieb23 / beardedavenger ??s tutorials, always they are very usefull for me to keep learning. ;)


Life is too short to remove USB safely ...

Share this post


Link to post
Share on other sites
jankowalski

thanks for info. This is really useful. if there is any place where i can find those tutorials? Anyway, i created this new function for my test purposes and it works ok

/*  adding post views */
	add_action('pagelines_before_postloop', 'postview');
	function postview() { ?>
	<?php if(function_exists('the_views')) { the_views(); } ?>
	<?php }

now instead of creating new line i want to insert this content to metabar so how can i inset this into metabar?

Share this post


Link to post
Share on other sites
Rob

Using the Action Map, you can identify the proper elements to include in a hook that can be modified from what you wrote earlier. Let me also point out the ShortCode Exec PHP plugin, which would take

<?php if(function_exists('the_views')) { the_views(); } ?>

and convert it to a shortcode. You can add that shortcode into the metabar in Framework's Blog & Posts settings.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
jankowalski

I used Action Map and i found pagelines_post_metabar but it doesn t show up. it only shows up when use: pagelines_before_postloop Thanks, ShortCode Exec PHP plugin makes the trick temporarily , however i don t want to install separate plugin for every functionality because it slows down my page. how can i write a function to add shortcode?

Share this post


Link to post
Share on other sites
Rob

That's an extremely light plugin and works very well in the background, quietly and with minimal impact. You can't convert a php snippet into shortcode without it. But once you do, I'm confident you'll be extremely pleased with the results. I think the code for including a shortcode in a function is do_shortcode() but I don't know how that's implemented. I'd suggest Googling it or searching the WordPress codex.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
jankowalski

i already did it, and it works, thanks. i tried to do it by code

//[foobar]
	function foobar_func( $atts ){
	 return "my shortcode goes here";
	}
	add_shortcode( 'foobar', 'foobar_func' );
but didn t realize that php won t work. so i assume this is bad...??
//[foobar]
	function foobar_func( $atts ){
	 return "<?php if(function_exists('the_views')) { the_views(); } ?>";
	}
	add_shortcode( 'foobar', 'foobar_func' );

thanks

Share this post


Link to post
Share on other sites
Rob

Honestly, I don't know. Worst case, if you try it and it doesn't, you know just what to fix or remove. But since you've accomplished your goal, is it worth experimenting? Glad you were able to get this done!


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×