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
14 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); ...
1
vote
1answer
52 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
16 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
17 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
24 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
24 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
14 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
324 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
24 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
55 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
31 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
157 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
24 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
26 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
42 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
38 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 ...
6
votes
2answers
281 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
16 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
13 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
74 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
47 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
53 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
80 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
485 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
25 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
77 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
107 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
88 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
24 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
92 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
99 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
28 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
67 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
50 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
29 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
247 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
64 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
258 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
97 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
82 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
997 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
0answers
26 views

wp_localize_script() dont parse values

I try to parse php values to js file using wp_localize_script() wp_enqueue_script( 'countdown_js', plugin_dir_path( __FILE__ ) . 'js/countdown.js', array(), '1.0.0', true ); $dataToBePassed = ...
0
votes
2answers
190 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
472 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
121 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
215 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 ...
0
votes
1answer
333 views

Variable undefined but it is defined

I have an author list that I include on every page template. This author list shows the authors details and photo. I also show the author images on many different place on the different page ...
0
votes
1answer
39 views

Declaring a var, placing it in a query and using the output of the query?

So i'm wondering if it's possible to declare a variable that you'd place in a query to then use it in a update_post_meta function? This is how I tried to do it. First off I made a connection to ...
1
vote
2answers
159 views

Using Multiple Queries of “home_url” vs. Calling a Variable Multiple Times

Question Since I am using multiple instances of home_url() in one page template, I was curious if the following method would speed up my page load time. My method is to store the output of home_url() ...
0
votes
1answer
53 views

How Does One Create a Global Variable Repository

This may have a simple answer but I would like to store all the variables I've declared ( or cached ) across my theme in a central file and serve then this file globally ( Similar to how get_header(), ...