Use same page-mypage.php template for several pages

To re-use the same template for different kinds of pages you can use the template_include filter. Example given from the docs: add_filter( ‘template_include’, ‘portfolio_page_template’, 99 ); function portfolio_page_template( $template ) { if ( is_page( ‘portfolio’ ) ) { $new_template = locate_template( array( ‘portfolio-page-template.php’ ) ); if ( !empty( $new_template ) ) { return $new_template; } … Read more

inserting content of 1 Post to in another with a template hierarchy

Yes, get_page_by_path() will return a post object or array on success, and not the post ID. $faq_post = get_page_by_path( $post_slug, OBJECT, ‘land’ ); // object $faq_post = get_page_by_path( $post_slug, ARRAY_A, ‘land’ ); // array So there is no need to make the custom new WP_Query call, and your code below is good: $faq_post = get_page_by_path( … Read more

Custom page for editing custom post type on frontend based on url

You can add custom url structures with add_rewrite_rule for example the proposed structure in your question can be achieved with something like… add_action( ‘init’, function() { add_rewrite_rule( ‘^jobs/([^/]+)/edit/?$’, ‘index.php?post_type=jobs&name=$matches[1]’, ‘top’ ); } ); So now if you visited https://example.com/jobs/job-title-example/edit/ you should see exactly the same as if you were to visit https://example.com/jobs/job-title-example/ this is because … Read more

wp_get_canonical_url showing first url of the post for custom page

This is because wp_get_canonical_url can only be used on posts, and cannot be used for tags authors archives etc. Returns the canonical URL for a post. https://developer.wordpress.org/reference/functions/wp_get_canonical_url/ More specifically, no equivalent exists for tag archives because archives and listings do not have canonical URLs. A canonical URL indicates to a search engine the correct and … Read more

get_avatar() as backround image

It’s hard to say exactly what the problem is with your code, but… There is at least one major flaw – you don’t pass any param to get_avatar_url, but first param for that function is required and should contain ID or email. To be precise: $id_or_email (mixed) (Required) The Gravatar to retrieve a URL for. … Read more