When to use WP_query(), query_posts() and pre_get_posts

You are right to say: Never use query_posts anymore pre_get_posts pre_get_posts is a filter, for altering any query. It is most often used to alter only the ‘main query’: add_action(‘pre_get_posts’,’wpse50761_alter_query’); function wpse50761_alter_query($query){ if( $query->is_main_query() ){ //Do something to main query } } (I would also check that is_admin() returns false – though this may be … Read more

Link on post title only if post have content

Based on this question Probably the easiest way would be: <?php // The Loop while (have_posts()) : the_post(); ?> <?php if (” !== get_post()->post_content): ?> <h2><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></a></h2> <?php else: ?> <h2><?php the_title(); ?></h2> <?php endif; ?> <div><p> <?php if (get_field(‘telefono’)): ?>Telefono: <?php the_field(‘telefono’); ?> … Read more

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