• 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

how can I set a session variable in Drupal 8 and get it in a php script?

PHP if in_array() how to get the key as well?

Not able to access model in the controller mautic

Add rows to Single product Additional information table in WooCommerce 3.6

How to unlink image from folder?

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

how to remove %20 in the url in php

generating a random code in php?

How to submit the custom form data in database in WordPress without plugin using ajax?

Get WooCommerce products from specific category

how to insert data into select2 search input after scan using qrcode

PHP my timezone is no setting up in PHP.ini File in xampp

How to validate tin and cst using PHP?

CodeIgniter 3 is generating a session file on each request, why?

How to fix bootstrap multiselect search data using ajax

About Contact Privacy policy Terms and conditions