• Skip to primary navigation
  • Skip to main content
OsomCode

OsomCode

Awesome code tutorials for WordPress and Genesis

  • Subscribe
  • My account
    • Edit profile
    • Favorites
    • Update credit card
  • Login

How to prioritize a CPT in WordPress search results

Learn how to display first a particular Custom Post Type (CPT) entry in WordPress search results with this tutorial.

Following a request from a subscriber, I prepared a tutorial to choose the order of appearance in the search results when using Relevanssi Plugin.

But if you’re not using the Relevanssi plugin, you can also get the CPT you want to display first in WordPress search results with this code tutorial.

Snippet to prioritize a CPT in WordPress search results

Add the following code at the end of functions.php or in your functionality plugin:

To see this and another 847 code snippets of this website, login or subscribe here.

In this case you are prioritizing the portfolio entries, but you can change it to the CPT of your choice.

Conclusions

Now you know how to get entries from a particular CPT to be prioritized in WordPress searches.

Any questions? Let me know in the comments.

And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉

CPT PHP Search

To leave read and make questions about this code, you can login or register.

  • About OsomCode
  • FAQ
  • Contact

Legal Notice · Privacy Policy · Cookie Policy · Terms and conditions
Copyright © 2023

Lost your password?