WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#8803 closed defect (bug) (worksforme)

get_category_by_slug doesnt work

Reported by: security_man Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.6.1
Component: General Keywords: reporter-feedback
Focuses: Cc:

Description

not sure if its because there are now two category types link and post, but nothing is returned by get_category_by_slug function in v 2.6.5 and i dont see any changes in the code for 2.7

also the wp_get_bookmarks doesnt honor the category_name argument. these are probably related as one would function the same as the other as wp_get_bookmarks works fine with the correct category id.

Change History (2)

comment:1 DD325 years ago

  • Keywords reporter-feedback added

Seems to work for me:

<?php

var_dump(get_category_by_slug('general'));

?> 
object(stdClass)[169]
  public 'term_id' => &string '4' (length=1)
  public 'name' => &string 'General' (length=7)
  public 'slug' => &string 'general' (length=7)
  public 'term_group' => string '0' (length=1)
  public 'term_taxonomy_id' => string '4' (length=1)
  public 'taxonomy' => string 'category' (length=8)
  public 'description' => &string '' (length=0)
  public 'parent' => &string '0' (length=1)
  public 'count' => &string '13' (length=2)
  public 'cat_ID' => &string '4' (length=1)
  public 'category_count' => &string '13' (length=2)
  public 'category_description' => &string '' (length=0)
  public 'cat_name' => &string 'General' (length=7)
  public 'category_nicename' => &string 'general' (length=7)
  public 'category_parent' => &string '0' (length=1)

However, Going off your second paragraph, Are you referring to Link Categories? If So, get_category_by_slug()} is only for post categories, not for link categories. (Was it ever different?)

Next, wp_get_bookmarks().. I guess you mean get_bookmarks() ?

In which case, That works for me too:

<?php

var_dump(get_bookmarks('category_name=Blogroll'));

?> 
array
  0 => 
    object(stdClass)[154]
      public 'link_id' => string '2' (length=1)
      public 'link_url' => string 'http://wordpress.org/development/' (length=33)
      public 'link_name' => string 'Development Blog' (length=16)
      public 'link_image' => string '' (length=0)
      public 'link_target' => string '' (length=0)
      public 'link_category' => string '0' (length=1)
      public 'link_description' => string '' (length=0)
      public 'link_visible' => string 'Y' (length=1)
      public 'link_owner' => string '1' (length=1)
      public 'link_rating' => string '0' (length=1)
      public 'link_updated' => string '0000-00-00 00:00:00' (length=19)
      public 'link_rel' => string '' (length=0)
      public 'link_notes' => string '' (length=0)
      public 'link_rss' => string 'http://wordpress.org/development/feed/' (length=38)
      public 'object_id' => string '2' (length=1)
      public 'term_taxonomy_id' => string '2' (length=1)
      public 'term_order' => string '0' (length=1)
      public 'term_id' => string '2' (length=1)
      public 'taxonomy' => string 'link_category' (length=13)
      public 'description' => string '' (length=0)
      public 'parent' => string '0' (length=1)
      public 'count' => string '8' (length=1)
      public 'recently_updated' => string '0' (length=1)

I'd suggest disabling all your plugins and trying again, AFAIK nothing was changed related to links/bookmarks between 2.6.3 and 2.6.5 to start with.

comment:2 ryan5 years ago

  • Milestone 2.8 deleted
  • Resolution set to worksforme
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.