A variable is a storage location and an associated symbolic name (an identifier) which contains some known or unknown quantity or information, a value. The variable name is the usual way to reference the stored value; this separation of name and content allows the name to be used independently of ...

learn more… | top users | synonyms

0
votes
2answers
25 views

Call global variable array() in woocommerce child/template

So I have this in my functions file - it defines the products that are not eligible for free shipping. It works everything is fine. //functions.php function my_free_shipping( $is_available ) { ...
0
votes
1answer
26 views

Remove HTML content if attribute is not set / variable attributes

So I'm creating a shortcode that uses the standard bootstrap carousel. It works completely fine as long as all the 3 slide attributes are entered correctly but obviously if only 2 are set and the ...
1
vote
2answers
36 views

Declaring <?php ?> in variables

I need to put the PHP <?php global $' . $icon_var . '; echo $' . $icon_var . '; ?> inside the variable of a custom menu structure, but it gets commented: <a ...
-2
votes
1answer
34 views

How to pass variable to functions.php?

I have a variable, created in page.php, and would like to pass this to a function in functions.php. Possible?
0
votes
1answer
42 views

Dynamically adding filters

I have a function that I'm trying to get an array in it to use in a callback to dynamically add filters. Here is the function that I need to retrieve the array keys from ( in the $classes variable ): ...
0
votes
0answers
32 views

How to pass multiple page ids from a custom field variable into post__in wp_query

