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
1answer
13 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
30 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
25 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
57 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
18 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
20 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
20 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
39 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
163 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
40 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
103 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
201 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
35 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
196 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
63 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
36 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
37 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
39 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
37 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 ...
10
votes
5answers
499 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
26 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
175 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
85 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
233 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
48 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
40 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
79 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
42 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
809 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 ...
0
votes
1answer
24 views

Trying to create an edit page link?

Using a plugin and have created a page that offers more fields in a spreadsheet format. To add these extra fields you simply click edit on the row you want to edit.... Now when I am in the plugins ...
0
votes
0answers
15 views

Why would one WP installation have an issue with a space in a shortcode variable?

I found a workaround, so the client site is fixed, but I don't like the fact that I don't have a cause, so I'm hoping one of you might have experienced this and know the cause. The client suspected ...
0
votes
1answer
148 views

Passing user defined variable into get_permalink

I'm trying to use a predefined variable (generated from an earlier sweep of the database) in wordpress' standard get_permalink( get_page_by_title) function. I'm assuming that this is possible? But I ...
0
votes
0answers
61 views

Pass variable to next page

I'm putting simple breadcrumbs in a site, based on a custom post's category. Items > Category > Individual Post "Items" doesn't change, it's just plain text. In the Category page it's title is ...
0
votes
2answers
70 views

Global Variable vs Local Variable

// MOVE REVISIONS METABOX TO BOTTOM OF EDIT-FORM.PHP $post_types = get_post_types(); add_action('do_meta_boxes', 'batteryboys_reorder_meta_boxes'); function batteryboys_reorder_meta_boxes(){ ...
0
votes
1answer
160 views

how to add number value in front for variable [closed]

Hi there my question is very simple, is there a way by which we can add a value in the end of the variable a numeric value. like we have a variable $tota $tota1 $tota2 $tota3 each have different ...
0
votes
2answers
598 views

Passing PHP Variables to AJAX Loaded Pages

I have a blog that shows 9 blogs posts per page, with each additional page of blog posts automatically added using the Infinite Ajax Scroll plugin. Every time a blog post is successfully queried the ...
0
votes
1answer
30 views

Class variables in shortcodes

Don't know what I'm doing wrong but, I have the following code: class the_shortcode { //Define Class Variables private $var; public function __construct() { ...
1
vote
1answer
100 views

Add classname comment template from functions.php

I want to add an extra classname to my comment template (the div wrapper before the post itself) which is stated in functions.php. The classname in functions.php is an extra field in my users profile ...
3
votes
2answers
294 views

When to use global $post and other global variables?

I am trying to understand when and why I should use the global $post variable. I have tried to do the following on a post page, outside the loop, and as expected it works. <?php ...
0
votes
2answers
142 views

Shortcode not passing variable to included file

I set up a shortcode which includes a standard php/html form file. In the form I have a hidden field where the value is a variable which is meant to be available in the form via the shortcode ...
0
votes
1answer
34 views

How can I assign bloginfo path or thumbnail path to a variable and call it in markup?

In my head this sound right. I check if the post has a thumbnail. If it has, I assign the post thumbnail to a variable that I call as the source for my background image. If the post does not have a ...
0
votes
0answers
123 views

setcookie in functions.php does not accept arguments (variables) passed from WordPress page

I have a WordPress installation where a page (Page 1) displays certain fields from a selected user's profile (Not the logged in user but a user they have selected). A PayPal button is used to take a ...
-1
votes
1answer
181 views

Enter a variable in the 'category_name' parameter

Is it possible to use a variable for the 'category_name' parameter? I have three pages: red, yellow, and blue. I have multiple posts that are categorized in three categories: red, yellow, and blue. ...
0
votes
0answers
32 views

stuck in $args value insertion how to pass more than one value

I am in a middle of building a plugin and some how I manage to limit profiles to show only with the users with role regular_user by putting this line in my code $args['role']='regular_user'; ...
0
votes
1answer
94 views

Adding to an array & passing it through do_action/apply_filters

For exercise I am working through a PHP class to add meta boxes I found on GitHub. I just copied the code and now I am playing around with it to understand it. It works like this: The file ...
0
votes
1answer
59 views

Can I get variable into dynamic sidebar?

How can I get a variable into a sidebar? $sidebarnum = 4; dynamic_sidebar('Footer Widget $sidebarnum'); ?>`
0
votes
1answer
38 views

Replacing string with a variable in php

I have following code in my plugin of Wordpress: wp_localize_script('ffd_js_script', 'myAjax', array( 'ajaxurl' => admin_url('admin-ajax.php'), 'idinfo' => ...
0
votes
1answer
327 views

Variable scope producing undefined variable notices in included files

I'm building a Wordpress Theme and on the front page the user is able to select how they would like to order their posts. I've then created two functions that take the users selection through the ...
0
votes
0answers
97 views

passing javascript variable into php wordpress

I am trying to pass variable from JS to PHP. I have this JS code that runs in my footer.php: <script> function printResponse(response) { if ( response.errorCode == 0 ) { var ...
0
votes
1answer
336 views

Cleaner way to define multiple variables for is_page_template()

I need to so some stuff only when specific templates (homepages) are used, I couldn't think of any better solution than this since is_page_template() do not handle arrays: $home_1 = ...