Jump to content
Sign in to follow this  
inov8ed

inserting something at the end of the metabar

Recommended Posts

inov8ed

Hi, I am trying to insert the number of postviews at the end of the platformpro metabar that shows post views. I seem to have just about everything working using a bunch of hooks and this filter to insert into the metabar: ` add_filter('pagelines_post_metabar', 'customize_metabar'); function customize_metabar($metabar){ $mymetabar = $metabar . userfunc_get_post_views(get_the_ID(), true); //$metabar is the original metabar return $mymetabar; } ` The only problem is, that instead of inserting it at the end of the bar after "leave a comment", it makes a whole new metabar above the current one. If I switch the code to just plain text in a single quote, ie `$metabar.'some text';` then it places the text in the right place. Any ideas what I need to do? Thanks! -Adam

Share this post


Link to post
Share on other sites
catrina

Have you already tried out this code? (from the other topic)?:

add_filter('pagelines_post_metabar', 'customize_metabar');
	
	function customize_metabar($metabar){
	
	$mymetabar = 'test'.$metabar; //$metabar is the original metabar
	
	return $mymetabar;
	
	}


Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
inov8ed

Hi Catrina, Yes, this works and puts the word "test" at the end of the metabar. However, when I try to replace the word with the function is where it doesn't seem to display in the right spot. Even matching the code exactly as above: ` add_filter('pagelines_post_metabar', 'customize_metabar'); function customize_metabar($metabar){ $mymetabar = userfunc_get_post_views(get_the_ID(), true).$metabar; //$metabar is the original metabar return $mymetabar; } ` But the insert comes not at the end of the metabar as expected with the word "test" that works from above but rather on a separate line in front of the metabar. It is like it isn't included in the metabar div. That is what confused me. -Adam

Share this post


Link to post
Share on other sites
catrina

Hm, what are you trying to accomplish with this function? What are you putting inside the function (i.e. an image, a sentence)?


Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
inov8ed

It is basically the post views from the wordpress.com stats. It seem to work fine, just the location issue. Here is the function I am putting in: ` function userfunc_get_post_views($postID, $display_to_all = false) { if ( $display_to_all || is_user_logged_in() ) { global $post_stats; foreach ( $post_stats as $p ) { if ( $p['post_id'] == $postID ) { ?> (<?php echo number_format_i18n( $p['views']) . ' views'; ?>) <?php } } } } ` -Adam

Share this post


Link to post
Share on other sites
catrina

Have you tried adding it somewhere else to see if it works? (To see if the issue is the placement)


Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
inov8ed

How would I go about doing that given the filter is what is putting in the code? Should I try putting it in another filter somewhere else? It seems like it must have something to with the way the customized metabar is created. Does that filter actually create a second metabar or add to the existing one? It seems like it should be just adding, but when I swap the text for a function it pops it out of the metabar... -Adam

Share this post


Link to post
Share on other sites
catrina

It's supposed to add to the existing metabar, but since it's not a hook like "pagelines_metabar_end" (like some other filters), it's just not behaving the right way. I've searched for other filters you can use for the metabar, and the pagelines_post_metabar, but it's the only one that exists. Have you considered using a different hook that places your code in a position near the metabar?


Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
timlinson

What exactly does userfunc_get_post_views return? Can you post the function?

Share this post


Link to post
Share on other sites
inov8ed

Hi Tim, It is posted above. It basically gathers the wordpress.com stats for a post and posts it for all to see. I sort of got around the issue by using CSS to float:right the whole thing. This basically stuck it on the same line to the far right. Not exactly what I was planning but it may do the trick. -Adam

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  

×