dlngle
Forum Replies Created
-
Forum: Hacks
In reply to: $post variables aren't outputting any data inside custom plugin.Make sure you don’t have get_post_info(); outside of php tags somewhere.
The code you are showing me will not print out the function name.Check you’re not printing or echoing it either.
Also that hook will be called whenever wp goes to loop through posts.
use:
add_action('wp','myfunction'); function myfunction(){ $post = get_post(); var_dump($post); }
The above code will only output the data once on the page.
Forum: Hacks
In reply to: $post variables aren't outputting any data inside custom plugin.Ok, I assumed this code was going to appear inside a class.
That’s ok just remove
array( &$this, 'get_post_info' )
and replace with
'
get_post_info’`Because you are not in a class you do not need to send the object across ( And there is no object ).
Final Code:
add_action( 'the_post', 'get_post_info' ); function get_post_info() { global $post; var_dump( $post ); }
Hope that works
Forum: Hacks
In reply to: $post variables aren't outputting any data inside custom plugin.Hi Grizzam,
Using the global variable is correct however it sounds like you are using it outside of the post loop.
global $post; var_dump( $post );
If it shows null you are outside of the loop.
This probably means your function is running on the init action.
Here is an example of some code that will work.add_action( 'the_post', array( &$this, 'your_function') ); function your_function(){ global $post; var_dump( $post ); }
Hope that helps.
Forum: Hacks
In reply to: displaying the number of active visitors on a single postHi Lemonthirst,
It sounds like Google Analytics could do the trick for you.
Once you install the tracking code on your site you can get live stats through the admin panel.
I’m not sure if there is a plugin for it but you can sign up at https://google.com/analytics
This won’t work if you wanted to view users usernames though.
Forum: Developing with WordPress
In reply to: Customized wp_nav_menu()I did a bit of fiddling the other day and came up with this…
I wanted just the sub menus to appear and show the parent page as a heading above it.
If you are on a subpage the link stays active.
I created a custom sidebar and made up my own css.
Hope this helps.<?php global $wp_query; if( empty($wp_query->post->post_parent) ) { $parent = $wp_query->post->ID; }else{ $parent = $wp_query->post->post_parent; } if( empty($parent)){ $parent = wp_list_pages(title_li); } ?> <?php if(wp_list_pages("title_li=&child_of=$parent&echo=0" )): ?> <h2 class='left'><?=get_the_title($post->post_parent);?></h2> <hr /> <nav id="side-nav"> <ul class="navList"> <?php wp_list_pages("title_li=&child_of=$parent" ); ?> </ul> </nav> <?php endif; ?>
The output looks like this..
<h2 class='my_custom_class'>page_parent</h2> <hr /> <nav id="my_custom_class"> <ul class="my_custom_class"> <li class="page_item"><a href="#">page_item</a> <ul class='children'> <li class="page_item child"><a href="#">children</a></li> </ul> </li> <li class="current_page_item"><a href="#">current_page</a></li> </ul> </nav>
Hope this helps,
Matt