I have a client that wants to pull content from multiple pages using page_ids listed in a custom field (363, 87, 95) without interfering with the main loop content (can't use sub-pages as same page ...
0
votes
0answers
57 views

Get WordPress Page Title, ID, or Template of the Page an AJAX Request is Made From and Pass as Variable in AJAX

I have a page template that includes a region that holds links to a series of video custom post types. Each of the links is tagged with an 'ajax-link' class so that through an AJAX request I can pull ...
0
votes
2answers
37 views

How to pass a variable for key/value pairs in an argument?

For example, this works: 'default' => '#ffffff' But this does not: $white = '#ffffff'; 'default' => $white How can I pass variables to key/value pairs? Here is a more complete example for ...
0
votes
1answer
29 views

Create a Wordpress shortcode using PHP [duplicate]

I am currently using the following code within single.php (after the_content) This gets the store_name from custom field as $merchant from the post and then returns a list of products from that ...
0
votes
1answer
21 views

Where and how to define variables for URLs etc

I have one online version of a site, and one developer version which I am working and making changes on. If I have a form with a url which the user will be redirected to: <input type="hidden" ...
0
votes
1answer
30 views

Declare global variable that can be used on other function

I have AJAX image upload function where I can get attachment_id value. I want to save that as global variable and use it in different function that sets post thumbnail when it's exist. This is what I ...
0
votes
2answers
37 views

Passing attributes to shortcode dynamically

Can I pass dynamically to shortcode attributes like as the following example shows [ authoorsposts author = get_the_author_id(); ]
0
votes
0answers
13 views

How to use a variable as key in an array at Customizer select setting

I'm trying to add a Customizer 'select' setting to my theme with the path to a CSS file as key in an array, like so: $wp_customize->add_control( 'control_something', array( 'label' ...
0
votes
1answer
33 views

How to fix Uninitialized string offset: error on a checkbox in WP Settings API

I am trying to create an options page with a checkbox field. The checkbox is working fine but when I uncheck it and save settings, an error string shows on Notice: Uninitialized string offset: 0 in ...
1
vote
2answers
27 views

Global variables during plugin activation , deactivation and uninstall operarations

For activation hooks codex states that you have to be explicit on globals: A note on variables during activation But that seems not to be working on uninstall.php If i define a global in my main ...
0
votes
3answers
40 views

Action 'init' function doesn't return variable

I have a function which checks if $_POST is set (a form which submits to the same page). I need to have it initialized before the page is loaded because the function will do a header redirect if the ...
0
votes
1answer
65 views

Validate form in functions.php, send errors back to template

I have a form in a template that upon submission should be validated, and any errors should be displayed, and if no errors, insert the data into the database. I'm new to wordpress, but my idea was ...
0
votes
0answers
26 views

passing category name from category.php to single.php

It's the first time I used WP. I just use a small portion of it, because I already had my website ready. So the only section that uses WP is the blog section. I finally was able to implement it has ...
0
votes
1answer
56 views

Define PHP variable from a seperate API if statement

I am trying to put together a function that will echo certain text based on a range of numbers. One of number(s) I am trying to compare against is echoed in my template as such -- <?php if ( ...
0
votes
0answers
31 views

Woocommerce variable filter form not working

I created a custom variable filter for woocommerce, but when i submit a form its doesn't work... Not filtering a variable selected product. (Show all product on shop page). Thanks for any help! ...
0
votes
0answers
53 views

Woocommece Variable Product Dropdown hide other two dropdown [closed]

I am using wordpress woocommerce.Here i have question about variable product for woocommece.Here in woocommerce initially all drop down options load.Now is this possible to load it based on first ...
0
votes
1answer
25 views

How to get variable from function.php to loop file

i had code in function.php file : $selective = new WP_Query($args_selective); get_template_part( $loopFile ); i cant get $seletive in my loop file. Help me pls. Thanks for any answer !
0
votes
1answer
84 views

Using ACF Custom Field value in a URL with do_shortcode() [closed]

I am using the ACF custom fields and video.js plugins and I want to add the custom field value inside the url for the youtube video that is inside of do_shortcode() So far this is what I've come up ...
0
votes
2answers
41 views

How to get variables from fucntion.php to my plugin files

I have written a function in functions.php that gets variables from a contact form and sends the inputs (and some other info like IP and location..) to my email. I am starting to work on my first ...
0
votes
1answer
273 views

How to pass a PHP $_GET variable and fetch/output it?

I've already looked at the Wordpress Codex, and looked around for other solutions online, but i still can't seem to get it working. Basicly what i need is to pass a GET variable in an URL, and output ...
0
votes
0answers
23 views

Custom Taxonomy Link Text Echo Name Not Slug

I'm a little lost about where I can place a simple php echo within a loop. I have a "program" taxonomy where each program is echoed onto buttons. Right now I'm only echoing the slugs for the link ...
0
votes
1answer
28 views

Easy reading or transfer of data from posts?

Plugin usually transfer data using code like [espro-slider id=21] , is there a short way to read it or do they use regex to read it. If not is there a short way to define variable in post and use it ...
0
votes
1answer
22 views

How can I see a varibles value when my plugin runs?

I am trying to make a plugin that redirects a user based on how they fill out a form. I am having trouble finding my problem I have narrowed it down to a small snippet that seems to work. function ...
0
votes
1answer
67 views

How to add multiple custom URL variables?

I am building a Wordpress plugin that looks for different custom variables in the URL. The way I am able to achieve that right now is with this code: function add_custom_query_var( $vars){ ...
1
vote
2answers
351 views

Echo one category as title when post has multiple categories?

UPDATED QUESTION to be CLEARER Here's my situation: Wordpress top navigation has several menu items that jump to an array of posts within a specific category. For example, if you click "necklaces" ...
0
votes
0answers
75 views

Using simple field variables within a loop

I am trying to loop a custom post type called "room" within a custom post type called "venues". I have venue pages and I have created a custom post type called room which is tagged with the venue ...
0
votes
0answers
223 views

Setting a cookie in functions.php and it gets deleted when working on an other function

My first function gets the parameters from the URL and sets the cookies: /** Get variables from the URL and set them into the coockie **/ add_action( 'init', 'set_utm_cookie'); function ...
0
votes
1answer
966 views

How to pass variables from a function in functions.php to an other one

I have a function that gets the variables from the URL (UTM): /** Get Parameters From UTM **/ add_action('template_redirect', 'get_the_utm_vars'); // 'template_redirect' - action hook that ...
0
votes
1answer
57 views

getExcerpt: Make ellipsis appear only if character limit is reached

I have a function called getExcerpt that displays the first 140 characters of an excerpt and after that, an ellipsis appears. The call in my template is like this: <?php echo get_excerpt(140); ...
2
votes
1answer
422 views

How to store the_title() into a variable to reutrn the value, not just echo it

I have a loop, and need to pass one more argument through it. I need to get the current page's single post title, and then use that as the value. I tried going about it like this: $tagz = ...
0
votes
1answer
164 views

Query Products & Store IDs in array

I'm attempting to query Products in WooCommerce and return their IDs as an array that can be used to filter conditionally. I'm using ACF Pro to add custom fields into the product, for which I'm then ...
0
votes
1answer
79 views

Pushing Category and Publish Date to Google Analytics

I have found an interesting article about tracking variables with JS based statical system (for example Google Analytics). The article writes examples like: _gaq.push('setCustomVar', 3, ...
0
votes
0answers
46 views

Best way to access variables in template markup

I am making my own mini OOP wrapper for working with wordpress themes. I have a main $settings variable that contains all of the information like definitions, scripts, menus etc.. I then pass this ...
0
votes
1answer
54 views

Where's the explanation of the TinyMCE's vars in the WP core?

I am modifying my TinyMCE editor for my users, and I'm using the example in the docs as a starting point. function my_format_TinyMCE( $in ) { $in['remove_linebreaks'] = false; ...
0
votes
1answer
92 views

get_term_link() returns correct - But illogical error-messages disturb

I've a really strange issue with Wordpress and the get_the_link()-function and a following issue with objects who are objects, but identified as non-object-error, itself they are working. First the ...
12
votes
5answers
825 views

Best way of passing PHP variable between partials?

I have a variable in header.php, such as: $page_extra_title = get_post_meta($this_page->ID, "_theme_extra_title", true); Once I do: var_dump($page_extra_title); I always get NULL outside of ...
0
votes
1answer
28 views

How do I create settings only used by my theme? [closed]

I have a theme that when installed will check to see if the necessary pages are there and if not they will be created (this is for a website not a blog). I'm trying to create settings that will be ...
0
votes
3answers
389 views

Creating Wordpress Shortcode with Variable

please forgive me I'm relatively new to PHP... I would like to create a shortcode called [city-name] and have tried placing the following code in my functions.php file: function get_city_name() { ...
0
votes
0answers
133 views

Using $wpdb->get_results with Select and a comparing a column with a variable

I wasn't sure whether I should ask this on stackoverflow so I thought I'd try here instead. I'm developing a custom plugin and I've got to retrieve some numbers from a table where the value in the ...
0
votes
1answer
303 views

Admin: global $post empty

I tried to get $post var outside function php in wordpress admin panel. The only way that I find to access to $post is to add_action. However I want to get this var outside the add_action and global ...
0
votes
1answer
84 views

How can I display a specific number of post in a category via a url

I'm trying to link to a specific category in my blog but limit the number of posts that are listed. I can link to the specific category via "www.example.com/?cat=6" and after looking around the web ...
0
votes
1answer
57 views

Editing Global Variables from Inside Functions

I'm working on my first plugin and I have two separate functions inside to accomplish two different task. Each function is added to a different hook, one using actions and the other using filters. ...
1
vote
1answer
115 views

Assigning WP functions which echo to PHP variables

I am creating a settings page. If I use the default example it works fine. <form method="post" action="options.php"> <?php if(isset( $_GET['settings-updated'])) { ?> <div ...
0
votes
1answer
47 views

Is it possible to pass variables to WordPress externally?

I would like to know if it is possible to pass json variables from a form which is located outside WordPress? This is the situation: The user fills a form located on x server. Then his answers are ...
9
votes
2answers
3k views

Passing a variable to get_template_part

The WP Codex says to do this: // You wish to make $my_var available to the template part at `content-part.php` set_query_var( 'my_var', $my_var ); get_template_part( 'content', 'part' ); But how ...