List of the years with posts presented

Relationship between post and category is not stored in the posts table. You must extend your query for additional tables. By category id: SELECT YEAR(p.post_date) FROM {$wpdb->posts} p JOIN {$wpdb->term_relationships} tr ON tr.object_id = p.id JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id = tr.term_taxonomy_id WHERE tt.term_id = 4 AND p.post_status=”publish” AND p.post_type=”post” GROUP BY YEAR(p.post_date) DESC Or … Read more

CPT Archive with core Category

You want display posts of a given type ({post_type}) from category ({term}) and structure of link should looks like this: {post_type} / category / {term} To avoid collisions with links to pages and “blog” posts, expression can not start with ([^/]+), but should contain slug of post type entered explicitly. This means a separate rule … Read more

When i try to open archive pages i get a 404 error

Probably you have to go to Permalinks > click “Save Permalinks” and refresh that archive page to see if it solved. If not, then maybe you are using some plugin that caused the problem? deactivate all plugins and re-save permalinks and check that archive page again.

How to query for pages/post depending on slug?

With a custom Page (post type page) and a custom Page Template, you can do it like so: In the templates, make a new instance of WP_Query which is used for querying the posts in either the Romanian or English language. In the query/function args for WP_Query and wp_get_archives(), use a custom parameter named lang … Read more

Creating a custom archive template that sorts post by date

I’ve taken the answer from here, where they are changing the order in a different way, but it should work for you. It uses the pre_get_posts hook to change the ordering for the archive page only. add_action( ‘pre_get_posts’, ‘my_change_sort_order’); function my_change_sort_order($query){ if(is_archive()): //If you wanted it for the archive of a custom post type use: … Read more

Getting category posts from a certain year

Is there a trick to get for wwx.example.com/year/category/ The main query is open to public query variables like year and cat so without pretty permalinks you could try www.example.com/?year=2022&cat=5 where 5 is the category id as an example and with pretty permalinks it would be redirected to www.example.com/2022/?cat=5

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