• 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

Prevent blank space in pdf pages (DomPdf)

How to convert time from one timezone to another in PHP

How to Display Data in Yajra Datatables Laravel 7?

Add restriction to WooCommerce coupons by allowed user ID

Any AWS EB Laravel route getting 404 Not Found nginx/1.16.1

Docker & Laravel : configure: error: Package requirements (oniguruma) were not met

php curl requesting twice

Cant seem to get the Pagination to work on my WooCommerce REST API application?

Explain how this array transposing and flattening function works

Converting array to string and then back in PHP

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255

Laravel Model save() & update() Not Saving

HTML + PHP + PHPMAILER

How to create a cookie to store the timestamp of when a page is first loaded with php

getting error while enter Command => php artisan route:list

About Contact Privacy policy Terms and conditions