• I am trying to look on using Code Snipped to modify Plugin.

    Don’t know if that’s possible, so maybe somebody could help on that. I am not an expert.

    I am using HTML5 Responsive FAQ plugin that got in main Plugin File html5-responsive-faq/html5-responsive-faq.php

    
    function register_hrf_faq() {
    
       register_post_type('hrf_faq', array(
    
             'rewrite'         => array(
                                     'slug'       => 'hrf_faq',
    

    I have paste only a part of this function.

    Is it possible using Code Snipped replace ‘hrf_faq’ to ‘faq’ only (in ‘slug’ part)

    Tries to use str_replace but apart of brake of the website, haven’t got any success.

    • This topic was modified 7 years, 6 months ago by Dariusz.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    A quick web search reveals this WordPress Stack Exchange question, which suggests that this is not very simple, but is possible.

    Here’s a sample code snippet:

    add_action( 'init', function () {
        if ( $current_rules = get_option( 'rewrite_rules' ) ) {
            foreach ( $current_rules as $key => $val ) {
                if ( strpos( $key, 'hrf_faq' ) !== false ) {
                    add_rewrite_rule( str_ireplace( 'hrf_faq', 'faq', $key ), $val, 'top' );
                }
            }
    
        }
        flush_rewrite_rules();
    } );
    • This reply was modified 7 years, 6 months ago by Shea Bunge.
    Thread Starter Dariusz

    (@idarek)

    Thank you, will have a try.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Code Snipped to modify Plugin’ is closed to new replies.