Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [functions]

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.

0
votes
1answer
43 views

Create New User Custom Field not Saving

I've added a function to my child-theme to add a new field in the Add New User section so that you can select if the member is either just a member or candidate etc : function ...
0
votes
1answer
16 views

Do I need to use wp_reset_postdata for my function?

I am using this function which seems to work fine, however I was wondering if I must use wp_reset_postdata after endwhile? function evecal_task_function() { $args=array( 'posts_per_page' => -1, ...
0
votes
1answer
21 views

custom post type column countdown

i have registered custom post type and i have created custom columns for it one of those columns is count down it's functionality to cut the NowTime from the custom meta date and time i have set ...
0
votes
0answers
28 views

ajaxurl usage for a custom function

I am creating a custom form in one of my paste and its getting submitted using AJAX post method. Here is my code: HTML for button : <button onclick="result()" type="button" name="result_submit" ...
0
votes
0answers
22 views

Wp_schedule_event functions.php

I am using this code in my functions.php which works fine. However, I was wondering if this is the best practice to do so to schedule an event, or if there is a better solution. if (!...
0
votes
0answers
31 views

Woocommerce endpoint titles in my account template

I am working with woo-commerce user dashboard template. I need to print the title of current endpoint instead of the_title();. following image snapshot of DOMIAN.com/my-account/orders/. there should ...
1
vote
1answer
39 views

How to display post content instead of excerpt

I am using a plugin, and to get around something I need to add some text to the excerpt field on my posts, but I don't want to display the excerpt field data on the front end, but rather the post ...
0
votes
1answer
32 views

How to add styles in existing function?

The goal is to add some internal styles to a function. The function has some if statements, and then it does: $content .= " <div> <h3>stuff</h3> <div>$additional_stuff&...
1
vote
1answer
33 views

Two Types of settings in WP - The Doubt

I was trying to learn some basics of wordpress plugin development, and I stumbled upon two types of settings. 1 add_settings_field( 'custom_title', esc_html__('Custom Title', 'myplugin'), ...
0
votes
1answer
23 views

deactivating an active plugin using if page

Good day! just wondering if you can help me out? I was trying to create a code for functions.php if the user currently lands on a specific page, thus the plugin will turn deactivated, but if the user ...
1
vote
1answer
28 views

Add function to every post?

I have some code that generates a dropdown list of all my post files. I would like to add this dropdown to the top of every post page, right before the post content. What's the correct hook/action ...
1
vote
3answers
30 views

Using separate .php file for functions - how to run on site?

Instead of bogging down my child theme's functions.php file, I would like to have a separate .php file that has various functions, that I can call within functions.php (and in other files). I have ...
0
votes
1answer
24 views

Hook into all password resets in Wordpress and get password before hashing?

I'm syncing my Wordpress authentication system with an secondary/external authentication system and my site has at least two ways of resetting the password, including: Password reset email User ...
-1
votes
1answer
23 views

how to handle multiple forloop?

I have and order_id as array but wc_get_order accepts only one id at a time how to loop through order_id and let the list of item id and item name? i am using this inside a class. it works fine if ...
0
votes
2answers
27 views

Control the srcset much more (not all sizes in it each time)

I'd like to be have more control on the srcset on certain important images of my website if not all. By default the srcset includes all the sizes created by wordpress for all the images. I'd like to ...
1
vote
1answer
37 views

Use wp_get_recent_posts with search term

I have a function that uses wp_get_recent_posts() I need to use this same function on my search page but am having problems adding the search parameter to the $args array. Does anyone know if this ...
0
votes
0answers
17 views

Widget PHP code isn't working

So I have a custom post type, and a php code widget that is connect to said post type and updates every time there is a new post in that type, but it's supposed to redirect when the display on the ...
0
votes
1answer
19 views

I want to change the Wordpress comments file

In the standard structure of Wordpress, a warning page appears when the user makes spam or goes too fast. The link structure of the warning page is "/wp-comments-post.php". Briefly (see images) https:/...
0
votes
1answer
46 views

Run shortcode in custom script in wp_head if post type is CPT 'Jobs'

i am using genesis framework and types plugin. i create post meta fields for a custom post type name 'jobs' i want to run a custom javascript named jobpostingschema.js in wp_head if post type is ...
0
votes
0answers
16 views

Keep Admin Logged In For a Year

I would like to keep the admin account logged in for a long time, such as a year. I am using this code: add_filter( ‘auth_cookie_expiration’, ‘keep_me_logged_in_for_1_year’ ); function ...
0
votes
0answers
35 views

Need help displaying custom labels before prices in Woocommerce

Good Afternoon StackExchange; I am needing a bit of help on figuring how the proper php code to achieve the label set up on various products throughout my woocommerce store. Basically what I am ...
0
votes
1answer
56 views

Wordpress function, Run using Crontab

I have disabled cronjobs on my nginx server, as it is better to run from crontab. define('DISABLE_WP_CRON', true); How could I run a custom wordpress function using Crontab, once per day? This ...
2
votes
2answers
53 views

Problems with function on function.php

I've a problem with some functions on function.php. I want to use get_tems_by("slug", $slug, "category"); but it doesn't work inside a function on function.php. When i changed slug by ID and give a ...
0
votes
0answers
11 views

How do I display a random “custom post” that will last for a specified amount of time without repeating content?

I saw someone else's question, but it was posted over seven years ago, and I am not very savvy about changes that may have occurred that would render the solution useless. I have several different ...
0
votes
1answer
31 views

what is `get_section()` and how to use it?

i saw get_section() being used in WordPress. what is this function and how can i utilize it for theme development?
0
votes
2answers
33 views

Redirect to other page if login

I have a home/static page with login button. Currently I've set the button url as "http://example.com/login" How can I set the login button to redirect to a specific page IF/WHEN the user is logged ...
0
votes
0answers
34 views

How can I get my pagination loop to display the correct number of total pages?

Currently my pagination is showing 7 posts on the first page and 6 on each page after. This is what I want. The current readout looks like this: . The total count of my pages changes as soon as I ...
0
votes
0answers
12 views

Woocomerce .html end product error

need help, I added .html end at WooCommerce with function at rewrite. And now all, ok, but when clicking at product I got error 404,not found, example: http://ozrubai.lt/parduotuve/vyriskas-dzemperis-...
0
votes
0answers
11 views

get video poster image by video id

Using wp_query i got list of videos. All videos have their own poster images. How to get them? To make sure video exists i tried function wp_get_attachment_url and i got video url and its correct. ...
-1
votes
1answer
11 views

How to test for a class (from a plugin) in functions.php

I've added various code changes to functions.php. Many of them depend on certain plug-ins being active, as they refer to classes defined by those plug-ins. If the plug-ins are disabled, it will cause ...
0
votes
2answers
27 views

What is the fastest way to load PHP functions that are only used in one theme template?

I've developed a lot of PHP code snippets for my website, and I'm not sure where would be the best place to put them in order to reduce site loading times. If they go in functions.php or in a ...
1
vote
0answers
15 views

Move 'current-menu-item' class on #adminmenu li from Posts to Pages for Taxonomy Edit Screen

I've created a custom taxonomy called 'venuecategory' that is hidden by design(not attached to a CPT and does not appear in admin menu). When I'm on this taxonomy's admin page ('wp-admin/edit-tags....
1
vote
0answers
267 views

WooCommerce: How can I get orders with a custom ID in order meta data object?

Because of a project I need help from you. I've searched a lot but I can't find a solution. I'm trying to edit a WooCommerce function named woocommerce_account_orders I've added the field ...
0
votes
0answers
27 views

How can I use an array of objects with multiple PHP functions?

I'm a bit stuck with my PHP to make something work for a WordPress site that I am developing. What I want to do is have an array of objects pertaining to social networks that I can pass through ...
0
votes
0answers
17 views

help setting post to private

have this piece of code and it works great. I can create a shortcut like so .. http://example.com/site/wp-admin/post-new.php?post_title=Journal&category=Journal And it sets the title to journal ...
0
votes
1answer
41 views

Override plugin function to show invoices even if not logged in

I am using WooCommerce Print Invoice plugin to print invoices. Now I am working on a Cordova app for my website and I need to be able to see invoices from wordpress. Plugin has a function to hide or ...
0
votes
0answers
123 views

get_field() with ID in one signal filter not working

I am trying to get_field() using post id in one signal filter, I am getting the value of post id. But for some reason note getting the values of get_field(). I have imported wp-load, but still didn't ...
0
votes
1answer
98 views

How to speed up admin-ajax.php in wordpress

I have some code on functions.php that I call via ajax on frontend, I'm using admin-ajax which takes about 2 to 2.5 seconds to load since I have many plugins and that ajax handler need to load all wp ...
0
votes
1answer
30 views

Create dynamic logo carousel without using any plugin

I am converting an html template to a WordPress theme. In the WordPress theme development process I'm stuck at dynamic logo carousel. Can anyone tell me how to create a logo carousel dynamically ...
0
votes
0answers
13 views

Inserting shortcodes via functions.php

My question has two parts. I have several shortcodes which are for email capture forms which are geographically specific. I'd like for these email capture form, i.e. shortcodes to appear ONLY on ...
0
votes
0answers
40 views

Display Google AdSense Ads without a Plugin, question if this is correct?

I don't want to use yet another Plugin to do something which ought to be very simple. I am trying to create a shortcode which will display my Ad Code. I found this online as a suggestion: // ...
0
votes
1answer
140 views

400 Bad Request - JavaScript App calling Custom wp-json endpoint

I have successfully created a new endpoint/route and can view it via wp-json. Not only that, I can successfully make a post request to this endpoint externally from the browser using the Restlet ...
0
votes
2answers
57 views

The Loop not looping?

After much troubleshooting and searching, I think I finally understand how to get The Loop going. Except I can't seem to get it to actually loop! I have created a Child theme, and added a functions....
0
votes
1answer
25 views

Configuring default woo commerce login with modal popup

Good day. I was trying to configure the default woo commerce login page. I want to add the two contents (login) and (register) to a modal popup separately. let's say if the user is not logged in and ...
0
votes
1answer
85 views

How to change form action of wp-login page with a function

I'm manually creating my own Wordpress login form. The action parameter of all the forms points to wp-login.php. I want to change it for all of them to custom url (/login). Any idea how to that? For ...
0
votes
0answers
22 views

Cannot access wp-admin but can authenticate frontend login

I have a custom function which is based off the wp_login_form(). I copied the function and essentially wrote it to add in two new fields to validate against - "mbjbookdomain" and "mbjbookreference". ...
1
vote
1answer
45 views

Get_avatar filter?

I'm trying to display something below avatar in comments. How can I filter this ? Sorry I'm a newbie with Wordpress PHP development. In comment.php of my child theme I have : wp_list_comments( ...
1
vote
1answer
23 views

Combine two different filter callback functions

I am currently using this code which works fine. function add_data_attribute($tag, $handle) { if ( 'chargebee' !== $handle ) return $tag; return str_replace( ' src', ' data-cb-site="...
0
votes
0answers
24 views

Get Billing Email from WooCommece Checkout and Pass to Fullstory JS

I'm using WooCommerce on WordPress where I've integrated Fullstory snippet in the header of my site. I've enabled checkout for guests, that is, they can check out without creating an account on my ...
0
votes
0answers
36 views

Get posts by id using shortcode

I am trying to get posts by id using shortcode [testimonials id="272"] in functions.php file. I used the below code it is working but not able to get posts by id. Can anyone help me with this issue if ...