• 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

WAMP Virtual Host not working

carbon generated datetime not stored correctly into the database

Nginx RTMP not recording

Change the alert text on add to cart action without selected variation in Woocommerce

How to add automatically collapse/expand in content wordpress (single.php)?

how do i retrieve and display the alt text of an image in wordpress?

how to hide previous markers when new markers added in google map javascript api

How to separate letters and digits from a string in php

Laravel Route issues with Route order in web.php

enroll_table three field fetch to payment form to create payment field in laravel 5.5

How to pass data to all views in Laravel 5?

GRPC installed successfully on ubuntu but php is looking for it in another folder

PHP: Insert marker every 3 iterations

I cannot create a auto generated date time in mysql workbench

retrieve data from database using session

About Contact Privacy policy Terms and conditions