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)

3
votes
2answers
3k views

why doesnt is_home() work in functions.php

I'm pulling in scripts.php through functions.php. this is in scripts.php but for some reason, wordpress isn't recognizing is_home(). i've tried resetting the query, but to no avail. Am I hooking into ...
1
vote
2answers
207 views

How to use WordPress (PHP) functions in AngularJS partials files?

I am using AngularJS to load a list of my WordPress posts, however I can not get any of my PHP functions to work with my partials file. I've tried using something such as search.php instead of ...
0
votes
0answers
26 views

List authors by first letter with letter per page

Currently I have this working with first letter of post title with letter per page. <div class="alpha_navigation"> <div class="inner_alpha_navigation"> <?php foreach ($letters as ...
0
votes
1answer
55 views

remove_action not working, even after changing priority [duplicate]

So one of the functions in my theme is: public function job_manager_job_filters_distance() { //Show some HTML } And somewhere else in the document lies: add_action( ...
-3
votes
1answer
57 views

Error in theme check “ Found a translation function…”

I have used underscores to create a unique theme. I am getting theme errors (as identified by the WP Theme Check plugin) as follows: WARNING: Found a translation function that is missing a ...
0
votes
0answers
37 views

Fatal error: Call to undefined function wc_format_decimal() in class-wc-meta-box-product-data.php on line 996

I Get this error when trying to add a new product. If I refresh the products page, the new product will show up. I can make changes to the product information but the price never updates. It just ...
0
votes
1answer
97 views

Fatal error: Call to undefined function post_exists()

I am using the function in my own class as I am using other wordpress functions in it. I am unable to understand why it is not able to find the function while ide "go to declaration" point me to file ...
0
votes
2answers
26 views

Getting back a blank Wordpress site following functions code edit

I added some function code to the functions.php file of my child theme that has now set my entire site blank. Is the only way to get it back via cPanel and changing the theme back to the parent them ...
3
votes
1answer
1k views

Slugs as breadcrumbs for Pages

I´m trying to create a function that creates a breadcrumb trail of Page slugs outside of The Loop. These breadcrumbs show the path from the homepage to the current (sub)page. For example, on the ...
5
votes
1answer
154 views

Understanding Wordpress functions' naming conventions

Many Wordpress functions follow naming conventions, probably the most well known of these would be the the_*() functions, such as the_post(), used in The Loop. Obviously the is_*() family of ...
0
votes
0answers
37 views

Embed handler in custom field

I am trying to implement wordpress function wp_embed_register_handler() into a custom field. Using this instead of wp_oembed_add_provider(), for the urls I use do not offer oembed support. With help, ...
0
votes
1answer
66 views

Different body image backgrounds on different pages, posts and categories

I am trying to implement the ability to choose a different body background image to different posts, pages and categories. I am using Advanced Custom Fields to add an image field to every post, page ...
0
votes
0answers
13 views

function to add radio inputs that set custom fee

I'd like to add a custom fee to orders, and have that custom fee be chosen by the customer. So, under the 'Add to Cart' button, there should be a few radio inputs with set dollar amounts. By ...
0
votes
0answers
20 views

Override a __construct function in child theme

I'm trying to override a loop function in a child theme. I've tried a lot of things I found on google, but something fails, sometimes nothing change, sometimes I get a 500 error. This is the original ...
0
votes
1answer
26 views

Insert menu into theme location depending on user logged in/out status

I am using the Avada Theme from Themeforest and I have set up 2 menus under Appearances > Menu: menu-logged-in which contains a parent item (My Account) and then several child items; and ...
0
votes
1answer
24 views

custom post type does not working when adding in child theme function

I'm trying to register post type through child theme function.php but it does not working. However its working fine when i adding in the parent functions.php. add_action( 'init', 'testimonial' ); if ...
0
votes
1answer
27 views

Call to undefined function error in plugin

I wrote a function inside a class that gets a user's country from the IP address... function getcountry() { if (!class_exists('GeoIP')) { include_once("geoip.inc"); } if ...
0
votes
1answer
18 views

I want to get product attirbute in the section below

I want to add product brand and weight which i have defined in attribute of product but it am using the <?php $weightvalues = get_the_terms( $product->id, 'pa_weight'); foreach ( ...
0
votes
0answers
17 views

How do I redefine wm_navigation() or wp_logo() within a theme that uses hooks?

What I want to do: Move the title of my website from it's current location to be in the "menu" div so that it is to the left of the menu/page list. Demo page: http://aaronmoore.me/visartsassignments/ ...
0
votes
0answers
52 views

How to get last order number in Woocommerce and insert next?

I am developing an offline product to retail. This will be sold by a distributor NOT through my website. I have an sequential order reference system based on woocommerce such as 152, 153 etc. I want ...
0
votes
2answers
33 views

It does not work concatenation in function.php

I want to put a variable between two tags, but it puts him out. This is my function: (function.php) /* traer thumb */ function item_thumb() { global $post; if (has_post_format('video')) { ...
0
votes
0answers
171 views

WooCommerce - Customer Order History Pagination

I'm trying to implement pagination into WC's customer order history that can be seen on the "My Account" page using woo_pagination(). https://docs.woothemes.com/document/woo_pagination/ The template ...
0
votes
1answer
67 views

How to replace native comment_count with Comments Evolved aggregate count

What I Am Trying To DO I am using a plugin called Comments Evolved which aggregates comments that are tabbed from Faceook, G+, and WordPress native. I am trying to replace the native comments_number ...
0
votes
0answers
18 views

Add extra attributes to images via editor

Would like to allow editors to add: data-action="zoom" to image tag without them having to code it. Preferably from a TinyMCE button/menu. Example: <img class="alignnone wp-image-2438" ...
0
votes
1answer
39 views

How to list out all values from the get_body_class array

I am trying to list out all of the current page body classes. using the body_class function it gave me class="[body classes were here]" however I need to show these as plain text. I have tried the ...
0
votes
0answers
36 views

How can I make a function as sticky expired date post?

I want to edit functions.php to make a sticky post, the flow is post a post, clock will start and after 1 hours, the post will be disappear. Anyone can help me? Please. I have tried, I am really new ...
4
votes
3answers
3k views

Add class to menu items of one specific menu (nav_menu_css_class)

This code adds an extra class to all my menu items: add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2); function special_nav_class($classes, $item){ $classes[] = 'btn'; return ...
0
votes
1answer
76 views

Remove css styles from specific page

I need to remove all theme (both child and parent) css styles from a singular page using functions.php in a child theme. Here's what I'm currently adding to the child's functions.php // import parent ...
1
vote
1answer
48 views

Modify custom field input data before creating a new post

I'm try to check input data before it is added to DB. For example: I have a custom post meta named book_isbn in post page. I want to make sure that this variable $_POST['book_isbn'] is valid before ...
0
votes
1answer
46 views

How to stop or remove an action being called inside a function of an extended class

The Problem I am trying to remove an JSON+LD block being added by a WordPress plugin called The Events Calendar. I believe it is being added by the function called: ...
1
vote
2answers
379 views

Highlight Current Tag in wp_tag_cloud

I'm in the middle of building a website and one of the pages will be a glossary. The first page of the glossary will display a list of all the words, which are custom post types assigned into a custom ...
0
votes
0answers
29 views

How to send Email to Dealer email id when order is cancelled woocoomerce

I am trying to send the mail to my Dealer which user has choose during checkout that your order is cancelled . I have prepared a system to which sends email when order is placed my code is ...
0
votes
2answers
109 views

Woocommerce checkout field maxlength, make input number field only (postcode)

I've been struggling with this for a few days now. What i want to do, it to limit the Postcode/zip fields to 4 numbers. So, to add a maxlength and a type="number" to those fields. Things i've tried ...
1
vote
1answer
40 views

Is there a way to add a class to non current menu item?

When using the wp_nav_menu function, the current menu item markup usually is like so: <li id="menu-item-19" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item ...
0
votes
2answers
111 views

Wordpress can't get jquery/unslider to work [Solved]

I don't know what I'm doing wrong... I'm using the starter timber theme... I'm trying unslider to work with my theme... indicated here is somehow a proof I did right in putting scripts from the ...
0
votes
1answer
73 views

How to get post category list as select in front-end?

I use widget plugin Getting the random post & URL via ajax. I want to add function, that allows users on frontend choose category, and than display random posts from this category. function ...
0
votes
1answer
37 views

Simple JS function Not Working

I have been trying to get a simple JS function to work for the longest while but its just not working. Console says "test is not a function. echo '<input type="hidden" ...
0
votes
1answer
70 views

srcset and custom field get_post_meta and wp_get_attachment_url

I would like to use the new wordpress 4.4 function srcset with an image which comes from a custom-field like this <img src="<?php $bigimg = get_post_meta($post->ID, 'bg_file', true); echo ...
0
votes
1answer
39 views

Display Year and Month from custom field + Age Calculator

I have a custom field "DOB" on my custom post type which is in [Ymd] format. I want to compare that date of birth to current time and want to show "You are # years # months." I am able to calculate ...
1
vote
1answer
20 views

How do I customize my wordpress Admin Area?

I'm building a wordpress multisite which is aimed to serve as a blogging platform but I wanted to customize the admin area for my users by removing all the dafult widget. Please , Is there a wordpress ...
1
vote
1answer
116 views

How to pass “get_the_terms_list” as shortcode to Visual Composer Grid Builder

I am trying to create a shortcode that returns the term list inside of Visual Composer's Grid Builder. I have read the docs here. My code is as follows: add_filter( 'vc_grid_item_shortcodes', ...
0
votes
0answers
17 views

add post type support not showing edit author options for all users

Need to allow all users (admins) to be able to edit the authors of a post. Added this to my wp-admin.php in the inc/functions folder but is hasn't worked: add_action( 'init', ...
0
votes
1answer
51 views

enqueue multiple Google fonts with multiple weights and styles (italic).

I am trying to enqueue multiple Google fonts with multiple weights (400,600,700, etc,) and styles (normal, italic) and can't figure out why it is not working. This is the code that I am using in the ...
15
votes
4answers
13k views

How to customize the_archive_title()?

In my child theme's archive.php, I have the following code for displaying the title of my archive pages: <?php the_archive_title( '<h1 class="page-title">', '</h1>' ); ...
0
votes
1answer
33 views

Allow authors to post only in categories they create in WordPress

I'm looking for a way to allow users with an assigned WordPress role (in my case, author) to create new categories and then automatically be restricted to only posting in those categories or the ...
0
votes
0answers
35 views

Removing A Parent Theme Template

There is a template with code that I want to prevent the child theme from loading. All it does is load a little date box. What i've done is duplicate the hierarchy of that template file located in the ...
0
votes
0answers
26 views

wp_verify_nonce() didn't work in the function

I'm creating link with wp_nonce in GET parameter: $link = esc_url( wp_nonce_url( add_query_arg( 'my_arg', 1 ) , 'product_subscription' ) ); echo '<a href="'. $link .'">'. $link .'</a>'; ...
0
votes
1answer
72 views

Check if has any sidebar active on current page

Is possible to check if has any sidebar active on current page? Like this: @edit This function also return true even if the current page does not have this sidebar active... <?php ...
2
votes
1answer
62 views

Check if page parent has certain template

I want to check if a page has a parent with a certain page template attached to it. If I know that I can determine which scripts to load or not. Normally I would just get the page template and if it ...
2
votes
3answers
356 views

Is using eval() ok in this scenario

I am trying to include user input includes using "get_template_part()" The includes are added in the theme options eg a user inputs. get_template_part('content/block', 'branding'); ...