Articles of functions

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 = “https://mail.google.com/mail/feed/atom”; […]

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 […]

Add a mature content warning to first-time visitors

I would like to ask visitors if they are 18+ at the first visit to my blog. If they click yes, they access the blog normally and next time they will not be asked. If they click no, they access an info page, and they shouldn’t have the opportunity to retract. I want to record […]

Shortcode to get featured image of specific id post

So I’m trying to create a shortcode to get specific id and its featured image to display it in a specific page. I want to use shortcode to make it easier for the user to add any post in this page. I’ve tried a simple code which works but only display title, I’m not sure […]

Only load certain artists on this page

I have a wordpress page which loads all the artists in two columns… here is what I believe to be the relevant bit of code <?php global $paged; if ( is_front_page() ) { $paged = (get_query_var(‘page’)) ? get_query_var(‘page’) : 1; } else { $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; } query_posts(array( ‘post_type’ => ‘artists’, […]