Articles of functions

Add before_content and after_content to register_sidebar

Is there any way to add two new functions, before_content and after_content to the register_sidebar function? These would work like before_title and after_title, except it would wrap everything that comes after the title. I’ve found this thread which has some useful information, but every mentioned approach has flaws. For example, inserting the required code in […]

Hide a menu-item and its submenus and display a 'Log in' link if the user is logged out

I need, somehow, to enable that when you logout, that ‘My Account’ item is getting hidden from the navbar, and instead it displays a ‘Log in’ link. The item ‘My Account’ also have submenus with the items ‘Log out’ and ‘Track your order’. This should be hidden as well (I guess it gets hidden when […]

Global functions on WPMU

I work in a multisite environment where all of the sites are related. A lot of recent developments have required me to copy and paste certain functions into many different theme folders, which causes problems if I need to update them everywhere. What would be the best way to have a global “functions.php” file? My […]

Displaying a random user with a shortcode

I’m trying to setup a shortcode to show a single random user each time the page is refreshed. I’ve been successful in displaying all users or a select user by the user ID. Here is my shortcode as it is now: //* Shortcode for getting users function list_of_users( $atts ) { extract( shortcode_atts( array( ‘display’ […]

Where to place custom functions?

Straight to the question: It seems that there are only so many places to place custom code: functions.php, plugin, template, shortcode. Having too many plugins slows down your load times, inflating the functions.php file can get unmanageable, same with a template, and shortcodes really depend on the situation. I have a homepage with a lot […]

Editing or filtering the output of the Genesis navigation

I’m trying to edit or apply a filter to the default Genesis navigation genesis_do_nav Currently I’m extending a Walker class to add a <span> with data-attribute around the navigation’s link text. class Menu_With_Data_Attr extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args) { global $wp_query; $indent = ( $depth ) ? str_repeat( “\t”, $depth ) : […]

How do I edit wp_head and/or functions.php to remove rss-feed which isnt used and dont validate?

When using w3.org’s validation tool Unicorn I get the following error/warning: URI: http://energyshop.se/hem/feed/ This feed does not validate. After looking into my source its there crystal clear in the <head>: <link rel=”alternate” type=”application/rss+xml” title=”energyshop.se &raquo; Hem kommentarsfl√∂de” href=”http://energyshop.se/hem/feed/” /> Now, how do I remove this feed since I dont use it? Thanks in advance!

When to use an if statement after get_posts?

Whilst looking through the codex for the get_posts function, I noticed that in the majority of the examples they do not show an if statement after call to get_posts Example: <?php $args = array( ‘posts_per_page’ => 10, ‘order’=> ‘ASC’, ‘orderby’ => ‘title’ ); $postslist = get_posts( $args ); foreach ( $postslist as $post ) : […]

Debugging Technique Question re: functions.php

I needed to develop a technique to delete some data from the database. The technique will be part of a plugin at some point. For immediate results, I was editing functions.php on my local dev site, placing the necessary commands at the bottom of the file and reloading the page upon saving. Is this considered […]

How would go about if I just want a temporary function?

How would go about if I just want a temporary function? (It’s a converter just for converting Access to WordPress tables). I want to execute several times so therefore I want it automated, but I don’t know how to execute the function after adding the filter in add_action(). After I’m done converting, I will delete […]