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
0answers
8 views

some profile informations like youtube link doesnt seem

youtube icon which is represented in code with "fa fa-youtube" doesnt seem but i have youtube link on my profile settings. <?php $youtube_profile = get_the_author_meta( 'youtube_profile' ); ...
1
vote
0answers
10 views

How do I give parameters to the content part I am fetching in Wordpress?

I am using a content part for intro-sections on various sites. I would like to be able to include a custom title which will be displayed in the section. I only was able to use the variables the other ...
-1
votes
0answers
16 views

How do I wp_deregister_script() for entire site except one or two pages?

I am using Elementor Pro but only on a few pages. It seems a waste of overhead for the Plugin JS/CSS to load on every single page and post so how do I wp_deregister_script() for the entire site ...
0
votes
0answers
11 views

youtube_profile doesnt seem like empty on profile [on hold]

loop with "if " 's value is false.youtube icon doesnt seem but i have link on my profile settings. <?php $youtube_profile = get_the_author_meta( 'youtube_profile' ); if ( $...
0
votes
0answers
23 views

Why has_term does not work with AND operator?

I am working with multiple conditional in WooCommerce doing specific actions according to the existing categories in the cart: if( (has_term( 'prestamos-empresa', 'product_cat', get_post( $product_id ...
0
votes
0answers
6 views

Redirect only certain posts from sub-domain to main domain

I have a sub-domain of blog.bla.com which contains hundreds of posts. Only some of those need to be redirected to bla.com/individualArticle. When using redirect plugins, none of them will let me ...
0
votes
0answers
17 views

Redirect Child Category to Parent Category Post Permalink

I changed my permalink structure to /%category/%postname/ and its okay, My site post permalink is now https://example.com/categoryname/postname/ Now the issue is, I am having child category, It ...
1
vote
0answers
15 views

contact form 7- convert to wp registration form [on hold]

A very nice man shared this code to add to a theme's function file that will convert a cf7 form into a registration form. There is a plugin out there but the developer seems to have abandoned it. The ...
0
votes
0answers
20 views

Ajax request not sending to server and returning - wp-admin/admin-ajax.php 400

I have written a jQuery function using jsPDF to convert a form to PDF, I have then added an ajax command with the intention of saving the generated PDF to the server. However, when I click submit, ...
0
votes
1answer
14 views

How do I make a custom “Read More Blogs” button for my blog page

I'm actually working on my custom wordpress theme. And, when I tried to develop a "Read More Blogs" button, I was unable. Because, all the examples I saw on internet was for pagination. I need a ...
0
votes
0answers
9 views

Password Protected Page cookie expiration time / ask for Password every page visit in a session

I found this post on my topic pass-protected pages and posts not protected after enter them 1 time But I'm not sure it got answered correctly. It must be a cookie issue, but after the first visit to ...
0
votes
1answer
31 views

function class doesnt work

i added a menu to admin bar menu but it's style doesnt work;it looks like has default style <style> .my_menu_item_class{ color:red; background: yellow; } </...
0
votes
0answers
18 views

I am trying to set post terms to a custom taxonomy

I have a custom taxonomy that I would like to update on posts using a PHP function. An example of what I am trying to achieve is the following: Array ( [0] => WP_Term Object ( ...
0
votes
1answer
25 views

Programmatically add Yoast meta description after post save

I'm building a website and I need to have the Yoast description programmatically added after saving a post (a custom post type in my case). Now, since I'm using Advanced Custom Fields, and I also ...
0
votes
0answers
21 views

How can i add condition for editing post with a field

I’m trying to add a conditions to specific post for editing. I have got post type clients. And this post type have got client_manager field(acf). client_manager field is getting a user on system. When ...
0
votes
1answer
45 views

Help using ShortCodes to style whole chunks of the post

Recently my sites got hacked, forcing me to start rebuilding them from scratch. It's been ages since I spent time on them, so I don't even remember the plugins I'd installed and used. One of them, ...
0
votes
1answer
25 views

How to rewrite wordpress search to work on specific category

I want my wordpress search to work on specific category within custom search, by default this actually work fine example.com/categoryname/?s=keyword but I want to make it work like this example.com/...
0
votes
2answers
70 views

Calling a method from functions.php on a click of a button

I have been working on a project where I will have to call a method(that accepts user id as an input) from a click of a submit button(Accept button). I have been trying all the ways but the real ...
0
votes
1answer
14 views

how to use 2 index.php file One for mobile and one for desktop

I want use 2 index.php file in WP, One for mobile and one for desktop. Is there a way for this? or use a index.php file with deferent content for mobile and desktop. There is a solution? (I dont use ...
0
votes
0answers
32 views

Creating export to CSV function but responding as expected

I have added the following code to function.php to create a CSV download of a PODs Framework PODs with the name solution. For some reason - which I do not understand - the CSV download is not ...
0
votes
0answers
14 views

Extra action upon setting a featured image

I am searching for a way to have newly uploaded and old one media files, which are set as featured image on a single post, duplicated into webp extension. For this purpose, it seems that I need to ...
0
votes
2answers
24 views

Calling a function from functions.php in custom page/ blog post

Is it possible to call a function from functions.php in custom page or blog post? I put simple function in functions.php: function testTest() { echo "Test"; } And called it from the page: <?...
0
votes
0answers
10 views

Change social navigation menu default icons with customized icons (twentyseventeen theme)

I'm taking the first steps as a self-taught in the wordpress world. My problem is the following: modify the icons that the "Twentyseventeen" theme assigns by default in the social media menu. I ...
0
votes
1answer
99 views

Display shortcode based on user meta

I have been working on a project where I want to display a shortcode based on the user meta data. I have added a user meta while creating a new user. The default value of the user meta is set to false....
0
votes
0answers
13 views

Change user role on registration if checkbox on form is checked

I am using the NRGNetwork theme on a site I am working on. If you click sign up, a registration form drops down. I altered this to include a checkbox that says "Register me a site contributor". I want ...
0
votes
0answers
48 views

Send Front End PM Message after Succesful Ultimate Member Registration

We're working on a Wordpress project which requires: - a list of Therapists with a "Contact" button for each (done, listed with Store Locator and an Ultimate Member user group for the Therapists) - ...
0
votes
0answers
14 views

How to show text near a specific word/tag/category?

can someone give some examples of code that I can use in the tag and category loop pages, which will give out the content near a word? Here is an explanation. The default function of the category and ...
0
votes
1answer
24 views

My website is not showing Footer section

** EDITED ** Hello im new with Wordpress, Im having a problem with widgets (sidebar and footer) my footer.php is not being rendering unless I delete sidebar.php from files. Ive tryed to debug but ...
-1
votes
0answers
16 views

How to replace specific word on Page ID in Wordpress using translated_text

I wish to modify a string on a specific page ID using $translated_text function. Please can someone help set up the code for this?
0
votes
1answer
30 views

Display current user metadata on Wordpress page

So I have a Wordpress website, and I want to be able to display the current logged in user's data on a page. Previously, I had been able to find a snippet of code that would go go in functions.php and ...
0
votes
0answers
28 views

How to add typehints to function in functions.php when argument is an object?

I have a function that is defined in functions.php of my theme and it makes use of the WP_User object. My problem is how do I let the PHP interpreter aware of its use. This doesn't work //function ...
0
votes
0answers
13 views

Sort the archive by year

I have a custom post type by the name of companion which allows me to publish articles/posts for a magazine. I applied a custom taxonomy to companion by the name of issueCompanion which acts as ...
1
vote
3answers
42 views

Running a script before absolutely everything

I want to run a script before any Wordpress stuff kicks in. I know it's wrong but currently I have my function in the index.php file before the below code: {{{MY FUNCTION IS HERE}}} require 'vendor/...
0
votes
2answers
22 views

Activate and deactivate plugin automatically

How I can Activate and deactivate plugin automatically? For example, I want the "Yoast Seo" plugin to be active only on Monday, Wednesday, Friday, Saturday and the other days deactivated. How can I do ...
0
votes
1answer
37 views

Run a code only on theme activation only during first activation

function clearwidgets(){ //stuff here only runs once, when the theme is activated for the 1st time } register_activation_hook(__FILE__, 'clearwidgets'); And the code I am trying to execute is this:...
0
votes
0answers
9 views

Trouble running signature script

I am creating a document on my website which requires a customers signature. I have taken the signature element from https://codepen.io/nonsalant/pen/JYpjvE I have made some slight changes as I dont ...
0
votes
1answer
19 views

Woocommerce checkout field

is it possible to hide certain checkout filed in woo-commerce when user is logged in ? like i have a checkout field of Email address i do not want my user to see this when the user is logged in Your ...
0
votes
1answer
12 views

Extend WordPress Audio Widget to accept HLS (.m3u8) URLs

I'm working on a new FM radio station website, I was trying to use the default WordPress Audio Widget to play their live audio stream. The problem was that the Insert from URL option doesn't accept ....
0
votes
1answer
50 views

query posts in functions.php and update a field

I'm having problems querying posts in functions.php. This is mainly to update posts in the back-end, not to show a query on the front end. I'm trying to get all posts that use the status post format ...
0
votes
0answers
32 views

How to remove link script on wordpress

I'm stuck with a script. Please guide me how to block it.. script type="text/javascript" src="//deloplen.com/apu.php?zoneid=2643583" async data-cfasync="false" /script Your site is hacked and needs ...
0
votes
0answers
10 views

Paid Membership Pro Approvals

I'm currently developing a membership site using paid memberships pro along with woocommerce subscriptions. I would like the option to approve or deny memberships, which is why I have opted for pmpro ...
0
votes
0answers
37 views

shape custom-background with css

i want to create a theme has background image that is changeable by admin.for this goal i added that code to my function.php: $defaults = array( 'default-color' => '', 'default-...
0
votes
1answer
26 views

Compare meta key to current date in pre get post

I'm looking for a way to compare a string to the current time. I found this question "pre_get_posts filter using numeric meta_query comparison (from dates)" and I'm confused as to get it to work. $...
0
votes
0answers
14 views

Add Product Permalink Before Order Item Meta

I am using the following code to add product permalink in woocommerce admin order page- function fpd_custom_order_item_values($_product) { $url = $_product->get_permalink(); echo '<p&...
0
votes
0answers
21 views

Custom query for custom post type not getting correct post ID

I have written a custom query here: <?php $the_query = new WP_Query( array('post_type' => 'video', 'posts_per_page' => 10, 'post_status' => 'publish') ); ?> <?php if ( $the_query-&...
0
votes
1answer
23 views

Add Product Permalink in woocommerce admin order page

I am trying to add the permalink of product on woocommerce admin order page with this code: function fpd_custom_order_item_values($_product) { $url = $_product->permalink; echo '<p>'.$url....
0
votes
1answer
35 views

Remove pagination if search returns empty

I made a fix that when the searchbar is empty, it returns 'No results', instead of all posts, but the pagination still shows up. Does anyone know a fix for that? My code search.php: <div class="...
0
votes
1answer
31 views

I'm creating a online store for my website, my aim is to add description to products in home page only how can i achieve it?

Here is my code i need to add description to homepage only add_action('woocommerce_after_shop_loop_item_title', 'description_in_shop_loop_item', 3 ); function description_in_shop_loop_item() { ...
0
votes
1answer
13 views

how to increase connection time

actually I'm using this script To increase the connection time // Reste connecté à WordPress durant 1 an add_filter( 'auth_cookie_expiration', 'keep_me_logged_in' ); function keep_me_logged_in( $...
0
votes
1answer
21 views

Shortcode to insert default text and change one word throughout it?

A beginner developer here, working on my first project. I've been trying to find some guidance on how to create a plugin or function to create a specific shortcode. Let's say I have two default ...