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)

1
vote
2answers
43 views

Two different menus for two different locations?

I'm trying to change the menu in a primary and a secondary menu depending on the page which is visited. My primary menu is in the top of the page, and it looks like this: Index | About | Contact ...
0
votes
0answers
11 views

function 'wp_heartbeat_set_suspension' not found or invalid function name

Woke up to find this error mysteriously appear on the admin pages of my website Warning: call_user_func_array() expects parameter 1 to be a valid callback function 'wp_heartbeat_set_suspension' not ...
5
votes
5answers
10k views

How do I remove UL on wp_nav_menu?

I search on this site and found many answers for this question. Most of them is not working on my theme. Here is a one solution I found and it's working according to my need. function ...
0
votes
0answers
22 views

How set offset on query with specific post_type from functions.php

I have a page template called 'page-blog.php'. On that page I have 2 queries that both obtain the posts of a different post type like so: $posts = ...
0
votes
1answer
41 views

Add URL Rewrite Rule To Wordpress

my link http://localhost/abm/?ct_city=la-jolla&search-listings=true i want to this http://localhost/abm/USA/la-jolla Could you help please.. htpaccss file # BEGIN WordPress <IfModule ...
0
votes
2answers
42 views

is there a benefit in using a constant over get_stylesheet_directory_uri?

Is there any benefit perfomance wise when defining a constant in the wp-config.php like so <php define('PATH_TO_THEME', get_stylesheet_directory_uri() ); ?> and then referring to ...
1
vote
1answer
36 views

How to target only the front page (not subsequent paginated pages) in theme/plugin?

I'd like to switch on the front page ONLY. Not subsequent paginated pages (like ?paged=2). I want to output certain output only on the "true" front page of the site. I've tried: <?php if ...
0
votes
0answers
15 views

Function for moving a sub menu under a different top level menu?

I have a snippet that will allow me to make submenus become top level menus, but can you help with a snippet that will allow to move a submenu to be the submenu of a different top level menu? For ...
1
vote
1answer
45 views

Woocommerce - remove product from category

I'm trying to do the following, but I'm stuck with coding. Hope someone can help me out here. In Woocommerce (on the product-edit page) I can choose in which category the product will be. I made a ...
0
votes
1answer
16 views

Overwriting a plugin function

I need to write a function in my own plugin and overwrite a function from another plugin and (preferably) not make any changes to it. Or WordPress' core. So, basically, what I need to happen is: ...
0
votes
1answer
21 views

Where to put random functions?

I have functions for setting default values when a new user signs up, I have functions for performance testing, I have functions for writing out a small icon to the admin tool bar, and so on. These ...
0
votes
0answers
21 views

How to integrate a code through function

so I'm having this big issue with replacing a code with another via function. I just copy pasted an example code from the plugin developer which at the moment is unable to assist me. This is the code ...
0
votes
2answers
42 views

Adding multiple taxonomy filters to functions.php

I need to add multiple taxonomy filters to the functions.php file to remove (3) irrelevant taxonomies from the Yoast SEO sitemap index. I have been able to successfully add one filter, but when I add ...
0
votes
0answers
20 views

How to get a variable into a buddypress function?

