[wp-trac] [WordPress Trac] #54443: Database Error Breaks "custom_css_post_id" Theme Mod

WordPress Trac noreply at wordpress.org
Fri Nov 19 13:31:08 UTC 2021


#54443: Database Error Breaks "custom_css_post_id" Theme Mod
---------------------------+-----------------------------
 Reporter:  domainsupport  |       Owner:  (none)
     Type:  defect (bug)   |      Status:  new
 Priority:  normal         |   Milestone:  Future Release
Component:  Customize      |     Version:  4.7
 Severity:  normal         |  Resolution:
 Keywords:  needs-patch    |     Focuses:
---------------------------+-----------------------------

Comment (by domainsupport):

 As an aside, I wrote this to restore lost custom CSS ...

 {{{#!php
 <?php
 if (-1 === get_theme_mod('custom_css_post_id')) {

    $custom_css_posts = get_posts(array('post_type' => 'custom_css',
 'numberposts' => -1));

    if (is_array($custom_css_posts)) {

       foreach ($custom_css_posts as $custom_css_post) {

          if (get_stylesheet() === $custom_css_post->post_title) {

             set_theme_mod('custom_css_post_id', $custom_css_post->ID);

          }

       }

    }

 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54443#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list