Community Forums › Forums › Archived Forums › Design Tips and Tricks › Function Error in Prose
- This topic has 4 replies, 2 voices, and was last updated 12 years, 11 months ago by
angieatc.
-
AuthorPosts
-
August 16, 2013 at 9:52 am #56819
angieatc
MemberI am working on a site (beginning stages) and I am adding some code to the custom functions section under Genesis. I am actually taking this code from Backcountry so my description will appear on the menu bar:
/** Add description to secondary navigation */ add_filter( 'walker_nav_menu_start_el', 'add_description', 10, 4 ); function add_description( $item_output, $item, $depth, $args ) { $args = (array) $args; if ( $args['theme_location'] != 'primary' ) { return preg_replace( '/(<a.*?>[^<]*?)</', '$1' . "<span class=\"menu-description\">{$item->post_content}</span><", $item_output ); } else { return $item_output; } }This is the error I am getting:
Parse error: syntax error, unexpected T_STRING in /home3/angieatc/public_html/test1/wp-content/uploads/prose/custom.php on line 11I do not get this error if I load this in a normal function file from another theme.
http://test1.strosgirldesigns.com/My design site, Hill Springs Designs
August 16, 2013 at 10:40 am #56831Brad Dalton
ParticipantMight need to put it into a plugin.http://www.studiopress.community/topic/add-new-widgetized-area-in-prose/page/2/#post-55822
August 17, 2013 at 3:55 pm #57087angieatc
MemberSo would the code look like this in the file and save it as extracode.php (or whatever I want to add? Would I add post signature and other codes in there as well?
/* Plugin Name: Prose Custom Code Plugin URI: http://example.com Description: Loads customizations for my site Version: 0.1.0 Author: Angie Lambert Author URI: http://strosgirldesigns.com License: GPLv2 or later */ /** Add description to secondary navigation */ add_filter( 'walker_nav_menu_start_el', 'add_description', 10, 4 ); function add_description( $item_output, $item, $depth, $args ) { $args = (array) $args; if ( $args['theme_location'] != 'primary' ) { return preg_replace( '/(<a.*?>[^<]*?)</', '$1' . "<span class=\"menu-description\">{$item->post_content}</span><", $item_output ); } else { return $item_output; } }
My design site, Hill Springs Designs
August 17, 2013 at 4:03 pm #57088Brad Dalton
ParticipantAugust 17, 2013 at 4:08 pm #57090angieatc
MemberI tried, I get an error:
/* Plugin Name: Prose Custom Code Plugin URI: http://example.com Description: Loads customizations for my site Version: 0.1.0 Author: Angie Lambert Author URI: http://strosgirldesigns.com License: GPLv2 or later */ /** Add description to secondary navigation */ add_filter( 'walker_nav_menu_start_el', 'add_description', 10, 4 ); function add_description( $item_output, $item, $depth, $args ) { $args = (array) $args; if ( $args['theme_location'] != 'primary' ) { return preg_replace( '/([^<]*?){$item->post_content}<", $item_output ); } else { return $item_output; } }
**edit, I did not remove the code from the functions so it gave me the line error but this is the error I get now.
My design site, Hill Springs Designs
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.