A function is a sequence of program instructions that perform a specific task. It is packaged as a unit that can be used wherever the according task should be performed.

learn more… | top users | synonyms (2)

0
votes
0answers
11 views

How to add custom redirect via parse request

I want to add custom redirect: Please tell one liner code to do : 301 redirect, 307 redirect, meta, javascript; add_action('parse_request', 'my_custom_url_handler'); function ...
0
votes
1answer
19 views

How to register a menu based on a ACF condition

I am trying to register a Wordpress menu, depending on a ACF field condition. $logo = get_field('logo','options'); if ($logo) { register_nav_menus(array( 'brand_centered_left' => __('Brand ...
1
vote
1answer
20 views

Add get_option to jquery

I have created a settings page that contains various radio button options for a custom plugin. A radio button I've created is to 'display dots' with the values yes or no. I can get use the value any ...
-2
votes
0answers
17 views

WooCommerce - How can I hook into product variation select to show dynamic content for each variation? [on hold]

my site runs Wordpress + WooCommerce and I have put together a simple plugin which I am using in my sidebar to run the standard [product_category category=""] shortcode, with get_post_meta to retrieve ...
0
votes
0answers
25 views

How can I add recent posts to menu like mashable

I would like create a mega menu that uses recent posts for hover state. Like When you hover a submenu you get a list of recent post relevant to that menu item like in Mashable. I I would like a menu ...
0
votes
1answer
44 views

What is wrong with functions.php? Fills error log with same error

After a third-party developer was used to reconnect our calendar with the Google Calendar API 3, we found that our .../wp_admin/error_log infinitely wrote: [14-Apr-2015 11:46:59 America/New_York] ...
6
votes
5answers
165 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
0answers
7 views

Detach “Add to Button” from amount specifier [on hold]

Hello I'm having trouble with my "ADD TO CART" button positioning on my wordpress page. As you can see from the picture below the button is placed under the amount specifier. I have tried using ...
-3
votes
0answers
16 views

How to change wordpress default search without plugin [on hold]

how can i display wordpress search results based on user input, users input are from and to dates from the datepicker.
0
votes
1answer
19 views

Function returning queried meta value based on current post ID

I have written several queries which sums download counts grouped by the post they are associated with, and other relations. They work great for exporting to CSV and other uses outside of WordPress, ...
0
votes
1answer
32 views

Wordpress get_post_meta issue

I'm new to php and was assigned some code to fix within a Wordpress theme, but I cannot figure it out for anything. The code is for the home page of a custom theme and it is supposed to pull the most ...
0
votes
2answers
21 views

Generating dynamic css into custom file [closed]

This is about running code on wordpress . The given code runs properly outside wordpress but when I put it on theme functions file it does not do anything. ob_start(); require('dynamic-css.php'); ...
0
votes
1answer
35 views

Woocommerce Price Text

I'm trying to show after the price of my product, whether the price is 'per person' or 'per group'. I've created a custom field for both, so for example, if custom field 'price_per_person' is ticked, ...
0
votes
1answer
30 views

Conditional read more adjustment

I get the read more link like this <?php the_content("Read More"); ?> I want on the Homepage a different text than on an archive pages. I can change the text for all read more links in ...
0
votes
1answer
25 views

How to fix blank pagination links?

I am working on a Wordpress blog that has what appears to be custom pagination for the posts. As you can see here the correct amount of links are being rendered at the bottom of the page, however ...
0
votes
1answer
13 views

get_template_directory() - references parent theme directory

I've got this line in the functions.php of my Child theme: require ( get_template_directory() . '/somecode.php' ); However it's giving me the following error: Fatal error: require(): Failed ...
1
vote
1answer
114 views

Understanding and altering the structure of posted images

Currently this is the (default) Wordpress image output: Float left, with caption, link to img <figure id="attachment_10220" style="width: 167px;" class="wp-caption alignleft"> <a ...
0
votes
0answers
28 views

AJAX login without a plugin does not work. when add a action to function.php

I am using wordpress ajax login without a plugin. I want to not be allowed users access to the WordPress profile after login, Because i have designed a specific profile in the link: ...
0
votes
0answers
24 views

ACF : Add custom field class to posts on home? [closed]

With the plugin Advanced Custom Fields i have made a custom field where i have the possibility to choose between 3 options, i would like to style the posts differently on my homepage in fonction of ...
0
votes
1answer
13 views

Writing editor content to a file

I have a project I'm working on where I need to write the content of the post editor to a physical file on the web server when a post is saved or updated. I'll be parsing and manipulating the content ...
0
votes
0answers
6 views

How to fix the warning shortcode function generated by Theme Check? [duplicate]

I searched on the internet but I still don't know how to fix it. I solved most of the the errors in WordPress Theme I am developing except for one WARNING. Please refer on complete error lines below: ...
0
votes
0answers
21 views

Create csv file in plugin

I have written a function to create csv file usin the below code.I am getting Headers already sent warning and I can't able to create the csv file too.How can I fix this problem.I have attached the ...
0
votes
0answers
8 views

Running wp_schedule_single_event on Post Import

I'm trying to have a category deleted after a certain length of time once a post has been published. I was successful in doing this when a post is manually created, but I cannot for the life of me ...
0
votes
0answers
18 views

Getting current user option within a function

I have created a new true/false field for specific user role "Member" to receive email notifications if a new post is published. For reference I'm using advanced custom fields to create a true/false ...
0
votes
1answer
27 views

Featured Image field not appearing in Custom post type

I created CPT called "Basics", then added the following code to functions.php add_theme_support('post-thumbnails'); add_image_size('large_thumb', 900, 500, true); add_image_size('small_thumb', ...
0
votes
2answers
33 views

Adding and updating repeating custom field meta data

I've got 20+ hours into this and could really use some help. Here is what I am trying to do.. For each record, add post meta. If the post meta already exists, update each field in the array. Just like ...
0
votes
1answer
30 views

widgets not working

I pasted my siderbar widget code in widgets.php file function right_sidebar_widget() { register_sidebar( array( 'name' => 'Right Siderbar', 'id' => 'right-siderbar', ...
-1
votes
1answer
20 views

trouble with passing class method data to outside function

I'm attempting to call a function using this shortcode format: [priceguide file='test.csv' type='mods'] When I do this, all I get back on the page is the file name, test.csv, and nothing else. ...
0
votes
1answer
26 views

List all post title in category using functions.php

I have search all google about this. But many of theme show the way to make a new Template Page which you can choose template type for page. But i want it directly show post title in category by ...
0
votes
0answers
27 views

Dynamically changing menu item link

Hoping someone can help me out - this has been driving me nuts for the past two hours. I'm trying to create a menu item - the menu URL should basically be: http://thesite.com/author/%username% ...
0
votes
2answers
28 views

wp_enqueue_script only works outside of action

So i've been trying to figure this out for awhile now. The following code does not seem to work for me. The javascript file will not be included in the footer ( or anywhere for that matter ) function ...
0
votes
0answers
15 views

Proper way of manipulating a category on your homepage?

I'm using the Genesis theme, and attempting to create a function that finds the homepage AND a specific category, and removes post content under both those conditions. Using my limited knowledge I ...
0
votes
0answers
9 views

custom forgotpassword and hook for additional function

I have other app and a wordpress, whenever if there is a lost password request in the wordpress, it will also trigger for lost password request and other function for the app API.. the password ...
0
votes
1answer
30 views

Warning: array_pop() expects parameter 1 to be array, boolean given

Getting the following php error when trying to add a new post: Warning: array_pop() expects parameter 1 to be array, boolean given in ...
0
votes
0answers
20 views

Create a Function to reference a certain file

Ok, so Imagine user N changes the design on settings to flat ui, the file changes to Framework/styles/flat/style.css from Framework/styles/default/style.css. How can I achieve this? This is possibly ...
0
votes
1answer
21 views

Retrieve contents/page names of various pages for use in a plugin

I'm trying to design a plugin that retrieves the contents of user selected pages and copy the contents into a giant single page. (As long single page websites are trendy right now) These are the ...
0
votes
1answer
23 views

WooCommerce -> wc_enqueue_js not working [closed]

I have a plugin that was using a deprecated function add_inline_js. I've changed it for wc_enqueue_js but it's not working. What I'm doing wrong? $woocommerce->wc_enqueue_js( file_get_contents( ...
0
votes
0answers
6 views

Why WordPress attachments LINK TO settings are not working?

Using this code below, I added some on-hover share icons for all images of the content. But, now these images are not getting any "Link To" setting from authors. I don't know what is the problem. Can ...
0
votes
0answers
15 views

Walker_Nav_Menu check if menu has parent

I created a custom function extending Walker Menu and having some few issues. I got a post from https://wordpress.org/support/topic/how-do-i-know-if-a-menu-item-has-children-or-is-a-leaf showing me ...
0
votes
0answers
21 views

How can I set and use a cookie on page load?

So I can set a cookie using the below code, and use the cookie I have created when the page gets refreshed problem is I need to set the cookie and use the cookie when the user first loads the sites. ...
-3
votes
1answer
39 views

PHP if url extension action=discussion condition use [closed]

I want use some style only for url extension /?action=discussion How can I use it by PHP condition?
0
votes
0answers
25 views

How can I include user meta information in the resulting array of a WP_User_Query?

I'm trying to accomplish some fairly complex custom functionality on a custom WordPress site. The client has an 'About Us' page that includes a list of all team members and their pictures. We're ...
0
votes
1answer
28 views

how to enqueque code in a php file from functions.php

Im building a website with wordpress, using a child theme. there is a file in the main theme folders, called entry.php that is where I need to add a bit of php at the bottom of this document. I don't ...
0
votes
1answer
16 views

Cannot access variables within a widget

I'm currently learning PHP and Wordpress development from a Java background at the moment. How do I access variables in public function Example_Widget() from public function widget( $args, $instance ...
0
votes
2answers
32 views

Use existing image sizes for WooCommerce

I've built a theme and have set the following image dimensions via functions.php: set_post_thumbnail_size( 1064, 347, true ); // Upload @ 2128(W) x 708(H) add_image_size( 'standard', 352, 235, true ...
0
votes
1answer
18 views

How to add next height number in Order Attributes inside the Add new page. [duplicate]

By default, when a new page is added it will be given the next highest number not already assigned to a page.
0
votes
1answer
13 views

Adding custom field in menu options [duplicate]

Please take a look at this image Is there's anyway I can add another field called "Font Awesome Icon" for the user to write the icon class and the output should be like this:
0
votes
3answers
44 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
1answer
21 views

WP_Query in functions.php overrides global $post object, even with wp_reset_query()

I've written a function that grabs all posts that are drafts and puts them as a dropdown in my toolbar for easy access to complete. This works just fine. The problem is that it seems to mess with my ...
0
votes
0answers
12 views

How to parse a post and change the way a gallery item is rendered?

I want to use this plugin http://final-tiles-gallery.com/index.html to display the gallery the users insert in their posts, for that I need to use an specific HTML structure so the plugin works, I've ...