A little code for Wordpress

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lance_kidd
Forum Newbie
Posts: 5
Joined: Mon Aug 15, 2011 2:34 am

A little code for Wordpress

Post by lance_kidd »

Hi,

I know nothing of PHP and I can't get anyone on the Wordpress forums to help. Here is what I have:

This code causes a menu of links to display on one of my site pages:

Code: Select all

<?php wp_nav_menu(array('menu' => '144')); ?> 
All this does is show the links in an unordered list. Since these links that I show are current news items, I want to display the date that I created the link to show up before the a tag. Wordpress site says that text can be inserted before the link by using before => 'sample text' but the text is the same and I can't modify it. What would I need to do in order to get the current date (or date the link was created in the menu) to show up before the link.

I don't think that it would be too hard for someone who knows a little about WP, but if anyone has some extra time and can help, here is the page that describes what can be added to the code above: http://codex.wordpress.org/Function_Ref ... p_nav_menu
phphelpme
Forum Contributor
Posts: 261
Joined: Sun Nov 21, 2010 3:32 pm

Re: A little code for Wordpress

Post by phphelpme »

lance_kidd wrote:

Code: Select all

<?php wp_nav_menu(array('menu' => '144')); ?> 
I don't think that it would be too hard for someone who knows a little about WP, but if anyone has some extra time and can help, here is the page that describes what can be added to the code above: http://codex.wordpress.org/Function_Ref ... p_nav_menu
Hi, as far as I am aware you are trying to add another value to the array:

Code: Select all

'before'          => ,
So surely as a guess never having used this function with wordpress you would create something like this:

Code: Select all

<?php wp_nav_menu(array('before' =>'your text here' , 'menu' => '144')); ?>
My guess would be that this array option built into Wordpress will only display text for the parent link etc before the dropdown function or display the same text for each and every link in that particular menu you are selecting '144'. So my suggestion not really knowing about this built in Wordpress function is you will have to extract the creation dates from the database first, then display the menu using some type of foreach statement so each individual menu link is displayed with its own created date.

Again dont hold me to this as I have never used this function for Wordpress.

There is another option but it depends if your article links you are using will change etc. If you have created a menu manually with set links to display certain articles then check out the custom menu page for Wordpress and you can add the date yourself to the link tag and title tag. That way your links/text have the date you created them on.

http://en.support.wordpress.com/menus/

I hope this helps out in some way.

Best wishes
Post Reply