I was able to pass the variable using update_option(). In my archive.php
I have the following code in my loop:
<?php update_option('featuredID', get_the_ID()); ?>
And then in my functions.php
file I am using the following code to get that ID:
$featuredPostID = get_option('featuredID');
Related Posts:
- Best way of passing PHP variable between partials?
- Custom page with variables in url. Nice url with add_rewrite_rule
- Show modified time if post is actually modified
- AJAX handler throws 400 (Bad request) – why?
- How to display the_post_thumbnail if a post has one or otherwise display the first image in a post?
- How Can I Access a PHP Variable in Another PHP Function
- Most elegant way to enqueue scripts in function.php with foreach loop
- WordPress – thumbnail image from youtube (function and loop)
- Adding WooCommerce to a Custom Theme – not working [closed]
- A snippet after every image
- Function to show only first instance of shortcode
- Automatically insert php function into post $the_content
- Creating loop within functions.php
- Display WooCommerce subscriptions for user [closed]
- How to use max and min values of custom fields
- Custom Shortcode, functions PHP WP_Query loop
- Filtering posts by category name based on page’s slug
- Is it better to assign functions like get_the_id() to a variable if it’s used multiple times?
- 2 Loops, Only Displaying 1 Loop in Both Loops
- Assigning WP functions which echo to PHP variables
- Passing values from a widget to a function within a plugin
- Having a Function Inside of the Loop
- Using $themename Variables
- Getting different functions data while using while loop in wordpress
- Create a new query in function.php to filter blog posts
- Limit length of first excerpt in the loop
- Default Custom Field Value Automatically Update
- Multiple Loops Meta Data
- Why doesn’t is_page(id) work in functions.php?
- How to pass variables from a function in functions.php to an other one
- The Loop not looping?
- Define PHP variable from a seperate API if statement
- While loop with an exception after a count is reached
- problem loading stylesheets to wp_head dynamically
- How do I pull excerpts from pages?
- Output loop to function return?
- issue with if/elseif in_array inside foreach loop display only one post
- Undefined variable error in new function
- Genesis Framework: How to exclude a specific author from archive custom loop
- Problem with calling custom function in a foreach loop
- Get term slug by term id and then explode it
- Using functions.php to include code that’s processed inline
- Breaking up multiple words and inserting an image after first word
- add_menu_page() with variable function
- Simplest Way to Build Custom Archives Page?
- Do I Need to Prefix Variables Inside Functions?
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Updating custom query var with multiple values
- the_date() and the_time() functions display actual date an time instead of published date and time
- Change Page Title
- get variables data from functions.php to template wordpress (without global variables)
- How set a while with a function
- Getting value of variable from functions.php and debugging it
- How to access custom class methods from any include without using global
- Prevent function from triggering on current page
- How to use `foreach()` in ajax call
- Code executes outside of Loop while same code gives ‘Uninitialized string offset’ notice inside a while loop
- Using a variable in name of dynamically-called helper function
- Only seems to be displaying one child when there are supposed to be multiple
- Add array of category IDs to global variable?
- Setting a cookie in functions.php and it gets deleted when working on an other function
- getExcerpt: Make ellipsis appear only if character limit is reached
- Integrate WP Tiles into existing loop (index.php) and theme
- Check if excerpt is empty at loop-portfolio
- Function to get the name in database table from the comma separated string
- Using Output from one Function and calling it into another
- Way of getting queried loop before the query with a filter hook?
- Post variables not displaying correctly in custom function
- Why don’t some template tags work when querying information on single.php?
- How do I access variables outside a function [closed]
- how to handle multiple forloop?
- Parse error: syntax error, unexpected ‘endforeach’ (T_ENDFOREACH) in [closed]
- Trying to get this function to show below the content
- add variable to actions/functions across different files (woocommerce)
- How do grab the main loop, with conditions, and output via shortcodes
- Creating mixture of shortcodes to use in the visual/text editor
- Get full slug for a WordPress Post
- Update post meta with wp cron
- Does hooking into the same action multiple times drain memory?
- Different wp_mail_from and wp_mail_from_name for specific situations
- Passing HTML in WordPress Shortcode arguments
- Convert User ID’s to User Names in a single.php file
- wpautop – disable tags, keep tags
- Manipulate Permalink
- Custom Attachment Caption Fields
- How to call particular funcion when the check box is checked in plugin options page
- Events: Check for other event with same start date and category [closed]
- Not all CSS elements transferring via parent to child?
- add_filter to specific WooCommerce Category
- Need To Change WordPress Meta Tags… Includes wordpress shortcodes
- WordPress wp_dequeue_script remove all other scripts
- Add Javascript code to functions.php childtheme
- Load CSS file conditionally
- my wordpress doesn’t save items to customized widget area
- Show author bio box
- Display most popular posts
- Remove heading tags on line break
- Add custom fields after post/page title
- Sort results by name & asc order on homepage
- I want to add the alt attribute to all the photos!