Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Agus,

    Thanks for your posts! I was just looking into the menu stuff as well and wanted a way to create a menu dynamically without having to use the WP Admin interface.

    In reference to how to assign your new menu to a specific location.

    I *think* you need to register your new menu using:
    register_nav_menu() <– single menu
    register_nav_menus() <– multiple menus

    You assign a location for a menu via register_nav_menus(), documentation here: http://codex.wordpress.org/Function_Reference/register_nav_menus

    In the documentation for wp_nav_menu() it specifies that you display a menu from a specified theme_location; documentation here: http://codex.wordpress.org/Function_Reference/wp_nav_menu

    Hopefully I understood your goal correctly?

    Hmmm… this may have nothing to do with your question but I found this information interesting. Maybe one of you can respond with some information on the mystery second parameter for get_bloginfo()???

    Here’s some code you can copy and paste into a template .php file like… index.php or header.php (it doesn’t matter as it’s only temporary, right!).

    The summary is that get_bloginfo() returns a String you can use inside php or output to the screen using ‘echo’, while bloginfo() simply outputs it to the screen (‘echo’ is built in).

    <div>
    	<h1>Difference between get_bloginfo() and bloginfo()</h1>
    	<h2>get_bloginfo()</h2>
    	<div>
    		<pre style="text-align: left;">
    			<?php get_bloginfo(); ?> <!-- Simply output the default get_bloginfo() parameter, blog 'name'. -->
    		</pre>
    	</div>
    	<h2>bloginfo()</h2>
    	<div>
    		<pre style="text-align: left;">
    			<?php bloginfo(); ?> <!-- Simply output the default bloginfo() parameter, 'name'. -->
    		</pre>
    	</div>
    	<h2>Try returning get_bloginfo() to a php value and then printing to the screen using echo.</h2>
    	<div>
    		<pre>
    			<?php
    				$name = get_bloginfo();
    				echo $name;
    			?>
    		</pre>
    		<pre style="text-align: left;">
    			<?php
    				$name = bloginfo();
    				echo $name;
    			?>
    		</pre>
    	<h2>Try returning bloginfo() to a php value and then printing to the screen using echo.</h2>
    	<div>
    		<pre>
    			<?php
    				$name = bloginfo();
    				echo $name;
    			?>
    		</pre>
    		<pre style="text-align: left;">
    			<?php
    				$name = bloginfo();
    				echo $name;
    			?>
    		</pre>
    		<pre>
    			Notice the difference? get_bloginfo() does not default to spitting out the results
    			to the visible page, whereas bloginfo() does.
    
    			The implications are that if you want to get blog info and then do something with
    			that data using php, you should use get_bloginfo() and if you just want to dump
    			the returned info to the screen without doing anything to it you can just use
    			bloginfo().
    
    			The confusing part for me is that in WPMU get_bloginfo() has a second parameter;
    			a String filter that can be passed. Based upon what I've seen from the new default
    			WP 3.0 theme, 'twentyten', the second paramter seems to govern what kind of data
    			is returned, 'raw' or 'display'.  However, testing it reveals nothing.
    
    			For example, let's try some tests, first with the second parameter set to 'raw'.
    			----------------------------------------------------------------------------------------
    
    			Round 1,
    
    				<?php get_bloginfo( 'name', 'raw' ); ?&gt
    
    			Results in:
    				<strong><?php get_bloginfo( 'name', 'raw' ); ?></strong>
    
    			Round 2,
    
    				<?php echo get_bloginfo( 'name', 'raw' ); ?&gt
    
    			Results in:
    				<strong><?php echo get_bloginfo( 'name', 'raw' ); ?></strong>
    
    			<br /><br />
    
    			Now let's try it with the second parameter set to 'display'.
    			- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    
    			Round 3,
    
    				<?php get_bloginfo( 'name', 'display' ); ?&gt
    
    			Results in:
    				<strong><?php get_bloginfo( 'name', 'display' ); ?></strong>
    
    			Round 4,
    
    				<?php echo get_bloginfo( 'name', 'display' ); ?&gt
    
    			Results in:
    				<strong><?php echo get_bloginfo( 'name', 'display' ); ?></strong>
    
    			----------------------------------------------------------------------------------------
    
    			<br /><br />
    
    			Now let's try all of the same again, but with bloginfo().
    			----------------------------------------------------------------------------------------
    
    			Round 1,
    
    				<?php bloginfo( 'name', 'raw' ); ?&gt
    
    			Results in:
    				<strong><?php bloginfo( 'name', 'raw' ); ?></strong>
    
    			Round 2,
    
    				<?php echo bloginfo( 'name', 'raw' ); ?&gt
    
    			Results in:
    				<strong><?php echo bloginfo( 'name', 'raw' ); ?></strong>
    
    			Now let's try it with the second parameter set to 'display'.
    			- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    
    			Round 3,
    
    				<?php bloginfo( 'name', 'display' ); ?&gt
    
    			Results in:
    				<strong><?php bloginfo( 'name', 'display' ); ?></strong>
    
    			Round 4,
    
    				<?php echo bloginfo( 'name', 'display' ); ?&gt
    
    			Results in:
    				<strong><?php echo bloginfo( 'name', 'display' ); ?></strong>
    
    			----------------------------------------------------------------------------------------
    
    			It would appear that the second parameter has no effect on output and is ignored?
    
    			The WPMU reference is located here:
    			<a href="http://codex.wordpress.org/WPMU_Functions/get_bloginfo">http://codex.wordpress.org/WPMU_Functions/get_bloginfo</a>
    
    			versus the general WP function codex located here:
    			<a href="http://codex.wordpress.org/Function_Reference/get_bloginfo">http://codex.wordpress.org/Function_Reference/get_bloginfo</a>
    
    			Go figure...
    		</pre>
    	</div>
    </div>
Viewing 2 replies - 1 through 2 (of 2 total)