Prevent Archive URLs

WordPress generates date archives automatically, it’s just a thing it does. You see the index.php template probably because there isn’t a more specific one for date archives in your current theme. There are plugins that disable these archives, Yoast SEO is one. A quick fix is to empty the date archive rewrite rules: add_filter( ‘date_rewrite_rules’, … Read more

How to tell if a page has subpages for Custom Post Types

This code will return an array with IDs of all pages having sub pages. Hope you were looking for it 🙂 $args = array( ‘post_type’ => ‘page’, ‘post_status’ => ‘publish’ ); $parentPages = array(); // an empty array to store pages with childs $pages = get_pages($args); // Looping through all pages and then we’ll check … Read more

How to create archive pages for metadata query generated posts (so without taxonomy)?

A fairly simple way to do this is to create a new page with the slug likedby, then add some rewrite rules to handle the extra parameters. First, the query var that holds the requested username: function wpd_likedby_query_var( $query_vars ) { $query_vars[] = ‘likeduser’; return $query_vars; } add_filter( ‘query_vars’, ‘wpd_likedby_query_var’ ); Then a couple of … Read more

Order archive custom posts by taxonomy term [duplicate]

First things first… Why it doesn’t work? Your code doesn’t work, because you use WP API incorrectly… Method set takes exactly two arguments: set( $query_var, $value ) Set a named query variable to a specific value. So how do you use it in your code? $query->set( get_terms( array( ‘taxonomy’ => ‘cat_publications’, ‘orderby’, ‘slug’ ) ) … Read more

Display archives based in post_format

No, you cannot define your own post formats. This is on purpose. The post formats are supposed to be standards, so theme developers can include styles for them. That wouldn’t work if people start making their own formats. Essentially post formats are just a custom taxonomy added to posts. So testing for post format archive … Read more

Changing author links on homepage to buddypress profiles – without affecting ability to link to author archive throughout the site

Rather than add your filter immediately when the functions.php file loads, find actions that you can hook onto later, when you know the context of the current request, so you can add and remove filters in a targeted way. For example, you might be able to use loop_start to only affect WPBakery output in the … Read more

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