Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8870963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:51:54+00:00 2026-06-14T17:51:54+00:00

Reposted due to no replies. I’m having some trouble setting a custom canonical title

  • 0

Reposted due to no replies.

I’m having some trouble setting a custom canonical title using the WordPress SEO API: http://yoast.com/wordpress-seo-api-docs/

I have a custom post type called designs which uses a custom URL rewrite. It takes the base page /design/ and adds the design name to it like /design/a-design/. The canonical in WordPress SEO by default is the /design/ page.

What I want to do is write a function which determines if it is a design page and return a different canonical. I can test whether it’s a design page by doing if ($design == ""){ and I tried to use the custom permalink URL, but the function just removes the canonical completely.

Here’s my basic function:

function design_canonical(){
    if ($design == "") {    
        // Leave blank and Yoast SEO will use default canonical for posts/pages
    }
    else {
        return $design['detailslink'];
    }
}
add_filter( 'wpseo_canonical', 'design_canonical' )

Quite clearly doing something wrong, but I’m not entirely sure what.

Thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:51:55+00:00Added an answer on June 14, 2026 at 5:51 pm

    You could try something like:

    function design_canonical($url) {
        global $post;
    
        if ( get_post_type( $post->ID ) == 'design' ) {
            return site_url( '/design/' . $post->post_name );
        } else {
            // Do nothing and Yoast SEO will use default canonical for posts/pages
            return $url;
        }
    }
    add_filter( 'wpseo_canonical', 'design_canonical' );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using MySQL with the .Net connector on 64 bit Windows. For some
I've been using the org.apache.commons.mail.HtmlEmail class, from apache commons-mail, for some time. Eventually, some
I'm trying to create an auto-complete box and have been having problems due to
I'm having trouble matching up the offsets in the stack traces of iOS crash
A user reported to us that some strange behaviour in our application can be
I'm using ACRA ( arca.ch ) to generate automatic error reports. I just released
I am working on a Java application that will use some Hibernate (annotated by
Using MySQL 5 I have a table like this: date (varchar) door (varchar) shift
I have run into an issue that is probably due to my mis-understanding of
I'm using OpenMPI with C bindings. In my code, there is a required number

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.