• I made a wordpress widget there everything is ok but css not working for widget title.Everything is okay in CSS file and title class also> CSS working for widget content but not working for widget title.Dont know whats going wrong.Please help.Here is my code:

    /**
     * Adds Footer_One widget.
     */
    class Footer_One extends WP_Widget {
    
        /**
         * Register widget with WordPress.
         */
        function __construct() {
            parent::__construct(
                'footer_one', // Base ID
                esc_html__( 'Footer Logo Text', 'solutioncat' ), // Name
                array( 'description' => esc_html__( 'A Footer Widget', 'solutioncat' ), ) // Args
            );
        }
    
        /**
         * Front-end display of widget.
         *
         * @see WP_Widget::widget()
         *
         * @param array $args     Widget arguments.
         * @param array $instance Saved values from database.
         */
        public $args = array(
            'before_widget' => '<div class="footer-widget wow animated fadeInUp" data-wow-duration="2s">',
            'after_widget'  => '<div>',
            'before_title'  => '<h2 class="footer-heading">',
            'after_title'   => '</h2>',
        );
        public function widget( $args, $instance ) {
            echo $args['before_widget'];
            if ( ! empty( $instance['title'] ) ) {
                echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
            }
            ?> 
            <div class="footer-logo">
                                    <a href="<?php echo esc_url(home_url('/'));?>"><img src="<?php echo get_theme_mod('logo-footer');?>" alt="logo Footer" /></a>
                                </div>
    
                                <div class="footer-content">
                                    <p>
                                       <?php echo get_theme_mod('footer_text'); ?>
                                    </p>
                                </div>
                                <div class="store-button">
                                    <ul>
                                        <li>
                                            <a href="<?php echo get_theme_mod('ios_footer_link');?>" target="_blank"><img src="<?php echo get_template_directory_uri(); ?>/assets/img/slider/app_store.png" alt="store-button" /></a>
                                        </li>
                                        <li>
                                            <a href="<?php echo get_theme_mod('android_footer_link');?>" target="_blank"><img src="<?php echo get_template_directory_uri(); ?>/assets/img/slider/play_store.png" alt="store-button" /></a>
                                        </li>
                                    </ul>
                                </div>                      
         <?php
            echo $args['after_widget'];
        }
    
        /**
         * Back-end widget form.
         *
         * @see WP_Widget::form()
         *
         * @param array $instance Previously saved values from database.
         */
        public function form( $instance ) {
            $title = ! empty( $instance['title'] ) ? $instance['title'] : esc_html__( 'New title', 'solutioncat' );
    
            ?>
            <p>
            <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_attr_e( 'Title:', 'solutioncat' ); ?></label>
            <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
            </p>
            <?php
        }
    
        /**
         * Sanitize widget form values as they are saved.
         *
         * @see WP_Widget::update()
         *
         * @param array $new_instance Values just sent to be saved.
         * @param array $old_instance Previously saved values from database.
         *
         * @return array Updated safe values to be saved.
         */
        public function update( $new_instance, $old_instance ) {
            $instance = array();
            $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? sanitize_text_field( $new_instance['title'] ) : '';
    
            return $instance;
        }
    
    } // class Footer_One
    
    // register Footer_One widget
    function Footer_One_widget() {
        register_widget( 'Footer_One' );
    }
    add_action( 'widgets_init', 'Footer_One_widget' );
    • This topic was modified 3 years, 3 months ago by Rihan Habib.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Topher

    (@topher1kenobe)

    Can we see your site and CSS?

    Thread Starter Rihan Habib

    (@xihad1)

    Mr.Toper thank you so much for your replay. Isolved this issue. Now new problem arised for me I made form by PHP,HTML,Bootstrap. But problem is when I clicked on submit it redirect to 404 page. I checked several times seems everything is ok. I dont know whats going wrong. Please help, here is my code :

    INDEX.PHP :

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <link rel="stylesheet" href="<?php echo get_template_directory_uri();?>/bootstrap.min.css">
        <title>Contact Us Form In Php</title>
    </head>
    <body>
    
        <div class="container">
            <div class="row">
                <div class="col-lg-6 m-auto">
                    <div class="card mt-5">
                        <div class="card-title">
                            <h2 class="text-center py-2"> Contact Us </h2>
                            <hr>
                            <?php
                                $Msg = "";
                                if(isset($_GET['error']))
                                {
                                    $Msg = " Please Fill in the Blanks ";
                                    echo '<div class="alert alert-danger">'.$Msg.'</div>';
                                }
    
                                if(isset($_GET['success']))
                                {
                                    $Msg = " Your Message Has Been Sent ";
                                    echo '<div class="alert alert-success">'.$Msg.'</div>';
                                }
    
                            ?>
                        </div>
                        <div class="card-body">
                            <form action="process.php" method="post">
                                <input type="text" name="UName" placeholder="User Name" class="form-control mb-2">
                                <input type="email" name="Email" placeholder="Email" class="form-control mb-2">
                                <input type="text" name="Subject" placeholder="Subject" class="form-control mb-2">
                                <textarea name="msg" class="form-control mb-2" placeholder="Write The Message"></textarea>
                                <button class="btn btn-success" name="btn-send"> Send </button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
    </html>

    PROCESS.PHP:

    <?php
    
        if(isset($_POST['btn-send']))
        {
           $UserName = $_POST['UName'];
           $Email = $_POST['Email'];
           $Subject = $_POST['Subject'];
           $Msg = $_POST['msg'];
    
           if(empty($UserName) || empty($Email) || empty($Subject) || empty($Msg))
           {
               header('location:index.php?error');
           }
           else
           {
               $to = "[email protected]";
    
               if(mail($to,$Subject,$Msg,$Email))
               {
                   header("location:index.php?success");
               }
           }
        }
        else
        {
            header("location:index.php");
        }
    ?>

    All files(index.php , process.php, bootstrap.min.js) are styaing in same folder

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘CSS not Working in Custom Widget title ,without title works everywhere properly’ is closed to new replies.