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

How Do I Prevent Featured Image Caption Displaying Above And Below Image

I'm trying to add an image caption below my featured image on my single posts. I have this working, but weirdly they are also displaying above the image. I'm hoping someone can help point out the ...
Nick Rowe's user avatar
0 votes
1 answer
12 views

comments_template() doesn't work with ajax call

I want to load comments by ajax. I can't call comment_template() functions using an ajax request. I don't want create a new query because I'll lost all inherited args (like all settings option in the ...
Stefano's user avatar
0 votes
1 answer
36 views

ENV for Wordpress

Hi im new to wordpress/php so apology in advance for such a noob question. Just a little bit of context, I'm trying to do this custom stripe payment integration on a wordpress site that does something ...
darth-dev-vader's user avatar
0 votes
1 answer
23 views

Including product categories (product_cat taxonomy) title and description in search query

WHAT I'M TRYING TO DO I'm using woocommerce, but the question could work for WP categories also. When searching for a product, the search engine only looks for products info (title and description) ...
allumette's user avatar
1 vote
1 answer
16 views

Calling a PHP function from a menu item

Please forgive this totally newb question. I'm not a dev, and I'm a little too far that I can deal with right now... I'd like to add a link to the WooCommerce cart page using the cart icon from my ...
Patrick's user avatar
  • 11
1 vote
1 answer
12 views

Options of select field in a custom divi module ignore sorting

I made a little custom module for the Divi Builder which allows me to display a specific single post (from a custom post type). This works fine, but the options are not sorted correctly in the builder,...
Comaris's user avatar
  • 11
1 vote
0 answers
12 views

Custom update for Woocommerce stock quantity [closed]

In my Wordpress store, products are set as simple, but I use WS Form to add attributes to the product/order. We sell travels packages. When a user purchase a product, the quantity decrease to 1. But ...
Paolo Montalto's user avatar
0 votes
0 answers
21 views

get last part of page url and add it as cat in wp_query

I have a page URL : https://mwallpaper.ir/mobile-wallpapers/birds and I grabbed last part of URL with this filter : add_filter( 'example_filter', 'catslug_callback' ); function catslug_callback( $...
ehsan's user avatar
  • 1
1 vote
0 answers
14 views

How can I restrict comments on Wordpress, so only the POST AUTHOR and the user who commented can see them?

I'm after a way to hide / restrict FRONTEND comments on Wordpress posts, so that only the post Author can see them, as well as the user who posted the comment? Eg - Bob creates a post, and Sally, ...
Andy Moore's user avatar
1 vote
0 answers
19 views

Trying to insert widget code into theme function

The site I am working on has a function in the theme (Botiga) that creates a wrapper row that displays a sorting dropdown for the items below. The default output is the dropdown displays in the right ...
semidivine's user avatar
0 votes
0 answers
6 views

How to get the proper category in permalink with custom post type assigned to multiple categories

I was wondering if you could help me with the following issue. I have read a lot of cases, but couldn't trace anywhere good answer which explain, how this works. I created a custom post type: project ...
Brango's user avatar
  • 1
0 votes
1 answer
21 views

Redirecting after login except for a specific page

I needed to redirect users after login and this was not a problem using an add_filter on functions.php, done, it works as expected. But now I need to avoid this redirect when the user login from a ...
zatarra's user avatar
0 votes
1 answer
34 views

Simple way to make most of my site private

I need to make a site I am developing be mostly private, accessible by standard Wordpress login. Most plugins are way overkill for what I need, I don't need user roles, tiers, monetization etc. I just ...
semidivine's user avatar
1 vote
1 answer
7 views

Get check box values inside array for use in posting form data

So I have the following function with an array of variables that handles a profile form. All but one is a typical input with the exception of 'member-comptency[]'. It's a select field field with ...
visyoual's user avatar
0 votes
1 answer
31 views

Secure way to add JS Script to Wordpress filesystem

EDIT: Because of the answers below i changed the title and explanation for this question. Maybe there are other people who struggle with saftey questions, like me. I am a beginner with Wordpress ...
LovinQuaQua's user avatar
0 votes
1 answer
25 views

Proper way to load styles using a child theme

I decided to start using Elementor Hello theme for building my websites. In the past, I always edited style, templates and other theme files directly from the original theme directory, but I decided ...
Martin Peternel's user avatar
0 votes
0 answers
9 views

How can I eliminate the top-level URL slug in WordPress while still being able to access child pages, particularly three levels deep or more?

Is this a limitation inherent to WordPress? For instance, when we have a URL structure with three levels of hierarchy, is it not possible to remove the first level? Currently, I must maintain the ...
Sankar V's user avatar
  • 101
