How to generate page content from database the right way?

WordPress is fetching current post for you, you have to only type to the right url. When you get e.g. to example.com/lorem-ipsum/ WordPress will load automatically post with title Lorem ipsum and display it using page.php template. Your page.php template should be looking something like that. <?php get_header(); ?> <div id=”content”> <?php while ( have_posts() … Read more

Renaming post IDs – Okay to do?

Is it possible to change the post IDs within the wp_posts table without causing problems? No it is not. If you change a posts ID, you then have to go through and fix other things: the post meta key/value pairs would no longer have the correct ID All terms in taxonomies such as categories and … Read more

WordPress SQL Injections through User Agent

how real is this security problem? You shouldn’t be concerned by this unless you’re retrieving user agents and making raw SQL queries. I recommend you avoid both of those, but for unrelated reasons. If you are piping raw user agents into raw SQL queries, and you would know if you were doing this as it’s … Read more

Total number of posts in last year

All you need to do is modify the SQL query. Using the code you linked as a base: $numposts = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->posts WHERE post_status=”publish” AND year(post_date) = 2010″); if (0 < $numposts) $numposts = number_format($numposts); The ‘AND’ I added basically gives you all the posts of 2010. Change the year accordingly

How to query the WordPress database to get posts of a certain custom post type, taxonomy and field?

I would use a custom query like this: $amsterdamstore_args = array( ‘post_type’ => ‘store’, // This is your custom post type ‘tax_query’ => array( array( ‘taxonomy’ => ‘city’, // This is your custom taxonomy ‘terms’ => ‘Amsterdam’, // The term you search for ‘field’ => ‘name’, // Check against the term’s name (you might use … Read more

What SQL / WordPress queries would need a nonce?

You might be a little confused as to the purpose and function of nonces in WordPress. Recommended reading: WordPress Nonces An Introduction to WordPress Nonces with Examples Protect_Queries_Against_SQL_Injection_Attacks A nonce is a “number used once” to help protect URLs and forms from certain types of misuse, malicious or otherwise. Nonces help you ensure, somewhat, the … Read more

How to display posts of specific category using a custom Query in WordPress?

the recommended way is: <?php $query = new WP_Query(‘category_name=Category&posts_per_page=4’); if($query->have_posts()) : while($query->have_posts()) : $query->the_post(); if (has_post_thumbnail()) { ?> <a href=”https://wordpress.stackexchange.com/questions/162985/<?php the_permalink(” ‘) ?>” title=”<?php the_title(); ?>”><?php the_post_thumbnail(); ?></a> <?php } ?> <h2><a href=”https://wordpress.stackexchange.com/questions/162985/<?php the_permalink(” ‘) ?>” title=”<?php the_title(); ?>”><?php the_title(); ?></a></h2> <?php the_excerpt(); // or the_content(); for full post content endwhile;endif; ?>

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