• 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

PHP, how to convert Int value to Week days

How to edit Records using CodeIgniter

Invalid value in field "itemtype" in Google Search Console

how to sort by a custom appended relation to model

Star and Half Star Rating in Laravel

Wordpress wpdb->delete issue

Apply filter array/return terms

How to create a individual template for page or post in custom plugin?

javascript html popup window

best way to store error messages in Laravel (session or variable)

Remove country code from phone number?

Filter WooCommerce related products by Polylang language

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

How to get company posts from LinkedIn via API?

Check if string contains a value in array [duplicate]

About Contact Privacy policy Terms and conditions