How can i catch (with get_posts) attachment file (pdf, images) from a post when i have only inserted it from media library and it isn’t upload for it?

When you upload a media from a post, the post_parent attribute is setted to the post ID you are uploading from. Not so when you simple insert a post from the library: in that case if the media was already attached to a post, its post_parent is already setted, and once a media can have … Read more

How to properly use Categories with Custom Post Types

Your get_posts call needs a posts_per_page argument if you want more than whatever the default number per page is. Use -1 to retrieve all matching posts. $featured_posts = get_posts( array( ‘post_type’ => array( ‘post’, ‘books’, ‘cds’, ‘maps’ ), ‘category’ => get_theme_option(‘featured_posts_category’), ‘posts_per_page’ => -1 ) );

Show all videos by tag name

Try this. Use for tag_id in get_posts. $tax_terms = get_terms(‘media_category’, ‘orderby=count&order=DESC&hide_empty=0’); foreach ( $tax_terms as $tax_term ) { $posts = get_posts(array( “meta_key” => ‘select’, “meta_value” => 1, “tag_id” => 5, “post_mime_type” => “video”, “taxonomy” => $tax_term->taxonomy, “term” => $tax_term->slug, “numberposts” => 100, “posts_per_page” => 100));

Can’t get Category link inside get_posts

If you can add your code, It may help for everyone. By reading you question. By default normally that get_category_link is have to work. Just use global $post before your loop. If is not work. What you have to do is. Grab the category id using your @category variable. (you can use print_r($category); or var_dump($category); … Read more

Custom loop in addition to default on archive page

I’m with s_ha_dum that this isn’t very clear on what’s happening, but have you tried wp_reset_postdata()? I believe you would put it before the last while loop in your example above. Here’s an article on other methods of resetting the query if that’s not working: http://digwp.com/2011/09/3-ways-to-reset-the-wordpress-loop/

Exclude parent category when getting category posts by slug

I wonder if a single typo is messing things up for you? Please try this: $args = array( ‘posts_per_page’ => ‘-1’, ‘orderby’ => ‘ID’, ‘order’ => ‘DESC’, ‘category_name’ => ‘documents’ ); $surveys = get_posts($args); where I replaced category-name with category_name. I know there is ways to exclude categories by ID but I need to use … Read more

get_posts() forcing ignore sticky posts on main loop

From the function reference for get_posts(): For full parameters list see WP_Query. From the WP_Query reference: ignore_sticky_posts (boolean) – ignore sticky posts or not (available with Version 3.1, replaced caller_get_posts parameter). Default value is 0 – don’t ignore sticky posts. Note: ignore/exclude sticky posts being included at the beginning of posts returned, but the sticky … Read more

Why the_excerpt() function returns excerpt on the Home page and trimmed content in sidebar?

Your problem has nothing to do with the_excerpt(). the_excerpt() template tag does not change its behavior by itself or change its behavior according to location. The only time the_excerpt() changes its behavior is when you manually filter the output through a custom function. I most probably think that all of your misery is caused by … Read more

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