Does WordPress run a post query when a page is invoked?

Yes, it does. Pages are just a type of post. If you visit, say, https://test.test/sample-page/, then this happens: WordPress checks the URL against its stored rewrite rules. On a normal site, https://test.test/sample-page/ will match (.?.+?)(?:/([0-9]+))?/?$, which the rule maps to index.php?pagename=$matches[1]&page=$matches[2]. WordPress performs a query using WP_Query, with the pagename argument set to pagename. Our … Read more

Shortcode with ‘year’ parameter

With help from @bosco , I was able to figure it out. Below is the working code: //get archived posts per year add_shortcode( ‘archived-posts’, ‘archived_posts’ ); function archived_posts($atts) { $a = shortcode_atts( array( ‘year’ => date(‘Y’) ), $atts ); $q = new WP_Query(array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1 , ‘post_status’ => ‘archive’ , ‘year’ … Read more

Get posts that do not have the same tags as current

I found an answer to my own question: If I use the tax_query arg then I could specify ‘operator’ => ‘NOT IN’ like so: $events = tribe_get_events([ ‘tax_query’ => array( array( ‘taxonomy’ => ‘post_tag’, ‘field’ => ‘name’, ‘terms’ => $current_tag, ‘operator’ => ‘NOT IN’ // HERE ) ), ‘start_date’ => ‘now’, ‘eventDisplay’ => ‘list’, ‘posts_per_page’ … Read more

complex get_posts() query to select child pages

You need a loop for this to handle the condition: /** list for course and childless department pages */ $course_and_childless_department_pages = array(); /** get department pages */ $department_pages = get_children( array( ‘post_parent’ => $post->ID, ‘post_type’ => ‘page’, ‘post_status’ => ‘publish’, ) ); foreach ( $department_pages as $department_page ) { /** get course pages (for department … Read more

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