Does WordPress generate an automatic page for post formats?

Take a look at get_post_format_link() Here’s a little example that uses get_post_format_link() to show a link to the format’s archive page. You can see something similar to this in action on Justin Tadlock’s site. function get_post_format_archive_link() { return sprintf( ‘<a class=”post-format-archive-link %1$s” href=”https://wordpress.stackexchange.com/questions/39925/%2$s”>%1$s</a>’, get_post_format(), get_post_format_link( get_post_format() ) ); } usage: echo get_post_format_archive_link(); The URL Structure … Read more

How to get first post in a category of a custom taxonomy

tax_query takes an array of tax query arguments arrays (it takes an array of arrays) but you are using only single array. The correct code is as following. <ul class=”product-categories”> <?php $categories = get_terms( array( ‘produkter’ ), array( ‘hide_empty’ => false, ) ); foreach( $categories AS $cat ) { $taxonomy = new WP_Query( array( ‘posts_per_page’ … Read more

Using WP_Query To Get Posts Randomly From today

I don’t think there is a parameter value Today as you used in date_query. If you want to return today’s post then you should provide date value to date_query as you stored current date in $today array. So here is your query now. $today = getdate(); $args = array( ‘tag_slug__in’ => array( ‘destacado’), ‘posts_per_page’ => … Read more

ajax category filter

Not sure if you’ve solved this or not but I was looking for a way to embed this within a page and filter posts by category. I got this working so it displays all categories and the posts related. Put that in functions.php function ajax_filter_posts_scripts() { // Enqueue script wp_register_script(‘afp_script’, get_template_directory_uri() . ‘/js/ajax-filter-posts.js’, false, null, … Read more

Executing Queries in tag.php

That’s because the main query is being discarded and replaced with your custom query. You’ve not told your custom query to look for that tag, so why would it? You might also notice your pagination is broken for the same reason, you’ve not told the new query which page you’re on, so why would it … Read more

How to get random posts and order them by date

Unfortunately, that will never work. ‘rand’ is a random order, so you always end up with a randomized order, no matter what you put for the date. In order to do something like what you’re describing, you have to use ‘orderby’=>’rand’. Then you can sort the result by date. $query = new WP_Query( [ ‘post__in’ … Read more

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