• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

advanced custom fields wordpress custom class

phpwordpressadvanced-custom-fields


PHP Snippet 1:

/* Target Page 1 Button */
.page-1 .btn {
  background-color: red;
}
/* Target Page 2 Button */
.page-2 .btn {
  background-color: blue;
}

PHP Snippet 2:

<?php
// e.g. in functions.php
function extraButtonClass() {
  // Target by page slug or ID
  if(is_page('page-1')) {
    return ' red';
  } elseif(is_page('page-2')) {
    return ' blue';
  } else {
    return null;
  }
}

// In template:
<button class="btn<?php echo extraButtonClass(); ?>">My Button</button>

Related Snippets

I want to display a sweetalert after the inserting of data in my database

Set quantity minimum, maximum and step at product level in Woocommerce

Laravel Sanctum CSRF not authenticating

Display the default discounted price and percentage on Woocommerce products

Laravel: Why is my variable not being set while it's in the construct function of the controller?

laravel MVC execution flow

Warning file_get_contents () failed to open stream: HTTP request failed! HTTP/1.0 402 Payment Required

Using Associative arrays

PHP Get value from JSON [duplicate]

How to edit Records using CodeIgniter

could not find driver Debian SQL Server PHP

Mysqli multi query error

How to create a scheduler application in php

Google Calendar API batch request PHP

What will the best solution for this multiple optional filter?

About Contact Privacy policy Terms and conditions