setup_postdata doesn`t seem ot be working

According to the Codex, you seem to skip the most important global $post; at the beginning, like this: global $post; $posts = get_posts($args); foreach($posts as $post) { setup_postdata($post); ?> <article class=”col two tablet-four mobile-six box”> <a href=”https://wordpress.stackexchange.com/questions/131909/<?php the_permalink(); ?>” title=”<?php the_title_attribute(); ?>”> <div class=”featured-image”> <?php if(has_post_thumbnail(get_the_ID())): ?> <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), array(650,200)); ?> <div style=”background: … Read more

Query random post from different categories

Random ordering is quite expensive operations in SQL and can become a headache on very big sites. Getting a random post from a category for 6 categories will mean you might need to run 6 separate queries, each ordered randomly. This can really break the bank and leave you bankrupt. From your answer and looking … Read more

WordPress ajax get content post id

There are many errors and bad practices in your code. I’ve fixed most of them. Explaining all those here is not possible. I’ve written the explanation as comment where they need to. Please read the whole code and comments attentively- custom.js // Wrap any jQuery code like this. It makes ‘$’ use fullproof // and … Read more

How do you Query posts with nothing in common?

Maybe you’re looking for the post__in parameter in WP_Query. $query = new WP_Query(array( ‘post__in’ => array(23,18,2,199,6,8) ); And then: while ( $query->have_posts() ) { $query->the_post(); /* post loop */ } Take a look at the docs. =D For public queries: post__in is not public queryable by default, so you can just validate and copy $_GET[‘post__in’] … Read more

how to get specific page content

Rather than call WP_Query() you can use get_post() and “set up” the global $post. This is probably a little more efficient than @tf’s answer, though the ideas are broadly the same. Please note, in both cases you should reset the post data afterwards. /** * Display the post content. Optionally allows post ID to be … Read more

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