I have a function to create profile subnavtabs in buddypress: function my_custom_subnav() { global $bp; $collection_term = 'FOO'; bp_core_new_subnav_item( array( 'name' => ...
1
vote
1answer
113 views

meta tags doesnt fetch data from permalinks

i have a page http://studyofjoy.com/categories/ i want to add custom meta tags to heading section like this: <meta property="og:title" content="<?php echo "title:" . ...
3
votes
3answers
11k views

How to add a data attribute to a WordPress menu item

I'm Twitter Bootstrap and need to add data-toggle="modal" attribute to the a tag of menu link. Upon searching most all results reference doing a walking for Twitter Bootstrap dropdown menus however ...
0
votes
0answers
22 views

Pagination not displaying

I'm using HTML5Blank theme to edit my own theme on clean basis, and trying to set the pagination but it's not displaying for some reason, and I cant find out why. Index.php calls loop then pagination ...
1
vote
1answer
687 views

How can i list current author's categories?

My Code getting authors written post categories but just 2 ID has author lists category.. I replace $current_user->ID but it is not worked. <?php $categories = $wpdb->get_results(" ...
1
vote
1answer
811 views

Conditional tag is_page with a custom post type

Accordingly to the is_page documentation, supplying the slug as an argument WP can tell me whether the current page is the one represented by the slug. Perhaps I am using the wrong slug? However I ...
0
votes
1answer
549 views

More gentle way to hook Wordpress custom url

I have written a plugin named foo, and I want when user typed url /hello and it will display the string world There is an existing post which uses the following code if ($_SERVER["REQUEST_URI"] == ...
0
votes
1answer
27 views

Add action to custom Function

I am trying to use plugin action in my custom function. Plugin is adding an action to wordpress registration form add_action( 'bp_before_account_details_fields', 'tv_bp_avatar_upload_form' ); But ...
0
votes
1answer
55 views

Option Tree integration of Custom CSS

I would love to integrate Custom CSS field from my Option Tree plugin to the code, but if I try to integrate them following way into functions.php, it ends up with Fatal error: Call to undefined ...
0
votes
1answer
622 views

function triggered by “manage_users_custom_column” filter not working

I am trying to add a custom column un users.php but it stays empty. I have successfully added a column to the users admin page with this code in my theme's functions.php file: function ...
0
votes
0answers
27 views

Call attributes from shortcode function to a JavaScript function?

How do I call attributes from shortcode function to a JavaScript function? extract(shortcode_atts( array( 'xyz' => '' ), $atts )); I want to call xyz's value in ...
0
votes
1answer
45 views

Is this an acceptable practice for WordPress theme development?

I don't think this is the right way to do things, maybe I'm wrong or missing something but to me it seems unnecessary. Is this correct? What are the implications if any of doing things this way? In ...
0
votes
0answers
18 views

Add action after function defined in plugin

I'm trying to write my second ever plugin (my first was a derivative of Hello Dolly) and I have a function that does something, however my issue is that I don't know what action to use to call my ...
0
votes
0answers
59 views

Custom taxonomy not refreshing page on add

I have created a custom taxonomy for use with WP Job Manager. The taxonomy shows up, however when I type in my tag and click the "add new job title" button nothing seems to happen. If I click refresh ...
1
vote
1answer
54 views

Check if a menu is empty?

I have menus set corresponding to a custom field on a page. Ie I have menu1, menu2, and menu3 on three pages under custom field => MenuName. Under functions.php I have: /* Add Menu Locations */ ...
1
vote
3answers
623 views

Why does `url_to_postid` return 0 when testing `page_for_posts` Page?

If I set Reading Settings > Posts Page (in other words, the page_for_posts option) to a static page, and then attempt to pass its URL through url_to_postid() it will return 0 - why is it? I ...
0
votes
0answers
60 views

500 error even after restoring to a working functions.php

While changing the functions.php file to edit who can see the wordpress toolbar I managed to return a server 500 error after the page as updating. I've since restored my backup of the previously ...
0
votes
1answer
27 views

How to change number of posts shown on homepage vs other pages?

I tried using this function but my homepage (which is the latest posts, not static) shows 5 posts -- the else. function limit_posts_per_page() { if ( is_front_page() || is_home() ) return 1; ...
0
votes
1answer
40 views

Enqueue less file not working in child theme?

In my child theme I have: add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . ...
0
votes
2answers
22 views

Add loggedout class on body using a function or JS

Is it possible to add a class loggedout on the body of every page for all logged out users using a function or JS? My theme already adds a class 'loggedin' for all logged in users.
0
votes
0answers
22 views

Add Title Field To User Profile Page

Looking to add a title field to user profile which is shown above First Name field. I can add custom fields using this code but I can't figure out how to change the position of the title field to ...
0
votes
2answers
212 views

How to arrange PHP files to allow for multiple types of pages

I am new to WordPress development (the most I've ever done on the web design/development side of things is creating basic HTML sites); so this may be an extremely simple question, but I am trying to ...
0
votes
1answer
21 views

Template code to split a post and print a custom field?

So I want a blog post but in the center of every blog post I want to split the content and print a custom field attached to the blog post type. Ie you field called "Blog Quote" and the user will ...
0
votes
0answers
33 views

is_page_template wont allow me to enqueue scripts

I want to load specific javascript files onto any page that uses the template hello-world.php below is the code that I have used to target the page, register and enqueue scripts. But for some unknown ...
0
votes
1answer
48 views

Change WooCommerce add_to_cart Button Text?

I am trying to change the add_to_cart button text for all products based on category. For category 'course' with ID 330, I would like the button to read 'Register'. For all other products, I would ...
0
votes
0answers
23 views

Is it necessary to add function.php into index.php

i am new to wordpress.. I want to add 3 different js files in index.php for this ..i have following code function.php <?php function addjs() { $dir = get_template_directory_uri(); ...
0
votes
1answer
1k views

Visual Composer creating own shortcodes with vc_map() to return simple Image

I am using the Plugin Visual Composer with in a new Theme I develop. My question is about mapping shortcodes to Visual Composer arrays. The problem I get, when I try to make a custom element for an ...
0
votes
1answer
31 views

Using catch_that_image() for galleries?

I'm currently in the process of creating my first custom wp theme, in which the post contains the title, the content, the gallery, and also a div in between the title and content where as a ...
0
votes
2answers
60 views

Add Top-Level Menu that opens URL

Below code adds My Page button in Admin Menu. It will take you to your author page when you click on it. However, it also opens up new page(Empty page). I want it to just take you to author page and ...
0
votes
0answers
14 views

Isolate Sub-Category from Top Category in WooCommerce Cart (Exclude others)

This is my first post to SOWD. I have the following function that adds custom fields for a given product category if present in the cart - in the example below, the product_cat is 123, which is a ...
0
votes
0answers
26 views

Simple modification for menu structure

I'm trying to make a menu for my website, but I want it to be easily modified through original WP menu(dashboard > appearance > menus). I want to add some small thing to the structure of my menu, ...
0
votes
1answer
27 views

Change category checkbox into radio button [duplicate]

Hi i want to change my category checkboxes into radio buttons on post page, so i can select one category at a time. I tried plugin to change it but it cause my site so heavy.
0
votes
3answers
44 views

Moving code from theme header to functions.php

Just wanted some advice in relation to adding some custom code to my wordpress site. I am using geoip to check a users country code and redirect them to the relevant site when they land on my ...
0
votes
0answers
25 views

Why isn't my plugin seeing other classes?

I've written some very simple code based off of this tutorial by Harish Chouhan on the Plugins API: /** Add Plugins API if not already existing */ if ( ! function_exists( 'plugins_api' ) ) ...
0
votes
1answer
59 views

Add caption functionality to custom WordPress theme

Hi I am working from a custom theme created by my predecessor and I am trying to add caption functionality to the theme but I am have some trouble with it. Presently if I insert a image into a post ...
0
votes
1answer
144 views

Print Woocommerce product price on cart page

I can access subtotal or total price via like this: $woocommerce->cart->get_cart_subtotal(); But I tried to $woocommerce->cart->product or $woocommerce->product->price then echo, ...
0
votes
0answers
26 views

How to retrieve value from Gravity Forms input and put it in template?

I'm trying to retrieve and input from my Gravity Forms form and put it into a template file. I know I have to use gform_after_submission but I am not sure what I am doing. This is what I have so far: ...