Buddypress activity id

That function is called right in entry.php as follows: <li class=”<?php bp_activity_css_class(); ?>” id=”activity-<?php bp_activity_id(); ?>”> Note that bp_activity_id() will echo the value. To use the value in code, call bp_get_activity_id().

Getting current post ID in functions.php

I believe this should work in all cases – whether you are in the loop or not. (In a widget, chances are you are not in the loop) Mind you, outside the loop, this will work very well on single pages or posts, but might not display the post you want on other types of … Read more

Get widget Title from widget id

You can get the widget name from the widget id with this: <?php global $wp_registered_widgets; $id = ‘recent-comments-1’; // example if ( isset($wp_registered_widgets[$id][‘name’]) ) { echo $wp_registered_widgets[$id][‘name’]; } ?>

How to check the array of featured images IDs

This is solely a PHP question. But as birgire mentioned, you can use in_array(). So, change your code to this: $post_thumbnail_id = get_post_thumbnail_id(); if( in_array( $post_thumbnail_id, array(1, 2, 3 ) ) ) { echo ‘<span>Location</span>’; } The first argument is your value, the second one is the array you want to search in.

post_author for wp_insert_attachment

My question is, is there a way to add a post_author to the wp_insert_attachment? I could not find that in the documentation. I need the attachment to have the same author id as that of the post. Currently it takes the id of the the admin. Sometimes the codex or published docs don’t tell the … Read more

Make slug as ID Number for custom post types

Here’s a way how to change the slug: add_action(‘wp_insert_post’, ‘change_slug’); function change_slug( $post_id ) { // Making sure this runs only when a ‘eduation’ post type is created $slug = ‘eduation’; if ( $slug != $_POST[‘post_type’] ) { return; } wp_update_post( array( ‘ID’ => $post_id, ‘post_name’ => $post_id // slug )); }

Cannot get grandparent object

just a small error. To get the parent and Grandparent objects, you need to get_post them also. The property “post_parent” only gives you the ID of that post, not the post_object itself. So you change your code like this: <?php $current = get_post($post->ID); //Conditional to be sure there is a parent if($current->post_parent){ $grandparent = get_post($current->post_parent); … Read more