How to hyperlink content from archive page with custom post-type

use the_permalink or get_the_permalink to display/retrieve the URL of a post ( a post of any type, they’re all the same internally ) e.g. the_permalink(); orx <a href=”https://wordpress.stackexchange.com/questions/283706/<?php echo esc_url( get_the_permalink( $post_id ) ); ?>”> Notice I used esc_url to escape the value for security reasons. Here are some similar functions you might find useful: … Read more

WordPress alphabetical A-Z custom post type post result display

Another option if you don’t want to hard-code the alphabet links (i.e., if no posts start with a letter, then that letter is not shown in pagination at all). // Always show pagination // First, grab all posts. $posts = get_posts(array( ‘numberposts’ => -1, ‘post_type’ => ‘homeless’, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’ )); // … Read more

how do links move when I move my site?

Some links (those built in code) will automatically change to your new domain. Others (those in post content) you will want to swap out using something like better search replace to swap out localhost for your new domain.

How to rewrite product permalinks in Woocommerce to use category slugs

Ok, so the second code is: function custom_rewrite_basic() { $prodCatArgs = [‘taxonomy’ => ‘product_cat’]; $wooCats = get_categories($prodCatArgs); $catSlugs = []; foreach($wooCats as $wooCat) { $catSlugs[] = $wooCat->slug; } add_rewrite_rule( ‘^(‘.implode(‘|’, $catSlugs).’)/([^/]*)/?’, ‘index.php?post_type=product&category=$matches[1]&product=$matches[2]’, ‘top’ ); flush_rewrite_rules(); } add_action(‘init’, ‘custom_rewrite_basic’);

Unique one time use URL

You could add a setting using add_option( ‘access_keys’, [ ‘key_1’, ‘key_2 ] ) to check against when loading the page. add_action( ‘init’, ‘wpse339612_check_access_codes’ ); function wpse339612_check_access_codes(){ if( isset( $_GET[‘key’] ) ){ $available_keys = get_option( ‘access_keys’ ); $key_index = array_search( filter_var( $_GET[‘key’], $available_keys ); if( $key_index !== false ){ /*User has access! Delete the key from … Read more