Articles of functions

“Can’t use function return value in write context” error

I’ve updated my plugin, Disable Blogging, to the latest version which is available in the WordPress repository. Everything works as it should. However, one of my users has encountered an error when updating my plugin. Fatal error: Can’t use function return value in write context in …/wp-content/plugins/disable-blogging/includes/functions-extra.php on line 74 They run this plugin on […]

How to change featured content to a different tag in WordPress Twenty Fourteen?

In twenty fourteen theme, we’d like to know how to change the features content tag. Currently it’s set as featured. Now, we would like to know how to code this for different page templates. We notice in page.php there is a piece of code calling the template part featured-content. <?php if ( is_front_page() && twentyfourteen_has_featured_posts() […]

How to include all files within a folder to functions.php?

My functions.php includes other function files located within a ‘functions’ directory. Currently they’re individually added, in the format of this example: include(‘functions/login.php’); How can I modify this to include all files within the ‘functions’ directory, without listing them individually?

Nested shortCode functions in the functions.php file

I’m trying to get a shortcode function (newStuff) to display inside of another function (oldStuff), but I’m running into trouble. Both shortCode functions are listed below, as well as what I’ve tried. Can someone please help me get the “newStuff” function displaying inside of the “oldStuff” function? Thanks! Current Functions function newStuff(){ return ‘ only […]

Is there a theme function for is_password_protected()?

I’m looking at the function and template references and I’m not seeing a way to test for whether a post is protected. Is there a theme function for (something like) is_password_protected()? I’m already using add_filter( ‘the_password_form’, ‘custom_password_form’ ); to override the default form that shows up, but I want to customize some other aspects of […]

List repeating share links

I want to add social share buttons to my posts, but I don’t want to put all that big bulk of code into all my content files. I want to create a function, and then add the function name to my template files, something like this: function pietergoosen_sosiale_netwerk_deel_knoppies() { <strong>Deel die pos met ander</strong><p </p> […]

Call to undefined function get_blog_option()

In the functions.php of my plugin I’ve added the following code: function relativePathForUploads( $fileinfo ) { global $blog_id; $path = get_blog_option($blog_id,’siteurl’); $fileinfo[‘url’] = str_replace($path,”,$fileinfo[‘url’]); return $fileinfo; } add_filter(‘wp_handle_upload’, ‘relativePathForUploads’); But in the error log I get the following message: PHP Fatal error: Call to undefined function get_blog_option() Do I need to include something before I’m […]

Order get_users() by last login date. Is it possible?

I want to create a page that displays all the blog users ordered by the last login date. I’ve tried with the get_users() function and I can succesfully get the users’ list, but not in the order I want: $query = get_users(‘&offset=’.$offset.’&orderby=login&order=DESC&number=’.$number); I think that the orderby=login is not what I’m looking for… Is there […]

Disable single post page

Is there a way to disable single post page, for example when some tries to go to single post page to show 404 page.

Add action hook conditionally – only when home.php in use

I am trying to add action hook in functions.php only if the page is home.php but the following does not work if ( is_page_template(“home.php”) ) { // do stuff } To make sure that file being used is home.php I do this global $template; echo $template;