Replace the custom post type permalink
Wow, I just realized: the argument ‘rewrites’ was wrong. It’s rewrite. Thank you guys anyway.
Wow, I just realized: the argument ‘rewrites’ was wrong. It’s rewrite. Thank you guys anyway.
Use usort with a custom callback, like this: function compare_term_order_numbers( \WP_Term $a, \WP_Term $b ) : int { $order_number_a = get_field( ‘order_number’, $a ); $order_number_b = get_field( ‘order_number’, $b ); return strcmp( $order_number_a, $order_number_b ); } usort($terms, ‘compare_terms’ ); Note that this assumes get_field returns a plain string, not an object, that each term has … Read more
Query string parameters are a helpful friend in this situation. It will allow you to keep the same single-$posttype.php file for both formats of the page. So if someone visits your page using the URL: https://yourwebsite.com/events They will see your normal webpage for visitors. But if someone uses the URL: https://yourwebsite.com/events?seminar=true They will see something … Read more
Rewrite is a global base for all posts under the custom post type. For example, this is the default CPT rewrite structure: example.com/lesson/%postname% In your code example, it’s implying you are trying to do: example.com/%postname%-lesson/%postname% Two issues with this idea. The first issue, assuming this functionality worked, is that your CPT urls would all be … Read more
Issue-1: edit_post_link() is a template function, to be used in theme template files. It’s not used in the Admin pages. So you’ll not get the edit_post_link filter hook for the Admin list pages. Issue-2: get_edit_post_link() function however, is used in Admin list pages. So you’ll get the get_edit_post_link filter hook for the Admin list pages. … Read more
I think a better approach for this would be to create a single nested (hierarchical) custom post type. For example, it can be series. Then a single series named sample-series as a top level post of series post type: site.com/series/sample-series/. Then seasons named season-one, season-two etc. can be children of sample-series, like: site.com/series/sample-series/season-one, site.com/series/sample-series/season-two. Similarly, … Read more
Custom Taxonomy rewrite rule working for everything other than singles
My was a mistake, I realize later that– that is the custom post types default behavior, the reason it is not working for me because something is added to my Settings -> Permalinks that adds another prefix so the permalink of my posts is /articles/%postname%/ so the output is /movies/sample-post I just removed the /articles/ … Read more
How to use wp_set_object_terms depending on page ID?
Show a wordpress custom post condtionally using a category term