Stack Exchange Network

Stack Exchange network consists of 175 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
0answers
4 views

Woocommerce singe product custom gallery output works just on the first slide

I copied the "product-image.php" to my theme folder in order to change the HTML output a bit, so instead of using wc_get_gallery_image_html I created my function and changed the output there. Here's ...
0
votes
1answer
21 views

Contact Form 7 If Condition

I have used the following code to successfully redirect a form to an URL after submission using contact form 7. <add_action( 'wp_footer', 'redirect_cf7' ); function redirect_cf7() { ?> <...
0
votes
1answer
20 views

Getting the post terms 'wp_get_post_terms' per post when within the functions.php file

I have used a form with an Ajax action to pull post information through on submit. It works a charm. However, I have used categories to separate the work into categories. One of which is the brand. ...
0
votes
1answer
27 views

Access to “My Site” is missing from the admin bar

You know there´s a direct access to every wordpress site right on the left side of the admin bar (or tool bar) once you get access to the wp dashboard which is intended to connect your website backend ...
0
votes
0answers
11 views

Problem with Showing Download Price

There is problem to showing the download price after using Discount pro plugin. As you see in Screen Shot below when we enable showing Show discounted price? in edd settings Price didn’t shown correct ...
0
votes
0answers
13 views

How to define multiple custom field values from $post_content

I was trying to find a way to input custom field values using the WordPress iOS app (since it does not support them at the moment) and I came upon a very nice plugin called CF setter that does just ...
0
votes
0answers
11 views

Logo custom width not implementing

add_theme_support( 'custom-logo', array( 'height' => auto, 'width' => 200, 'flex-width' => true, 'flex-height' => true, ) ); and function ...
0
votes
1answer
22 views

Check if post visited first time

How to check if post visited first time? If post already never visited by nobody.
0
votes
1answer
27 views

Enqueing External JS on the remote server JS

wp_register_script( 'custom-js', 'https://s3.amazonaws.com/codexo/custom.js', array( 'jquery' ), '1.1', true ); wp_enqueue_script( 'custom-js' ); Above is the function through which I am ...
-1
votes
0answers
18 views

How to create Radio buttons on Dokan vendor new product creation page also already created pages

I am using the Dokan Multivendor Plugin. I want to add radio buttons on Dokan Multivendor New product creation page also the existing product pages. Here in WordPress wp-admin, I am adding ACF plugin ...
1
vote
1answer
46 views

Use of undefined constant bloginfo

I am a webmaster of a site which was made with WordPress. I don't know PHP. I changed PHP version from 5.6 to 7.2. Since this change, I have an error on my site : Warning: Use of undefined constant ...
0
votes
1answer
17 views

Setting custom canonical urls

I have a page that requests and displays information from a database. All is fine but I'm having some trouble setting custom canonical URLs for this single page only and its URLs (with parameters ...
0
votes
1answer
8 views

Function for Sticky Post on Categories causes issues with 404 behavior

I want to how sticky posts on category pages and I am using a code on my function.php file in order to manage it. The sticky posts are being shown on the category pages, everything is OK. But with ...
0
votes
1answer
25 views

How to redirect (301) trashed post to it's parent taxonomy TERM ARCHIVE instead of 404 page

I have a taxonomy called "Sports", that includes terms: Football, Rugby, Tennis... What I want to achieve is when (for instance) a post that has the term football is trashed and a visitor try access ...
0
votes
1answer
27 views

providing access to post_id or post inside functions.php

I'm trying to add metaboxes to the bottom of any post which is created from a specific post template. ie I don't want metaboxes on all my posts, just certain posts. At the point when I decided to ...
0
votes
1answer
13 views

add_filter function concatenate string and locate_template function

I am trying to inject a small php component to the end of my main site navigation. I have written this filter: add_filter('wp_nav_menu_items', 'add_css_switcher', 10, 2); function add_css_switcher(...
0
votes
1answer
23 views

Strip div From Excerpt

I have the_excerpt() in a specific page, I need to strip a div and keep the text, but only in the excerpt of that page. I believe I need to create a function with custom excerpt, but I don't how to ...
0
votes
1answer
25 views

add code in functions.php will slow down the Execution speed?

I put these code in functions.php to custom what I need. before I add these code,the back_end`s ttfb is 746ms. after adding,the ttfb is 3.6s !!! speed becomes slow obviously! Is there any way to ...
0
votes
0answers
46 views

How to offset main query without affecting other queries and backend

I'm trying to offset my main blog query by 3 posts whilst trying to get the pagination to function correctly. I've been following the codex reference here but I'm struggling to get it working as I ...
0
votes
1answer
14 views

Defined function isn't showed on page

I've defined a function in function.php and then I tried to call it but it's not visible when I call it. This is the function function social_sharing_buttons($content) { global $post; if(!...
0
votes
2answers
23 views

Woocommerce image sizes missing from Appearance › Customize but not declared by theme

I would like to resize the 100px x 100px store thumbnail images. The sizes are supposed to be set under Appearance › Customize › WooCommerce › Product Images These size settings are missing. After ...
1
vote
1answer
67 views

how to fix Warning: Use of undefined constant _ - assumed '_' (this will throw an Error in a future version of PHP)

Warning: Use of undefined constant _ - assumed '_' (this will throw an Error in a future version of PHP) in D:\xampp\htdocs\keuangan_rs\aksi_konten.php on line 52 elseif($aksi=="edit" AND $_POST['...
0
votes
1answer
39 views

Personalize checkout text

I would like to hide some of the text in the checkout page: billing details, Order notes (optional) and product/total row in "your order" section. I am able to remove the input fields, but I cant ...
0
votes
0answers
58 views

Plugin sub-menu pages recommended structure and links

Sorry if this has been asked before; I have been looking for a while, but couldn't find anything directly applicable. I am building my first plugin and I am trying to follow the WP best practices as ...
0
votes
1answer
71 views

Woocommerce textarea format ignored

I used the code posted by ClemC in Woocommerce add extra field to variation product with a textarea instead of a text_input. I succeeded to show my textarea under wooocommerce-default "variation ...
0
votes
1answer
66 views

ACF Date Form in Custom Admin Field

I have this function code, that brings in a ACF date picker data, and adds it to the columns view. It;s raw format is YYYYMMDD My next step is to change the format of the date to, Day Month Year so ...
0
votes
0answers
69 views

How do i Compress css and js in the WordPress from function file without any plugin? [closed]

How do i Compress css and js in the WordPress from function file without plugin? including all plugins css and js files? Like i have code which is only Compress HTML code not working for css and js ...
0
votes
1answer
29 views

Where do I implement this display of User Meta Data, and how to put it in a table?

So I have the code below that should pull the user metadata of the currently logged-in user. <?php $current_user = wp_get_current_user(); echo 'Username: ' . $current_user->user_login . '<...
0
votes
1answer
39 views

Enable right click on WordPress site

I can not right click on my site and I don't know why! Is there any function to enable right click on the site?
0
votes
1answer
83 views

How to auto-generate random numbers in username?

I have a public-viewed community site. I am able to insert First & Last Name fields in WooCommerce Registration form, and auto-generate username based on the combination of First+Last Name. But ...
1
vote
1answer
75 views

How do I create page navigation linking to each H2 within the page? [closed]

I require each page on a WordPress site that I'm developing to have page-level navigation linking to each H2 on the page. How do I best automate this?
0
votes
1answer
20 views

get_current_site() is undefined

I get the error Fatal error: Uncaught Error: Call to undefined function get_current_site() in XXXXXXXX Why is this happening? Do I need to load something before I can use that function? Is my ...
0
votes
1answer
33 views

How do I change the Search text within a search field? [closed]

How do I override the search text within the Hueman theme search box without editing any php files? I want to change the words "To search type and hit enter" to "What do I want to do?"
0
votes
1answer
21 views

How to display different blocks for mobile and desktops

I want to display a fixed banner from the bottom left of the screen. But at the same time, the banner is different for desktops and mobile devices. Please tell me. How can I determine the user's ...
0
votes
0answers
14 views

Last Page or First Page Pagination

How can I make a first page and last page link? $pagination = paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?...
2
votes
1answer
27 views

WP showing “warning: call_user_func_array()”, What to do?

I am currently working on designing my blog and am almost done but when I updated to 5.1 WordPress version in XAMPP, it started showing up this error message: Warning: call_user_func_array() expects ...
0
votes
2answers
21 views

Prevent Wordpress Automatic Logout

I am using this function which is supposed to prevent wordpress from automatically logging me out. However, I am still being logged out every so often. function my_logged_in( $expirein ) { return ...
0
votes
1answer
33 views

add referrer to woo

we just moved from Shopify to Woo and wanted to add a custom field "referrer" to an order, to track our ads. I found this article, but somehow does not manage to make it work. maybe it is a bit ...
0
votes
1answer
38 views

Overriding an Array in a Plugin's Class/Function from functions.php

There is a plugin I have installed that loads a metabox of an array ($requirements) list of items in edit post. When I print_r the plugin's array it shows: Array ( [item1] => Array ( ...
0
votes
0answers
12 views

Edit address field on checkout page

Is there any way to display my account edit address page or fields can be displayed in the checkout field so that customer while reaches to the checkout page after login/registration can view both the ...
0
votes
0answers
20 views

Handling form actions in Wordpress

A non wordpress PHP file has this kind of code: <form class="someclass" action="page-contact.php" method="post"> But when in WordPress it doesn’t work. suppose we are here(a WordPress page or ...
0
votes
1answer
26 views

How to add custom li item to wordpress menu

I have tried to add custom li to my wordpress header menu using functions.php. Here is my code in function file. function register_header_menu() { register_nav_menu('header-menu',__( 'Header Menu' ...
1
vote
0answers
16 views

How to make custom posts types display when published for the future

I'm having a hard time accomplishing two things. I've created a custom post type for Events. I would like for the client to be able to post the event by the date. This means publishing posts that are ...
0
votes
1answer
11 views

Prevent function from triggering on current page

I created a list of posts, each post about a car model. After that, I created a post about the best car models. This post grabs each post about every car model and displays them in a snippet list ...
2
votes
1answer
32 views

How to update Wordpress and plugins at specific day and time in PHP?

We use automatic updates on our sites due to having many sites and so manual updates not being feasible in the low hosting costs. But due to Wordpress or mainly plugin updates having the possibility ...
0
votes
0answers
18 views

Is it possible to intercept all ajax requests and get the parameters and the returns?

Is there any hook that always goes through it, where I can see all the requests, and also the returns after the "action" that is executed? I need to intercept all requests, including requests from ...
0
votes
1answer
15 views

Custom user role not working as expected

I've defined a custom user role in functions.php called "Dashboard Admin" with the capabilities defined below. The site has a number of custom post types- all with capability post- and I'd basically ...
0
votes
1answer
37 views

Display Data in Table from External Database in WP using Shortcodes

I have successfully coded a secondary database connection for my wordpress site in the functions.php file in wordpress. I have used the following to create shortcode and run the data to my table where ...
0
votes
0answers
24 views

echo Ajax function inside another Ajax function with foreach loop not working?

I'm really stuck with this :( I'm trying to echo function inside Ajax function with foreach loop for a list of users! To be clear: I have a list of followers/following users inside author.php, Then ...
0
votes
0answers
20 views

Using AJAX on frontend: Synchronous XMLHttpRequest deprecation except for admin role

Everything is happening in single.php. I have to validate if user has subscribed to the webinar and show login button accordingly. It's on the frontend. I'm doing this on document ready: <?php if(...