Tagged Questions

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

-1
votes
1answer
38 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
23 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
31 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
18 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
21 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
37 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
32 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
78 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
60 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
36 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
85 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
16 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
86 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
233 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
70 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
102 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
178 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
32 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 ...
0
votes
0answers
45 views

Working with arrays/foreach statements - echo results? Addition operator w/foreach… multiplying?

I'm really struggling with this - I'm relatively new to PHP but I'm trying make this code that I've pulled together output a list of chapters sorted by user pageviews based on a user_meta field called ...
1
vote
2answers
116 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
47 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(), ...
0
votes
1answer
183 views

How to append a query string to pagination?

I would like to append 2 variables from page 2 onwards in my loop. This is my normal category page www.example.com/category/news/ This is what I would like on pages: 2, 3, 4, 5 etc ...
0
votes
0answers
244 views

Passing variables through a href link from one page to another page

On my registration site I have a CPT called "event". In my "Events" page I list these events and create a "register" link for each one towards the "Registration" page: $events = new WP_Query( array( ...
0
votes
1answer
86 views

Shortcode and variable

I need some help, this may be a noob question, I am trying to add a string variable into my short code. Here is what I have so far: $instagram_title = get_post_meta(get_the_ID(), 'instagram_title', ...
0
votes
1answer
21 views

Remove # from a Variable [closed]

I am using WordPress WooCommerce plugin as a store management. When I echo with <?php echo $order->get_order_number(); ?> I get #6453 as a result but I need only numbers so how do I strip out ...
1
vote
0answers
23 views

How to return Javascript variable to wordpress [duplicate]

I use this Javascript code to create a dialog box to ask some thing to user and after decide what to do depending of the response. function dialogToCont() { var retVal = confirm("Do you want to ...
1
vote
2answers
99 views

Access the environment of an admin page from another admin page

I've been busy thinking about a problem, and so far I didn't find a solution to it. The abstract scenario On admin page A, I would like to print the value of a (global) variable—in the context ...
0
votes
1answer
386 views

How to pass post title (which could include &) to Gravity Form

I have created a form (Gravity Form) which I want to be able to complete dynamically from several of my other websites. In such a case, one of the fields that I am trying to send to the form is the ...
0
votes
1answer
16 views

Incorrect Blog Root

I have a blog at http://leghumped.com which I moved from a subdirectory to the site root a few months back. The problem is, the root still seems to resolve to /blog/. Eg: Instead of seeing ...
2
votes
1answer
49 views

How do I know what variables are passed in a filter/action and what their meaning is?

Something I have seen several times now and I don't understand is the following: In a theme's functions.php a function is defined and then attached to a hook, like so (simplified example): function ...
2
votes
2answers
83 views

WordPress filtering utm_ GET variables from url unless logged in as admin, not sure why?

So I am having an issue where I can't pull variables such as mysite.com/?utm_campaign=testing unless I am logged in as admin or editor. When logged out and just a regular users I can't grab any ...
0
votes
1answer
606 views

Passing variables through permalink structure in custom post types

I'm having a real headache with this one, and not sure what to try. Basically, I'm building a website with a custom post type of 'charities'. There are many charities listed, we'll use RSPB as an ...
0
votes
0answers
110 views

Create and update Custom Cookie based on multiple GET and POST Values for first time visitors?

I am not exactly sure the most efficient way to write this code. I collect custom data in my forms and also in my url via get such as: Name utm_campaign URL Referrer ID Among many more. Do I ...
0
votes
0answers
109 views

global variable not accessable inside functions

I downloaded and installed a wordpress plugin. Everthing works fine on localhost untill i uploaded the site on live server it wasn't working as intended. When i define a variable as global its value ...
2
votes
1answer
193 views

Using Wordpress public query variables

Good morning. I am trying to query various Wordpress pages, using public query variables, for example http://dmkim1979.ru/?p=37 // single post http://dmkim1979.ru/?page_id=40 ...
1
vote
1answer
126 views

Can wp_list_comments output into variable?

Is there any way how to output wp_list_comments() into a variable? Something like $output = wp_list_comments(array('reverse_top_level' => false ), $comments); I am writing a plugin and it would ...
1
vote
1answer
1k views

Use of global variables within plugin [closed]

I am creating my first plugin ever and I found my self having to call the same option variables within various parts of the same page therefore I sought for a solution and stumbled upon global ...
1
vote
2answers
323 views

Passing values from a widget to a function within a plugin

I have a plugin that is built with many widgets. A widget's bundle. Each widget creates it's own custom CSS code. Instead of having messy source code where I display 15 different sets of inline CSS ...
0
votes
2answers
389 views

WPDB SQL query with prepare() returning variable, not db value

I have been trying to get this to work for awhile now and I cannot seem to get any farther on my own. It seems to work fine as a normal SQL query but not within the WP framework using prepare(). ...
0
votes
1answer
25 views

Variable not staying set

This is most likely just a PHP problem, and it's probably a pretty simple answer, but I just can't seem to get my brain to function this morning. This is what I'm trying to do: $job_file = ...
0
votes
1answer
32 views

Storing state between hook functions

I have two functions which I'm hooking into a plugin. Both functions are called (at different times) during a single page creation by the server. I want to set a flag in function_a which can be read ...
1
vote
2answers
150 views

Putting PHP variables into javascript [duplicate]

I've created a simple theme options page for my site. The options page contains three input fields. I can output the the fields by using get_option. The three fields are called using the following: ...
0
votes
2answers
461 views

Passing parameters to a static front page

I have googled a lot, but so far haven't come close to a proper solution yet. I need help with passing parameters to the homepage of a WordPress website. Here's my setup / requirements: I use a page ...
1
vote
1answer
419 views

What is the best way to store custom variables

I need to store the id and secret key of my FB application. I don't want to write them directly in my template. What do you recommend ?
0
votes
0answers
90 views

Passing user first and last names from external db to WordPress user first and last names using session variables?

This may be a little convoluted, but here it goes. I don't let users register on WordPress to access my member site. I have an outside registration/login system set up and want to continue using ...
0
votes
1answer
172 views

Custom post type archive page for multiple post types

Hi I am working on a archive page which I can use for multiple custom post types. I need to make a variable in the $args array which can change to the post_type name on the basis of <?php ...
0
votes
1answer
510 views

How to create custom variables in the wp-config

I would like to add some custom config variable in the wp-config file (not in the functions.php). Then, I need to access to these variable in my templates. What is the way to do it ?
1
vote
1answer
465 views

How do i calculate the total of values of custom fields in custom post types?

So the title is a bit unclear, but here is what i have: Custom post type: Projects Custom post type: Investments        + Custom field: Amount And i have one page ...
1
vote
1answer
126 views

how to put a custom field value in variable

function zh_get_invoice_round_off_number() { global $post; return get_post_meta($post->ID, 'invoice_round_off_number', true); } function zh_invoice_round_off_number() ...
0
votes
1answer
135 views

Intercepting $_GET variable from custom pagination

I have a custom pagination using a form with the get action so I can have a page jumper box. Everything works until you enter something that is not an actual page. Examples are negative numbers, text ...