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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
26 views

calling a custom field value inside functions.php

I am creating a function, for a shortcode that I will use directly in the post content (using [my_description_number] shortcode), and it works, but I do not manage to call (echo or print) a custom ...
user avatar
  • 165
0 votes
0 answers
14 views

Create a pdf from the entries in DB

I have a website containing details of certificates and I want to create pdf files for each certificate using the id. The process I want is: The user enters the id of the certificate and a page should ...
user avatar
0 votes
0 answers
22 views

WordPress User Meta value variable into Google Gauge Chart

I am trying to insert a Google Gauge chart on my WordPress site created with Elementor using data from WordPress user meta (current logged in user). Using the code below, the chart is displayed with a ...
user avatar
0 votes
1 answer
35 views

How to hide WooCommerce product title and short description to non logged in users?

I am using this code for hiding short description to logged out users but it does not work - it shows the message asking user to login but it still shows the short description. add_filter( '...
user avatar
  • 1
0 votes
1 answer
20 views

Enable taxonomies by post type in an array of CPTs

I learnt to add multiple custom post types via functions.php in an array, like this: add_action('init', 'all_custom_post_types'); function all_custom_post_types() { $types = array( array('...
user avatar
  • 29
0 votes
0 answers
15 views

Create a CUstom Archive by Year, but just for a Single Category

I have a request from my designer to create a list of links to a page that only shows posts published by year and that belong to a specific category. So here is the design: I've found a function that ...
user avatar
  • 1
0 votes
0 answers
22 views

How to loop while adding data to database?

I've made a code in functions.php file to add data to database from select form but the data inserted in the database is the last option from the select only not all the data. so I'm trying to add all ...
user avatar
0 votes
2 answers
33 views

Use html inside shortcode function

I know I'm bad with coding, but I tried whatever I could find on the internet, and I ended up with this, which is not giving an error, but also when using the shortcode [my_playlist] in a post, only a ...
user avatar
  • 165
0 votes
2 answers
76 views

What is the best way to define constant options for a theme?

By constant options I mean properties of the theme that don't change during every day use in production, but are changeable by the developer primarily for reusability purposes. Things like custom ...
user avatar
0 votes
0 answers
35 views

Add a Metabox checkbox to the Page Edit screen of wp-admin , which only certain roles can see and Makes only certain roles able to Edit said page

UPDATE Please Read Past my Phases to see development and new questions! Currently on Phase 3 PHASE 1 - resolved so far Ive tried to code it myself, and Ive added this into functions.php, but there is ...
user avatar
  • 1
0 votes
1 answer
232 views

If ACF field is empty show different value [closed]

I have a function setup in my functions.php file which I am trying to use to show a Advanced Custom Field with a fallback value if that field is empty. Here is what I have so far: add_filter( '...
user avatar
0 votes
0 answers
24 views

Override a Post's URL with Advanced Custom Fields Function

I have a field on specific post pages which allows the user to create a new link to forward the user to a completely new URL (this is so it still appears within the filtering of Post Content and has a ...
user avatar
  • 1
0 votes
0 answers
73 views

How to upload large media file in chunks, without any plugin?

How to upload large media file in chunks, without any plugin ? I have done something like this, it's uploading the file, but after uploading the media file, the uploaded file is not visible in media ...
user avatar
  • 13
0 votes
0 answers
158 views

Jetengine Forms - Media upload path

Need a piece of code in functions.php that redefines the path Jetengine Form saves media files to... Ideally into the following path AND with another meta field entry in the path. /wordpress folder/...
user avatar
1 vote
1 answer
27 views

How can I remove the main description text box in a Woocommerce product editor page? I only use the "Product short description" text box [closed]

The main description text box which shows up right below the Woocommerce product title seems to not be able to be disabled within the Screen Options dropdown menu. It also can't be moved around, ...
user avatar
0 votes
0 answers
24 views

how to validate input field in wordpress generated with wpform plugin

I want to add a function to my registration form, which allows to validate one of the fields which is the following: REFERRED BY. example: if the user "Stack" refers me to the platform I ...
user avatar
0 votes
1 answer
44 views

WordPress redirect redirecting too many times or not at all

I am new to WordPress. I am trying to simply redirect users to a login page if they go to the account page without being logged in. I first tried adding this code to the functions.php code: add_action(...
user avatar
1 vote
0 answers
38 views

Change the WP Video Shortcode Output

Is it possible to change the structure of the WP video shortcode output that's displayed in post editor after selecting a video from media library and adding it to a post? I'm trying to change the ...
user avatar
0 votes
0 answers
14 views

Checkbox doesn't save inside metabox

I have a repeatable fields metabox which includes a checkbox input. I have an issue when saving the metabox in the admin. The checkbox value doesn't save. Here is the PHP code: <?php add_action( '...
user avatar
0 votes
0 answers
12 views

How would I get the new plugin version on this function?

I created a function to create a "Changelog" for every time I update a plugin on our site. As some things can break, I figured it would be useful to be able to backtrace what got updated ...
user avatar
1 vote
0 answers
36 views

Show categories then when clicked on a category list all sub category and when clicked show all posts in that sub category

Show categories then when clicked on a category list all sub category and when clicked show all posts in that sub category function cc_showcountries_all_cats() { $taxonomy = 'countries'; $terms =...
user avatar
1 vote
1 answer
22 views

remove wp floating submenu in wp dashboard

i successfully done making the menu name to be collapsed on click , but i have a problem with the floating submenu that appears on hover on menu name , i need to make this floating submenu to be open ...
user avatar
1 vote
1 answer
36 views

How to put "Read more" link in Custom Excerpt inside p tag?

I have a piece of code that extracts the first paragraph from the post, enclosed in a p tag. I want to add a "Read more" link inside the p tag referring to "the full post". Please ...
user avatar
0 votes
0 answers
42 views

Change WooCommerce Payment Options From Radio Buttons to Dropdown Menu

I would like to have my WooCommerce payment options displayed as a drop-down menu rather than radio buttons within Checkout, but can't figure out how to do this and can't find any plugins to do ...
user avatar
0 votes
0 answers
75 views

Is it possible to create a shortcode to link to a specific post/page where the tag is just an attribute?

I'm trying to think of the best way to phrase this. I want to create a single shortcode to link to any post, page, or custom post type but I don't want to have to use the post ID. Ideally I'd like to ...
user avatar
0 votes
1 answer
35 views

Prevent wp_signon redirect on failed login for ajax login

I have a custom sign up process with an ajax login if the user needs to log in (stays on the same page). I have this code in functions.php and call it with Ajax. If credentials are correct, everything ...
user avatar
  • 169
0 votes
2 answers
56 views

Determine if, within a post, you are on page 2 or greater - Wordpress documentation circular

I am trying to run a function that executes only on the first page of any post. So, if a post is paginated because you have used the <!--nextpage--> tag and you are on page 2 or greater of that ...
user avatar
  • 147
0 votes
1 answer
27 views

A function to get the content of a page

I have an Elementor page and I need to get the HTML and CSS output of it without the header and footer to use in an email plugin I am making. Is there a function in WordPress that can do this? I've ...
user avatar
  • 121
1 vote
1 answer
58 views

Show Primary Category first when I display post categories

I created some custom taxonomies in Wordpress and when I want to show the categories for a custom post type on the frontend, they're listed in alphabetical order. Is there a code for functions.php ...
user avatar
0 votes
1 answer
19 views

how to get the post ID from wp_insert_post

I am programatically inserting a new page, then I want to use the ID of that new page to add a template, however wp_insert_post isn't returning me any ID, here's the code I am using $tittle = 'My new ...
user avatar
0 votes
1 answer
36 views

How to redirect Subscribers on login to specific page, when logging in from a Page

I would like to redirect my Subscribers to our Member Resources page when they login, but only when they are logging in from a Page ( is_page() ). When they log in from one of our custom post types I ...
user avatar
  • 11
0 votes
1 answer
46 views

How to cut off question mark in url with functions.php

I use directive .htaccess <IfModule mod_rewrite.c> RewriteCond %{QUERY_STRING} !^$ RewriteCond %{QUERY_STRING} !(^|&)appId= RewriteCond %{QUERY_STRING} !(^|&)q= RewriteRule ^(.+?)\.html$ ...
user avatar
0 votes
0 answers
9 views

RSS feeds for specific topics

on a word press site i am trying to build, i am trying to get a listing of current news feeds from reliable sourced on a specific topic. In the WordPress RSS options, is there a way to set up a feed, ...
user avatar
0 votes
0 answers
34 views

Fetch URL parameter

I have an URL http://127.0.0.1/wordpressbosta/team/?team=teamOne. I would like to fetch team value teamOne in functions.php like below. function get_data() { echo json_encode($_GET['team']); ...
user avatar
  • 377
0 votes
0 answers
19 views

How to use Page link field with is_page()

I want to let users select the pages on which a page title box will not appear by using a Page Link custom field that allows for multiple selections. $excluded_pages_array returns '100', '102' etc. ...
user avatar
  • 1
1 vote
0 answers
45 views

Two Different Links for Same Product - WooCommerce [closed]

The idea here is to publish one WooCommerce Product to 2 unique Links. This way, we can edit the product at both Links in one location. However, can use functions.php to alter content by reading the ...
user avatar
  • 11
0 votes
0 answers
59 views

Can someone explain what's the use of parse request function in WordPress?

What's the meaning of "Parses the request to find the correct WordPress query" in plain Englush? Reference: https://developer.wordpress.org/reference/classes/wp/parse_request/ I encountered ...
user avatar
0 votes
0 answers
12 views

how can I add filter in specfic field in my website?

I want to replace any saudian phone in specfic field in my theme "my-listings" in description and this my script in functions.php: function cudjex($text){ $text = preg_replace('/(009665|...
user avatar
0 votes
0 answers
19 views

Updating custom query var with multiple values

I'm using set_query_var to bookmark snippets that were already published, in order to exclude them from other independent loops on the page. Basically, so that no title ever comes up twice. Basically ...
user avatar
  • 312
0 votes
0 answers
133 views

how can I change all wordpress media file url to custom cdn url?

any function can apply change all image URLs to CDN instead of modifying media.php in wp-includes folder ?
user avatar
0 votes
1 answer
24 views

set object terms after some some time of published post - functions.php

I have to change the published post in one category to another category after some days. I have created the below code for the function, which I have added in the functions.php file in child-theme. ...
user avatar
  • 13
0 votes
0 answers
13 views

Wordpress Function Assistance with Loop

I am trying to making a Wordpress function to insert custom colours via an ACF repeater field. But trying to get the custom colours to make an array is a problem. Example colour that works: $...
user avatar
0 votes
1 answer
27 views

current_user_can comma list vs OR (||) list

Can any help with this? I like the comma separated version because it's smaller to write and easy on the eyes, lol, but I can't make it work. //** WORKING - Works on the Checkout page add_action( '...
user avatar
0 votes
0 answers
20 views

Different image using srcset function

In a template I'm pulling in an image from the media library with: <?php echo wp_get_attachment_image( 33894, 'full', "", array( "class" => "lazyload" ) ); ?> ...
user avatar
  • 111
0 votes
1 answer
84 views

Using ACF Relationship field to set post type to draft or published status

I am currently using the ACF Relationship field selector to query through a custom post type for locations to show various pages. These pages are "service" pages that can be shown or hidden ...
user avatar
0 votes
0 answers
32 views

redirecting a URL if accessed directly

I have created a WordPress site, in which I have created a form using wpforms the url of this form is www.xyz.com/form hierarchy to this URL is home > Download > download with kyc > verify ...
user avatar
0 votes
0 answers
35 views

Save Meta when custom Taxonomy Saves

I am in need of some advice, we are setting up a custom tag for Movies. We want to have it pull from the OMDB Api when it is saved. We have the function setup, but it is not firing, and I am stumped. ...
user avatar
0 votes
1 answer
67 views

How to hide a child category and show his parent category

i have the following schematic: the world - Cover the world. The country -Covered the country. theater - theater cover. etc... And I want that when I ...
user avatar
0 votes
1 answer
36 views

Display logged in user name and lastname on page

I want to display the first an lastname of my users on a welcome site. I have some code in my functions.php that let me show the first name. How can I change the code to show both first and last? This ...
user avatar
0 votes
0 answers
13 views

Adding wp users ID into a link address from a DIVI modul

I try to change the navigation of my members in the backend. A logged in user can edit his data on a post page. The link on the left menu "Meine Daten" will direct the user to his post. The ...
user avatar