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().

Automatic post deletion

You can improve by storing the “expiry” time of post as a meta instead of the publish time. This way you can query for posts with meta which is smaller then the current time and draft them, no need to loop over all posts. Drawback is that you will have to decide how to handle … Read more

How to access featured image?

get_the_post_thumbnail ( $post/$post_id, $sizes, $attr ) will give you the featured image as html to output. get_post_thumbnail_id ( get_the_ID ( ) ) will give you the ID of the featured image so you can use it to get more information. Getting the thumbnail ID is essentially accessing the the post’s meta data: $image_id = get_post_meta( … Read more

Articles are text-only in any “Category” instead of HTML

The theme uses the_excerpt() instead of the_content(). I had created a child theme before (so I don’t modify the source theme directly: only the child one), so I only had to copy/paste the PHP file (archive.php) from source theme to child theme, and change the_excerpt() for the_content( __( ‘Read more &#8250;’, ‘my-domain’ ) );

UberMenu list current user’s posts as menu items

the_permalink(), the_title() by default echo their value. As you want to store that value in a variable you will need to return the values instead. get_the_permalink(), get_the_title() are two similar functions that return the value instead of echo. So you new code may look something like this: $list=”<li class=”ubermenu-submenu ubermenu-submenu-id-122-col-0 ubermenu-submenu-type-stack”>”; $list .= ‘<a class=”ubermenu-target … Read more

Custom WP_QUERY $args

You can use custom filters in $args (not tested) add_filter( ‘posts_where’, ‘find_by_title_filter’, 10, 2 ); function find_by_title_filter( $where, &$wp_query ) { global $wpdb; if ( $find_title_arg = $wp_query->get( ‘find_title’ ) ) { $where .= ‘ AND ‘ . $wpdb->posts . ‘.post_title LIKE \’%’ . esc_sql( $wpdb->esc_like( $find_title_arg ) ) . ”; } return $where; } … Read more

How to prevent WordPress from updating the modified time?

The question of how to customize which post data gets updated has been answered elsewhere on StackExchange. Here is a specific example of how to stop the modified date from being updated: function stop_modified_date_update( $new, $old ) { $new[‘post_modified’] = $old[‘post_modified’]; $new[‘post_modified_gmt’] = $old[‘post_modified_gmt’]; return $new; } add_filter( ‘wp_insert_post_data’, ‘stop_modified_date_update’, 10, 2 ); // do … Read more

Creating a Page of Posts

Try this code in your page-blog.php to display list of posts $paged = get_query_var(‘paged’) ? get_query_var(‘paged’) : 1; $args = array( ‘post_type’ => ‘post’, //Change this with your post type ‘posts_per_page’ => 10, //No. of Pages to show ‘offset’ => 0, //excluding the latest post if any ‘paged’ => $paged //For Pagination ); $loop = … Read more