You could listen for the $_SERVER['HTTP_REFERER']
and add a class to the body depending on that referer
add_filter( 'body_class','wpse_body_classes' );
function wpse_body_classes( $classes ) {
if ( is_page( 'event' ) ){ // event is the page slug of the page we wish to add the class for
if( wp_get_referer() == '/url/of/get_involved' ){
$classes[] = 'my-light-bg';
}
elseif( wp_get_referer() == '/url/of/urban_innovation_center' ){
$classes[] = 'my-dark-bg';
}
else {
$classes[] = 'my-default-bg';
}
}
return $classes;
}
EDIT
Updated the code to
- make use of wp_get_referer
- check if we are on the event page so the filter only runs on that page
- add a default body class to that page if no referrer is set
Related Posts:
- Is it possible to use a single custom post as the site front page
- Listing a post’s categories and subcategories
- Single post comment template not working
- How do I show google ads between post content?
- Add inline style to get_the_category_list
- Help with figuring out the future post workaround
- Disable single view for specific post category
- Only nextpagelink on wp_link_pages
- Display a post map on a blank/new page
- How To Pass Current Post Type ID from Single Template To Custom Page Template
- Is it possible to create rel=”noindex, nofollow” for a single post if contain bad keywords?
- Custom seperate Single.php
- Set a cookie only in single posts
- Custom post type not respecting template hierarchy
- WordPress object for comments frame [closed]
- I’m having a problem viewing the Youtube video
- Use different «Single.php» for custom categories
- force https except one page/post
- Single custom post type template not working (single-custom_post_template.php) not working
- Single.php category entries not showing right colours
- Link from archive-page.php to single-page.php
- How to check if a post is in categories x,y,z inludint their subcategories
- Changing the display of the themename_posted_on() function
- How to Highlight current category on category and single page template?
- Exclude single page from function
- WordPress, alternative single post template
- get full real path of thumbnail post img wordpress
- how to loop through this in blog single?
- Modify post template on Divi Theme
- I want to signin from first wordpress site to other wordpress website without registration..without using network mode
- Try to showing product file size on product single page
- Improve related posts
- Get active term on single (CPT) page
- Having single posts appear under the blog homepage and highlight menu items properly?
- Single.php loading fully on localhost but not on server
- explain why is_single doesn’t work
- Conditional for single-{post-type}.php
- How to modify single.php in a child theme?
- How do I get the category URL from get_the_category?
- Custom permalink structure only for default posts
- How do I create a link that will always show the latest post?
- Posts in multiple Categories different single.php
- How to show a post single post in page template
- Using previous_post_link and next_post_link to wrap around post sequence
- How do I create new content pages for my Custom Post Type?
- Problem with single-page for my custom post
- Insert After Second Paragraph Without Tag?
- Custom template for post type not working
- Which action fire in front-end single post only
- Best way to programatically add “rel” attributes to page and post images
- Display only entire most recent post on author page?
- 404 Page Not Found for Only One Post
- Add code just after Post content
- Pagination on single post page?
- Custom post template for particular posts
- Single Template that can be applied only via URL
- Remove post templates from the selection box menu when creating a single post
- Programmatically rewriting slug through functions.php but returns 404
- global variables in templates
- Send to different single pages by category when multiple categories exist
- Adding conditional content to single post-type template
- On single.php, fetch 2 posts created after and 2 posts created before in relation to the actual post (using menu_order)
- Get term name without a foreach loop
- Adding comments to my custom theme
- How to Manually Code Shortcode?
- Single.php Category Post Count
- How to use WP_Query() on single.php?
- Portfolio & Blog cohabitation : multiple single.php files?
- Help with a custom rewrite
- How to use single.php for creating, reading and editing Custom Posts with ACF
- How to present a div only when the index.php is accessed for/by the single post pages
- get_terms (or tax_query) for term of current post?
- Single.php the_excerpt loads same as the_content not loading read more line
- trying to show single post but displays all post on a custom post type
- Custom Post Type Specific Post Template
- How to move meta information in TwentyTwelve’s single post template?
- infinite loop on page with comments after changing comments.php and header.php
- Conflict in function to allow single post template based on category
- WordPress – When visiting a `single post/ single.php` my category menu item link becomes active
- custom wp_list_categories in single.php
- Loop all post on single.php
- Custom post type single page 404
- Different template parts when on different pages
- get_the_terms child terms for current post/custom post only
- Why custom post redirecting to index page?
- custom post type single page
- custom post type single post preview for pending status
- If is single in header.php [duplicate]
- Only show related posts when another post has same term
- DIVs not showing correctly on CPT?
- Is it better to set social media sharer in entry-footer.php or comments.php in WordPress blog?
- Custom post type single display is ommited
- Single page problem when permalink type changed
- Query child posts on parents single.php?
- Pagination issue with Single.php
- is_singular won’t call my functions?
- Single file upload
- Custom single.php files for different post formats
- Can I have a specific template for products even if they are standard posts and not CPT?
- No matching template found when using single.php