Retreive tags from attached post for media on page

‘attachment’, ‘posts_per_page’ => -1, ‘post_status’ => ‘any’, ‘post_parent’ => null, ‘tax_query’ => array( array( ‘taxonomy’ => ‘post_tag’, ‘field’ => ‘slug’, ‘terms’ => ‘logo’ ) ) ); $images = get_posts( $args ); if ( $images ) { foreach ( $images as $image ) { // Get the parent post ID $parent_id = $image->post_parent; // Get the … Read more

pagenavi shows a lot of pages calculated from all posts in the site with query_posts

I didn’t load the plugin to check and I never use query_posts(), but perhaps tie_pagenavi() is depending on the value in the $paged global variable. Try adjusting that value before (or after) calling query_posts(). Here is the code to adjust it before calling query_posts(). if ( get_query_var( ‘paged’ ) ) // On a paged page. … Read more

Retrieve posts in custom post type and specific taxonomies

Both get_posts() and wp_query() should be able to do this by passing the tax_query array into them. Example: $query = array( ‘post_type’ => ‘portfolio’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘clients’, ‘field’ => ‘slug’, ‘terms’ => array( ‘acme’ ) ) ), ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’ ); $posts … Read more

get_posts and wp_autop (remove filter)

You could make your own excerpt function: function wpse125086_custom_strip_tags_excerpt() { global $post; $p_obj = get_post($post->ID); $p_exp = $p_obj->post_excerpt; $p_exp = apply_filters(‘the_excerpt’, $p_exp); $un_p = array(“<p>”, “</p>”); $p_exp = str_replace($un_p, “”, $p_exp); echo $pcont; } But generally I’m thinking instead of transforming to get_posts() it might be better to go with WP_Query. In this case the … Read more

Show recent posts in single-post page

The function get_posts() accepts a parameter ‘post__not_in’, which allows you to specify an array of post IDs to exclude from the query. get_posts() is just a wrapper for WP_Query, so the documentation for this parameter can be found here. When inside the loop (such as inside single-events.php) you can retrieve the current post’s ID with … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)