Using a Custom Post Type Attachment as link

you don’t want the link to the actual post then use the field link again: <?php $args = array( ‘numberposts’ => ‘5’, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘include’ => ”, ‘exclude’ => ”, ‘meta_key’ => ”, ‘meta_value’ =>”, ‘post_type’ => ‘weekly_mktg_report’, ‘post_status’ => ‘publish’ ); $recent_posts = wp_get_recent_posts( $args ); echo ‘<ul>’; //i was … Read more

Custom permalink – append taxonomy name and term name at the end of permalink

You can achieve the following permalink structure by simply overriding (without having to remove) the default one (you specified) for the resources post type: /resources/%resources%/resources-type/%resources_type% <- preferred /resources/resources-type/%resources_type%/%resources% <- default And you can override it via add_permastruct() — first, register the post type without specifying the rewrite parameter which means the rewrite defaults to true/enabled … Read more

Generate permalinks

The second argument of wp_unique_post_slug filter is post id. You can utilize that to generate the slug only once while creating the post for the first time. Method 1: add_filter( ‘wp_unique_post_slug’, ‘unique_slug_108286’, 10, 2 ); function unique_slug_108286( $slug, $postId ) { if ( ! $postId ) { $n = 4; $slug = bin2hex( random_bytes( $n … Read more

WordPress | Convert #038; to &

You’re setting the link using PHP-generated JavaScript. I’m sure there are better ways to do this, e.g. just write the onclick handler into the div, or use an <a> tag for a link as usual, but if you want to it this way you should be using esc_js() not esc_url(). <script type=”text/javascript”> document.getElementById(“professionista<?= $query->post->ID ?>”).setAttribute( … Read more