1 vote
0 answers
36 views

Include bbPress topics and replies in WordPress search results?

I realize this deals with a plugin (bbPress) however I hope it's still considered relevant enough to WPSE since it deals with altering WordPress search results... How can I ensure that bbPress topics ...
Jesse Nickles's user avatar
0 votes
0 answers
11 views

Function for Post Creation plugin for Gravity Forms

add_action('gform_after_submission_33', 'customize_submission_values_for_custom_post_type', 10, 2); function customize_submission_values_for_custom_post_type($entry, $form) { if ($form['id'] != ...
JoaMika's user avatar
  • 668
1 vote
1 answer
86 views

Add custom text before all image captions in WordPress posts

I add captions to images in WordPress using the "Caption" box to indicate the photographer's name. I need custom text to always be displayed before the image caption, That is, now I just ...
Jusper's user avatar
  • 11
0 votes
0 answers
14 views

How to access admin menu labels and links on front-end?

I am trying to retrieve a list of all the admin menu labels and links on the front-end so I can add them to my admin bar menu. I don't need the submenus. I was hoping to access global $menu, but it ...
Aristocles's user avatar
0 votes
2 answers
15 views

Apply function only for specific post

I have a function to change the locale of the posts function change_og_locale( $locale ) { return 'es_ES'; } add_filter( 'wpseo_locale', 'change_og_locale' ); Now, I would like to fire it only if ...
NicoCaldo's user avatar
  • 147
0 votes
0 answers
76 views

Submit CF7 form programmatically with WP-Cron?

We need to check daily if our CF7 form is working properly (form submission data arrives to support's email). So i need a way to programmatically submit the form on frontend. I tried with WP-Cron but ...
Ion T's user avatar
  • 15
0 votes
0 answers
32 views

Get current post type within functions.php

In my function.php I need to run something to check post type or page id. how can i check current post type loaded in functions.php function.php <?php // the ajax function add_action('...
Beep's user avatar
  • 29
0 votes
1 answer
10 views

BuddyPress Edit activity function good practice

I am using a custom BuddyPress edit function. However, I was told this is a bad practice and that I should use WordPress's helper function. How to correctly do this? Here, is the code: add_action('...
Rohit kc's user avatar
1 vote
0 answers
32 views

Possible to overwrite load_template function in plugin using functions.php

So, I am currently using a Wholesale plugin for Woocommerce which, by default, redirects users to it’s own Wholesale Store page. The caveat is that the Wholesale Store page only uses the archive-...
jayciemota's user avatar
0 votes
0 answers
29 views

Include posts under a custom taxonomy in author.php

The author’s archive (author.php) on the website I’m working on displays only the posts by the current author. I have a custom taxonomy called “co_writer” which I use to simply tag a post as having ...
Sum's user avatar
  • 11
1 vote
0 answers
15 views

Is there a way to batch-find unlinked text URLs in the body text of all my posts and link them?

Context: I used a plugin (WP All Import) to import Excel rows into WordPress posts, but some cells have multiple URLs. Since Excel only supports one hyperlink per cell, I have a bunch of plain text ...
LeTronique's user avatar
1 vote
0 answers
16 views

Modifying Slider Function for Decimal Precision

I'm working with the WordPress Traveler theme. In the Tour option, there is a slider used for Max People. Max People will be used for another purpose and should work with a precision of 0.1 instead of ...
tbo812's user avatar
  • 11
0 votes
0 answers
18 views

Child theme's functions.php not being read (child theme's autoload.php not being run)

Our child theme's functions.php contains: require_once __DIR__ . '/vendor/autoload.php'; However, the files that autoload.php loads are not being loaded, and a fatal error occurs. '/vendor/autoload....
Steve's user avatar
  • 1
1 vote
0 answers
19 views

Assign a value (got from an xml file) to an attribute of Woocommerce products

Good morning, I should need to assign a value (value) from an xml file (that I export from my Warehouse Management System to My wordpress site) to an attribute I have already created 'unita'. And each ...
Giak's user avatar
  • 11
0 votes
1 answer
84 views

YouTube embeds Cross-Origin Request Blocked (CORB) error

I am new to the WordPress world, please bare with me. On my website have embedded some YouTube videos using the video block. I am seeing this error in the console: Cross-Origin Request Blocked: The ...
kocjs's user avatar
  • 23
0 votes
2 answers
40 views

Override categories with Pages (block theme)

It seems to be a common question as to how to override an auto-generated category page with a manually-created Page when both exist at the same location for example, /xxxx/ and /yyyy/ and /zzzz/ are ...
Displayname71's user avatar
0 votes
1 answer
33 views

FATAL ERROR when I try to change the .php according to required and optional items rule

hope to find a solution here. After having updated out php to PHP 8.0, we are having DEPRECATED alert. Most of them regards a required parameter that follows an optional one (making the second as ...
Federica Cilli's user avatar
0 votes
1 answer
56 views

stop resize button for wordpress media

The images in my WooCommerce product gallery do not need to be resized I only need the original image to display. Is there a way to add a toggle button to wordpress media to tell it to generate other ...
Monoor's user avatar
  • 13
0 votes
1 answer
35 views

Add class to functions.php custom code to call font awesome icon

I have inherited a website that has custom code in the functions.php file to create a custom Tab in Woocommerce products. This will eventually become obsolete as I update the site but for now I need ...
stratalign_nz's user avatar
1 vote
0 answers
41 views

Custom permalink for post of one category

I want to customize the permalinks structure for posts in WordPress based on their categories but only posts of one category, The permalinks of the "android" posts category become like these:...
Heisenberg's user avatar
0 votes
1 answer
26 views

Parameter for pagination posts_pagination

I created a pagination with the_posts_pagination() function Right now it looks like this and it works fine: Previous 1 2 3 4 Next When I am on the 1st page, the "prev" button disappears or &...
Thica's user avatar
  • 17
0 votes
0 answers
23 views

Display endpoint's return into a file (file_put_contents())

I've created a form (using WS FORM RUN WORDPRESS HOOK) than when submitted triggers a php script that grabs all the submitted data written on the fields and save them into $variables and everything ...
WinterCold's user avatar
0 votes
1 answer
44 views

Auto Generate Post Title from 2 ACF Taxonomies [closed]

I am looking for a custom function to auto generate a post title/slug for a specific CPT from two taxonomies and one custom field, created with ACF Pro. Auto generation should be done only when the ...
austriadesign's user avatar
0 votes
0 answers
26 views

add to cart linking to add to cart page

I am making a website in Wordpress and created a custom shortcode for loading the products. That is working fine, however when clicking the add the cart button, if redirects me to the cart page, where ...
Brango's user avatar
  • 1
0 votes
1 answer
66 views

How to change post date and post time in Wordpress automatically with a function

I am not much of a coder but I have done research lately on how to change the post date and time in WordPress to the current date and time for all posts and I have not been able to get much. If anyone ...
tee's user avatar
  • 1
0 votes
1 answer
70 views

Execute wp_after_insert_post after the permalink is customized

I'm trying to set a meta property to a new post's permalink using update_post_meta. When I run this on wp_after_insert_post I get a permalink that ends in "?p=[ID]". If I update the post to ...
Tim Troiano's user avatar
0 votes
1 answer
21 views

Second featured image only shows in metabox preview after saving a post in the wordpress editor

I am trying to add a second featured image to the Wordpress post editor, and it seems all be working. When I select and image from the mediauploader the first time the image shows in the preview of ...
Brango's user avatar
  • 1
0 votes
1 answer
35 views

How to use: WP_AJAX_GET_COMMENTS

I just found out WP_AJAX_GET_COMMENTS($action) function to retrieve comments on WordPress. Someone know how to use it? Thank you so much Stefano
Stefano's user avatar
0 votes
1 answer
21 views

Overriding an existing filter

There is this function that is part of the plugin EasyDigitalDownlaods' plugin: public function category_dropdown( $name = 'edd_categories', $selected = 0 ) { $categories = get_terms( '...
Niko's user avatar
  • 3
0 votes
1 answer
20 views

How to delete rows from custom table within a time interval?

I need to apply this PHP Rule to remove records into a custom table $query = "DELETE FROM $table_name WHERE Date < now() - INTERVAL 30 DAY; I'not albe to figure out how to implement this line ...
Tormy Van Cool's user avatar
0 votes
0 answers
23 views

pre_get_comments to restrict current users view of edit-comment.php to their comments

Here is what I have to far that is not working: function comments_for_current_author($query) { global $pagenow; if( 'edit-comments.php' != $pagenow || !$query->is_admin ) return $...
randy9000's user avatar
0 votes
1 answer
42 views

wp_insert_post inserts 3 posts at once?

I want to write an import of events (that I had as a text). The post are inserted, but each post is inserted 3 times!? I'm running a function on after_setup_theme in my functions.php. What I do: I ...
beat's user avatar
  • 43
0 votes
0 answers
18 views

disable a specefic sidebar when user is log out

I want to disable a profile sidebar when users are logout if (is_active_sidebar('profile')) : if ( is_user_logged_in() ) : dynamic_sidebar('profile'); else : dynamic_sidebar('--...
D.JCode's user avatar
  • 201

1
2 3 4 5
115