Skip to main content

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

list all gutenberg blocks properties with icon name as well

function custom_blocks_api_get_blocks() { $blocks = WP_Block_Type_Registry::get_instance()->get_all_registered(); $block_data = array_map(function ($block) { return [ '...
Marko Krstic's user avatar
0 votes
1 answer
42 views

How to use a function inside of a function, or rewrite this code to work:

I have a script that works as a standalone php file, but if I put it in a Wordpress hook action with a function, the checkposts() function stops working. I tried to put the checkposts function outside ...
Peter's user avatar
  • 153
0 votes
1 answer
45 views

How to automatically flush permalinks?

Is it possible to write function that will trigger flush_rewrite_rules() on a timer? I would like for it to run every hour
John Saputo's user avatar
0 votes
0 answers
14 views

Advanced Custom Fields in WP_Query: Clickable Text in List Format

So I have two ACF fields. A text field author_name and an url field author_link. The url field is intended to wrap around the text field to make the links clickable. The staff member would enter this ...
Hex1189's user avatar
0 votes
0 answers
19 views

I got this error POST https://localhost/meraboilerwp/[object%20Object] 404 (Not Found)

//this is my functions.php // Enqueue Styles function meraboiler_enqueue_styles() { wp_enqueue_style('google-fonts', 'https://fonts.googleapis.com/css2?family=Patua+One&family=Open+Sans:wght@...
Kashkumar Singh's user avatar
0 votes
0 answers
28 views

How can I display a Divi content inside a modal based on an AJAX request

This is my first question, please bear with me if I have forgotten any information. I want to show Divi content (saved as a WordPress project if it's important) inside an overlayed modal. For this I ...
cho's user avatar
  • 1
0 votes
2 answers
34 views

I am looking for a function to create category links in the wordpress loop for articles

For several days I have been trying to create a link for the categories, basically they are displayed but are not clickable to access the categories page. Do you have a solution or a function to put ...
gestionlydie-tv's user avatar
0 votes
1 answer
73 views

Calling a function via a shortcode in javascript

I'm looking to dynamically change the page-comments option based on whether the user clicks a URL. I have two functions to do this: function psb_comment_listener_func(){ echo " <...
pbee's user avatar
  • 5
0 votes
0 answers
10 views

How do I make a shortcode to display Dokan seller badge list?

I am going to add the Dokan seller badge list to the single product page by creating a shortcode so that the tooltip is also displayed. Thank you for your guidance.
negar file's user avatar
0 votes
1 answer
33 views

Adding a css class to the gallery

I'm using WordPress 6.5 with the old editor, I'm trying to add a CSS class on the div gallery when it specified in the shortcode, the code doesn't work, can you help me ? function custom_gallery_class(...
Barrista's user avatar
0 votes
0 answers
32 views

Abbreviate Wordpress post view numbers

Can anyone please walk me through how to make post views on Wordpress shorten to 10K or 1.1M rather than displaying the full number 10,000 or 1,000,000. I found the code below but not sure how to ...
Steve's user avatar
  • 1
1 vote
2 answers
113 views

Image alt tag is showing post title instead of Alt Text

The image alt tag shows the post title in the source instead of the Alt Text. function my_custom_image_sizes() { add_image_size('homepage-thumb', 329, 185, true); } add_action('after_setup_theme', ...
rudyards's user avatar
0 votes
0 answers
20 views

Failed to open stream: No such file or directory in /home/search/public_html/wp-includes/functions.php on line 6852

Warning: file_get_contents(/home/search/public_html/wp-content/plugins/open-user-map/open-user-map.php): Failed to open stream: No such file or directory in /home/search/public_html/wp-includes/...
Jan's user avatar
  • 1
0 votes
0 answers
11 views

WordPress current post functions inside loop doesn't work anymore, are they incompatible with php 8.0?

I recently update php from 7.4 to 8.0 , since many functions doesn't work anymore ! I don't know if it's related but I have tried many solutions and none of them works. Using (get_...) , the_title, ...
imagIne's user avatar
  • 83
2 votes
2 answers
282 views

Remove or disable Appearance > Patterns

Not sure quite when, but a recent WordPress release has added a new WP Admin link under Appearance for Patterns: My themes don't use Gutenberg, and I've disabled it. But the Patterns screen is still ...
doofusb0y's user avatar
0 votes
0 answers
12 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
17 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
76 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
49 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
27 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
28 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
20 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
28 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
16 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
21 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
12 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
23 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
40 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
8 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
  • 111
0 votes
1 answer
35 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
58 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
10 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
38 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
  • 678
1 vote
1 answer
94 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
17 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
17 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
104 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
  • 25
0 votes
0 answers
33 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
11 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
47 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
17 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
249 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
71 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
57 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
64 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

1
2 3 4 5
115