0

(Warning: WordPress newbie ahead...)

I have a WP site with a bunch of posts, many of which have tags associated with them. However, clicks on links to such tags -- https://example.com/tag/sample-tag) -- don't produce the pages I would expect -- a collection of teasers for posts with that tag. I just get the "nothing" page -- "Nothing Found / It seems we can’t find what you’re looking for. Perhaps searching can help".

I've dug through the database, and it looks like the tags are set up correctly -- proper cross-pointing entries in wp_terms, wp_term_relationships, etc, and the tags from the site show up in the standard WP Tags Cloud widget. I've checked the site logs, and the requests to /tag/sample-tag or whatever are returning a 200 status code, so the underlying mechanism seems to be ok -- it's just not producing the matching pages. Down in the Permalink settings, I've tried setting the optional "tag base" field to "tag" or to nothing, but neither works. I've also tried switching from my custom theme to twentynineteen, but I get the same behavior there.

So: Any ideas? Am I misinterpreting how these links are supposed to work? Anything else? Thanks!

2
  • Are there posts tagged with sample-tag? – Pat J Mar 13 at 4:00
  • Yes. All the tags are there and connected to posts, but nothing is showing up. – Jim Miller Mar 14 at 15:32
0

Found it: The posts I'm working with are instances of custom posts, and the default get_posts() function assumes that posts are just, well, posts. So it wasn't finding them, and was properly returning "none".

Solution: I added some code to my theme's function.php file, like so:

function set_up_theme() {
   ...other stuff
   function mytheme_pre_get_posts ()
      $query->set('post_type', 'my_custom_post_type');
   }
   add_action('pre_get_posts', 'mytheme_pre_get_posts');
}

Better ways or places to set this up are welcome, but it seems to be doing the trick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.