How to display archive page posts based on author_id

All you need is to use pre_get_posts action to hook to add author_id to the query based on your custom custom_user_id query var: add_action( ‘pre_get_posts’, ‘filter_by_custom_user_id’ ); function filter_by_custom_user_id( $query ) { // Apply only on frontend, for gallery post type archive, for main query and if custom_user_id query var is set. if( ! is_admin() … Read more

Unabled to Change Permalinks – Even Using the “Edit” (Resets to Original Permalink on “Update”)

Thank you TheDeadMedic, I should have tried this already, but here is the answer: I had the “Slug” Meta-box hidden, using the “remove_meta_box” function because it is annoying, especially for users that aren’t tech-savvy. Unfortunately, WordPress keeps the Permalink “Edit” as if you could edit it, but it is actually necessary for the “Slug” div … Read more

Ignore postname in permalink

Being in wp-admin/options-permalink.php (Permalinks) you can easily set this using Custom Structure: /%post_id%/%postname%/ So you can browse the Hello World post with: http://example.com/1/hello-world/ But if you strip out the postname from the URL like below: http://example.com/1/ You can still access the Hello World post. CAUTION Changing permalink in any live site may cause bad effect … Read more

Custom Post Type Archive template not being called

Everything you describe is expected behavior based on your post type registration settings. A page isn’t going to load an archive template, I’m not sure why you’d expect it to. Your rewrite argument slug is only for single posts. Setting has_archive to true uses the post type slug as archive location, which is ttwi_course. If … Read more

Add URL Rewrite Rule To WordPress

First you need to register your expected variables. Something similar to: function my_rewrite() { add_rewrite_tag(‘%ct_city%’, ‘([^&]+)’); add_rewrite_tag(‘%country%’, ‘([^&]+)’); } add_action(‘init’, ‘my_rewrite’, 10, 0); Then you need to create the rule which will redirect to your abm page. Note that you will need to discover your abm‘s ID, since you will need to pass it in … Read more