Author: therichpost

  • Rewrite wordpress post url working example

    Rewrite wordpress post url working example

    Hello to all, welcome to therichpost.com. In this post, I will tell you, how to Rewrite wordpress post url working example.

    Here I am introducing the new chapter of my blog and that is called Wp Tricks.

    Now I come to this post, first I will tell you very short story behind this post. last few days ago, I was searching for changing WordPress Post URL and only with WordPress Hooks and I just want to add “blog” in between my WordPress Post URLs and I have done with below code.

    Here is the working code and you need to add this into your theme’s functions.php file very carefully:

    function filter_post_link($permalink, $post) {
        //Using only for post but can use for other posts types too
        if ($post->post_type == 'post')
         {  
             return 'blog'.$permalink; // this code will add blog in my post ulrs https://therichpost.com/blog/post-title
    
         }
    }
    add_filter('pre_post_link', 'filter_post_link', 10, 2);
    
     This will Filters the permalink structure for a post before token replacement occurs.

    For Working, please check this video:

    If you have any query related to this post then feel free to ask.

    Jassa

    Thank you

  • Laravel select2 with json data working example

    Laravel select2 with json data working example

    Hello to all, welcome to therichpost.com. In this post, I will tell you, Laravel select2 with json data working example.

    laravel-select2
    laravel-select2

    Here is the complete working code and you can add this any of your’s laravel blade template file:

    http://prntscr.com/ouhn27
    <!doctype html>
    <html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
        <head>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1">
    
            <title>Laravel</title>
    
            <!-- Fonts -->
            <link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet">
            <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
            <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.8/css/select2.min.css" rel="stylesheet" />
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.8/js/select2.min.js"></script>
    
            <!-- Custom Script -->
            <script>
            $(document).ready(function() {
                var sampleArray = [{id:'AL',text:'Alabama'}, {id:'WY',text:'Wyoming'}];
                $('.js-example-basic-single').select2({data: sampleArray});
            });
            </script>
        </head>
        <body>
        <div class="jumbotron text-center">
        <h1></h1>
        <p></p> 
        </div>
        <div class="container">
            <div class="row">
                <div class="col-sm-8">
                <select class="js-example-basic-single form-control" name="state">
                    <option value="AL">Alabama</option>
                    <option value="WY">Wyoming</option>
                </select>
                </div>
            </div>
        </div>
        </body>
    </html>
    

    If you have any query related to this post, then please let me know.

    Jassa

    Thank you

  • Woocommerce mini cart add change quantity button

    Woocommerce mini cart add change quantity button

    Hello to all, welcome therichpost.com. In this post, I will tell you, how to add Woocommerce mini cart add change quantity buttons?

    Woocommerce mini cart add change quantity buttons
    Woocommerce mini cart add change quantity buttons

    Very soon, I am making video tutorial for this.

    Woocommerce is the best Ecommerce WordPress Plugin. Woocommerce gives us many features and Mini Cart feature is one of the best. But in Woocommerce Mini Cart, we can not change quantity but I have done that solution in my way and in above image, you can see change quantity feature in Woocommerce Mini Cart.

    Live Working demo link: https://therichpost.com/richtheme/shop/

    I have done this with jQuery and WordPress hooks.

    If you want that feature then please comment below.

    Thank you

  • Fullcalendar with select year and month dropdown

    Fullcalendar with select year and month dropdown

    Hello to all, welcome to therichpost.com. In this post, I will tell you, Fullcalendar with select year and month dropdown .

    Fullcalendar with select year and month dropdown
    Fullcalendar with select year and month dropdown

    Most of the things, I have done with jQuery and I like jQuery the most. Without jQuery, I think, site is incomplete(haha).

    Also, for good looks, I have used Bootstrap 4.

    I have shared many posts related to Fullcalendar and this is one also a good post related to Fullcalendar.

    Here is the working code and you can add this into your html to check the perfect working:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset='utf-8' />
    <link href='https://fullcalendar.io/releases/fullcalendar/3.9.0/fullcalendar.min.css' rel='stylesheet' />
    <link href='https://fullcalendar.io/releases/fullcalendar/3.9.0/fullcalendar.print.min.css' rel='stylesheet' media='print' />
    <script src='https://fullcalendar.io/releases/fullcalendar/3.9.0/lib/moment.min.js'></script>
    <script src='https://fullcalendar.io/releases/fullcalendar/3.9.0/lib/jquery.min.js'></script>
    <script src='https://fullcalendar.io/releases/fullcalendar/3.9.0/fullcalendar.min.js'></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
    <script>
    
      $(document).ready(function() {
        $('#calendar').fullCalendar({
          header: {
            left: '',
            center: 'title',
            right: ''
          },
          defaultDate: moment().format("YYYY-MM-DD"),
          navLinks: true, // can click day/week names to navigate views
          editable: true,
          eventLimit: true, // allow "more" link when too many events
          events: [
            {
              title: 'Lunch',
              start: '2019-08-12T12:00:00'
            },
            {
              title: 'Meeting',
              start: '2019-08-12T14:30:00'
            },
            {
              title: 'Happy Hour',
              start: '2019-08-12T17:30:00'
            },
            {
              title: 'Dinner',
              start: '2019-08-12T20:00:00'
            },
            {
              title: 'Birthday Party',
              start: '2019-08-13T07:00:00'
            },
            {
              title: 'Click for Google',
              url: 'https://therichpost.com/open-bootstrap-modal-popup-event-click-fullcalendar',
              start: '2019-08-28'
            }
          ]
        });
      
       $(".fc-right").append('<select class="select_month form-control"><option value="">Select Month</option><option value="1">Jan</option><option value="2">Feb</option><option value="3">Mrch</option><option value="4">Aprl</option><option value="5">May</option><option value="6">June</option><option value="7">July</option><option value="8">Aug</option><option value="9">Sep</option><option value="10">Oct</option><option value="11">Nov</option><option value="12">Dec</option></select>');
       $(".fc-left").append('<select class="select_year form-control"><option value="2019">2019</option><option value="2020">2020</option><option value="2021">2021</option></select>');
      
       $(".select_month").on("change", function(event) {
          $('#calendar').fullCalendar('changeView', 'month', this.value);
          $('#calendar').fullCalendar('gotoDate', $(".select_year").val()+"-"+this.value+"-1");
       });
    
       $(".select_year").on("change", function(event) {
          $('#calendar').fullCalendar('changeView', 'month', this.value);
          $('#calendar').fullCalendar('gotoDate', this.value+"-"+$(".select_month").val()+"-1");
       });
    
      });
    
    </script>
    <style>
    
      body {
        margin: 40px 10px;
        padding: 0;
        font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
        font-size: 14px;
      }
    
      #calendar {
        max-width: 900px;
        margin: 0 auto;
      }
    
    </style>
    </head>
    <body>
      <div class="container">
        <div class="row">
      <div id='calendar'>
      </div>
      </div>
      </div>
    
    </body>
    </html>

    If you have any query related to this post, then please let me know.

    Jassa,

    Thank you

  • How to use case in Laravel query?

    How to use case in Laravel query?

    Hello to all, welcome to therichpost.com. In this post, I will tell you, How to use case in Laravel query?

    Laravel is the top PHP MVC framework and today, I am just telling you simple code snippet for Case Statement in Laravel Query.

    use DB;
    $employee = "SELECT firstName,
                 CASE
                 WHEN status = 2 THEN 'Completed'
                 WHEN status = 3 THEN 'Cancelled'
                 WHEN status = 4 THEN 'Cancelled'
                 FROM employee";
    $employeedata = DB::select( DB::raw(  $employee  ) );

     

    If you have query related to this post, then please do comment below.

    Jassa Jatt,

    Thank you

  • How to create new user role in WordPress and add capability to that role?

    How to create new user role in WordPress and add capability to that role?

    Hello to all, welcome to therichpost.com. In this post, I will tell you, How to create new user role in WordPress and add capability to that role?

    WordPress is the best part for me in developer websites.

    We will create new user role like “administrator” with wordpress custom functionality. We will create “employee” user role and we will also add capability like edit post, add post etc.

    Here is the code and you need to add this code in your theme’s functions.php file:

    function add_theme_caps() {
      add_role(
        'employee',
        __( 'Therichpost Employee' ),
        array(
          'read'           => true,  // true allows this capability
          'edit_posts'     => false,
          'delete_posts'   => false, // Use false to explicitly deny
          'manage_options' => false
        ) );
    
      // gets the author role
      $role = get_role( 'employee' );
    
           // add capability to the author role
      $role->add_cap( 'view_dashboard' );
    }
    
    add_action( 'admin_init', 'add_theme_caps' );
    

     

    This is it, if you have any query related to this post or you want any kind information related wordpress then please let me know.

    Jassa jatt

    Thank you

  • How to use Thrive Theme global header and footer in post pages?

    How to use Thrive Theme global header and footer in post pages?

    Hello to all, welcome to therichpost.com. In this post, I will tell you, How to use Thrive Theme global header and footer in post pages?

    Thrive Architect, has very good feature and I like it but one thing is missing in
    Thrive Architect and that is Global Header and Global Footer feature in post pages But I solved this thing with my own way.

    Jassa

  • React routing working example

    React routing working example

    Hello to all, welcome to therichpost.com. In this post, I will tell you, React routing working example.

    After very long time, I came with Reactjs and this will be very intersting post.

    Very first, you have to install Reactjs setup on you local machine and for this please check the basics steps and here are they:

    1. First make sure, you have nodejs installed on your system because we will run and install reactjs with npm commands.
    
    2. Create a empty folder in your  any drive named 'reactapp'
    
    3. Go to 'reactapp' folder and Open command prompt and run below command:
       npm install -g create-react-app
    
    4. After run the above command wait for some time and after successfully installed files, you need to run below command in 'reactapp' folder:
       create-react-app helloreact
    
    5. After run above command wait to sometime and you will below files structure in your 'reactapp' folder:

     

    reactjs-app-file-structurea

    1.  After it, go to 'helloreact' folder and open command prompt,  run below command:
        npm start
    
    2. After run ablove command, you will see http://localhost:3000/ url and copy and run this url into your browser and you are done.

     

    reactjs-app-running

    Now, you have react setup on your local machine and now we will do react routing and here are the steps:

    You have to run below commands to install react router module and other basics modules.

    npm install --save react-router-dom
    
    npm install --save bootstrap
    
    npm install --save reactstrap react react-dom

    Here is the code for src/index.js file:

    import React from 'react';
    import ReactDOM from 'react-dom';
    import { BrowserRouter as Router, Switch, Route, Link } from 'react-router-dom';
    import About from './about';
    import Home from './home';
    import {
      Navbar,
      NavbarBrand,
      Nav,
      NavItem,
      Container, Col } from 'reactstrap';
    import 'bootstrap/dist/css/bootstrap.min.css';
    class Hello extends React.Component{
      render() {
        return (
      <Router>
                <Container>
          <Navbar color="light" light expand="md">
              <NavbarBrand><h2>Therichpost</h2></NavbarBrand>
          <Nav className="ml-auto" navbar>
                  <NavItem>
                    <Link to={'/home'}>Home</Link>
                  </NavItem>
            <NavItem>
                    <Link to={'/about'}>About</Link>
                  </NavItem>
            </Nav>
          </Navbar>
          
              <Col xs="12">
          <Switch>
                      <Route exact path='/' component={Home} />
              <Route exact path='/home' component={Home} />
                      <Route exact path='/about' component={About} />
                   </Switch>
          </Col>
          
                   <footer class="container-fluid">
            <center><p>Therichpost</p></center>
          </footer>
             
                </Container>
          
             </Router>
        );
      }
      }
    
      ReactDOM.render(<Hello />, document.getElementById('root'));

     

    Here is the code for src/home.js:

    import React from 'react';
    class Home extends React.Component{
      render() {
        return (
      
        <h6><p>Home</p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</h6>
        );
      }
      }
      export default Home;

     

    Here is the code for src/about.js:

    import React from 'react';
    class About extends React.Component{
      render() {
        return (
      
        <h6><p>About Us</p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</h6>
      
        );
      }
      }
      export default About;

     

    Now, in your command prompt, run below command and check the output with below image:

    npm start
    reactjs_routing

    Now, this is done, if you have any query related to this post then please do comment below.

    Jassa Jatt

  • How to integrate eBay with Php or wordpress?

    How to integrate eBay with Php or wordpress?

    Hello to all, welcome to therichpost.com. In this post, I will tell you, How to integrate eBay with Php or wordpress?

    If you want to integrate eBay with Php or wordpress then please let me know.

    Thank you

  • Angular 8 Fullcalendar with dynamic events working code

    Angular 8 Fullcalendar with dynamic events working code

    Hello to all, welcome to therichpost.com. In this post, I will tell you, Angular 8 Fullcalendar with dynamic events working code.

    Angular 8 has just arrived and I like it. I also like Javascript Fullcalendar because of its good features.

    You can check my more posts related to Angular 8.

    In this post example, I am getting dynamic events from my 
    php code file by custom made json events data and my 
    main motto is to get dynamic events and I am done :).

    Here is the working code and please follow carefully:

    1. Here are the some basic commands to download fresh Angular 8 setup, fullcalendar and jquery on your local machine:

    $ npm install -g @angular/cli       //Setup Angular8 atmosphere
     
    $ ng new angularlatest8            //Install New Angular App
    
    /**You need to update your Nodejs also for this verison**/
    
    $ cd angularlatest8               //Go inside the Angular 8 Project
    
    $ npm install jquery –save       //Add jquery module
    
    $ npm i fullcalendar             //Add fullcalendar module
    
    $ npm i moment                  //Add momentjs library
    
    $ ng serve                     //Run your Angular 8 Project

     

    2. Here is the code, you need to add into your angular.json file in root folder for including fullcalendar and jquery libraries:

    ...
    "styles": [
                  "src/styles.css",
                  "node_modules/fullcalendar/dist/fullcalendar.min.css"
                ],
                "scripts": ["node_modules/jquery/dist/jquery.min.js",
                "node_modules/moment/min/moment.min.js",
                "node_modules/fullcalendar/dist/fullcalendar.min.js"]
    ...

     

    3. Here is the code, you need to add into your src/app/app.module.ts file:

    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    import { AppComponent } from './app.component';
    import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
    
    //HttP for Rest API's
    import { HttpClientModule } from '@angular/common/http';
    @NgModule({
      declarations: [
        AppComponent
      ],
      imports: [
        BrowserModule,
        BrowserAnimationsModule,
        HttpClientModule
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }

     

    4. Here is the code, you need to add into your src/app/app.component.ts file:

    In this, I am calling data from mypage.php file with http client.
    import { Component } from '@angular/core';
    import { HttpClient } from '@angular/common/http';
    declare var $: any;
    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css']
    })
    export class AppComponent {
      title = 'easyfullcalendar';
      posts: any;
      constructor(private http: HttpClient) { }
      
      getItems() {
       return this.http.get('http://localhost/mypage.php').subscribe(data => {
           this.posts = data;
           setTimeout(() => {
            $("#calendar").fullCalendar({  
                            header: {
                                left   : 'prev,next today',
                                center : 'title',
                                right  : 'month,agendaWeek,agendaDay'
                            },
                            navLinks   : true,
                            editable   : true,
                            eventLimit : true,
                            events: [this.posts],  // request to load current events
                        });
    
         }, 100);
      });
       
    }
    
      ngOnInit(){
      	   this.getItems();
           
       }
    }

     

    5. Finally, here is the code for you src/app/app.component.html file:

    <div id="calendar"></div>

     

    6. Finally here is the code for mypage.php file and you need to add this into you xampp:

    <?php
    header("Access-Control-Allow-Origin: *");
    header("Access-Control-Allow-Methods: PUT, GET, POST");
    header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
    $events = array('title' => 'This is your','start' => '2019-07-15');
    echo json_encode($events);
    ?>

     

    7. Now run below command into your terminal and follow the below link:

    ng serve
    
    // you will get this link and run that link into your browser
    localhost:4200

     

    This is it and if you have any query related to this post then please let me know.

    Jassa Jatt,

    Thank you