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
18 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
101 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
20 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
41 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
53 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
18 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
94 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
33 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
26 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
33 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
31 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
23 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
373 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
84 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
49 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
194 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
30 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
31 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
64 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
41 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 ...
7
votes
2answers
471 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
18 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
14 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
98 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
53 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
57 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
116 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
535 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
27 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
90 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
153 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
100 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
29 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
100 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
126 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
31 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
75 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
55 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
31 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
289 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
76 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
287 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 = ...
0
votes
2answers
101 views

How to add chunk of php, html, and sql code to variable an append to $content

I am creating a plugin (my first) which allows the site admin to display the most used post tags over the last X number of days. This plugin is an evolution of the WP Development question here - ...
0
votes
1answer
89 views

$before/after_widget/title not displaying anything

I have built a custom widget with this code: class rfw_dock extends WP_Widget { function __construct() { parent::__construct('rfw_dock', __('TITLE'), array( 'description' => __( ...
0
votes
1answer
1k views

Passing variables from header.php to template and vice verca

I've defined a variable - let's call it $header_var, which is placed in the header.php file. I would like this variable to be passed onto my template file (in this case taxonomy.php). Also I would ...
0
votes
2answers
224 views

Print string to footer using wp_footer option

add_action('wp_footer','slider_option'); function slider_option() { $option ="<script>script function data </script>"; echo $option; } I want to print or ...
0
votes
1answer
514 views

Passing variable as permalink URL

I've been trying to adapt the rewrite functions described here with little success: Passing variables through permalink structure WordPress permalinks and custom $_GET Variables The structure of ...
0
votes
1answer
135 views

Current URL path variable

WordPress has a built-in variable $pagename that will give the current page. I am looking for something that will give the full url including the path before the current page. Details below. I am ...
0
votes
1answer
239 views

Widget checkbox array empty on update function

I have a widget that is not passing checkbox state to $new_instance, specifically $instance[ 'posts' ]; if I dump $new_instance in the update function it is empty? All the other instance variables are ...