Articles of functions

Show different website layout if no sidebar added

I have a question about website layout with and without wp widges in sidebar. Here is the code i have for my registered sidebar. <?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(products) ) : endif; ?> And this is the code i have in functions.php if (function_exists(‘register_sidebar’)) { $opts = array( ‘name’ => ‘Products’, ‘before_widget’ => ‘<div […]

How to display 2 function calls in same line?

<?php the_author_posts_link(); ?> <?php the_time(‘g:i a’); ?> When I call above 2 functions you will see the output in two lines. But what Need is “Andrew 2.10” I need both output in same line. How to do it.

WordPress performance – send all metaboxes to function or to call it again

I need to send my metabox information to a function – the meta is already called on page template $meta = get_post_meta(get_the_ID()) but I need to use this data in function the metaboxes are around 20 and containing different information (strings, arrays, multidimensional arrays, etc) For best WordPress performance which is better option – to […]

How do I pull avatar from post using BuddyPress?

I’d like to pull the avatar of a blog post’s author and display it on the page using BuddyPress but I cannot seem to pull it off. How would I go about this?

How do I place a function in a standalone page?

Im trying to a a function to create an rss feed from a gmail dress. This works if i place it in functions.php, but overtakes my site as an rssfeed, as expected. How do I place it in a standalone page, something like /gmailrss? The snippet if needed: function checkGmail($username, $password) { $url = “”; […]

Ajax resetting my global variable

I am wondering why I can’t read the updated value of $_TEST. It seems that $_TEST is being reset with each Ajax call. // functions.php $_TEST = 0; // the variable I want to update with each Ajax call if ( is_admin() ) { add_action( ‘wp_ajax_get_global_val’, ‘get_global_val’); add_action( ‘wp_ajax_nopriv_get_global_val’, ‘get_global_val’); } function get_global_val() // my […]

Function that prevents users from uploading photos more photos

Mjello, I’m struggling with this function that prevents users from uploading more photos than what their membership are entitled to. So they have 10 photos to upload. When they’ve reached 0 they should no longer be able to upload a photo. As it is now, the image that they’re uploading when they’ve have reached 0 […]

Is it legal to redefine wp_password_change_notification in a mu plugin?

I am trying to add some logic to this function of when to alert the admin to a password change but no email is being sent at all. The codex says it needs to be declared in a plugin, so is this legal from a mu plugin or is there only specific locations this can […]

Modify shortcode to work with custom post types

I have this shortcode which works fine with posts but I need to modify it to take arguments for custom post type and custom taxonomy. <?php // [blog_posts] function shortcode_latest_from_blog($atts, $content = null) { $sliderrandomid = rand(); extract(shortcode_atts(array( “posts” => ‘8’, “columns” => ‘4’, “category” => ”, “style” => ‘text-normal’, “image_height” => ‘auto’, “show_date” => […]

Class property seems to lose scope, attached to save_post action?

This may be more suited for StackExchange, so if you think that would be the right place to direct my question – please let me know :). So, I have a class with a property of save_list. This is an 2D array with it’s values being in the format array(‘meta_key’ => $meta_key). This class is […]