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
21 views

How to make a slug from GET request to other page and then retrieve it as variable?

Let's say i have custom page site/wordpress/id/ How can i: Send get request to it the right way with form that has 1 input "id" what action should be in that form? Make it look like guest is on the ...
1
vote
1answer
23 views

Can I hide certain upload folders in media library [duplicate]

A Plugin ( download monitor ) saves uploaded files in a certain folder called "dlm_uploads" within the WP upload directory. All files are visible in Media Library. Unfortunately the upload path cannot ...
5
votes
2answers
359 views

Gutenberg disallow certain custom blocks but keep all core blocks?

I'm writing a function to allow only some custom blocks - essentially I want to register all the blocks, then based on a database table of 'selected' blocks disallow any other custom block. I can ...
2
votes
0answers
28 views

How to find out what blocks are added by a plugin

I am creating a plugin, which adds a number of blocks defined by JS/PHP as per Gutenberg documentation. I want to display these block names on an admin page. Is there a hook or function I can use ...
1
vote
1answer
27 views

How to overwrite / extent wordpress function is_email

so wordpress' core isn't really up to date with email allowances of unicode domains. Even simple special characters like the german umlauts (äÄöÖüÜß) aren't allowed in the domain part of the name. So ...
0
votes
1answer
31 views

Allow Comments by Default for Multiple Post Types

I have this working for one post type, but need to do it for three. I tried the "else" statements but I realized I suck at PHP. function my_comments_open( $open, $post_id ) { $post = get_post( $...
1
vote
1answer
15 views

How do I update a field of a meta box?

While parsing data from a CVS file into a custom post type, i would like to parse data into the fields of a meta box, that I created. The meta box fields are normally updated like this: function ...
0
votes
0answers
10 views

How to handle a new function replacing an old function in plugin development?

If you had created a plugin which has a function other plugins or themes make use of... If this function was replaced with a new function that does the equivalent and more but with a different set of ...
0
votes
0answers
11 views

Remove tag from all posts when publishing new post

I need a function that does the following when a new post is published: Checks all existing posts and removes the tag "latest" if it exists It adds the tag "latest" the the post being published This ...
1
vote
1answer
42 views

Function issue with Walker_Nav_Menu [duplicate]

I am getting this warning after updating to PHP 7.2 can anyone help me resolve it? Warning: Declaration of foundation_navigation::start_lvl(&$output, $depth) should be compatible with ...
0
votes
1answer
76 views

How to remove canonical url in wordpress? add_filter( 'wpseo_canonical', '__return_false' ); not Working for me

How to remove default canonical URL in WordPress. I'm using Yoast SEO and I tried with add_filter( 'wpseo_canonical', '__return_false' ); And also I tried with remove_action('wp_head', 'rel_canonical'...
1
vote
1answer
16 views

restore_current_blog required after switch_to_blog, if I use that in a function?

class Basics { public function build_frontend_post_form( $blog_object ) { switch_to_blog( $blog_object->blog_id ); if( !( current_user_can( 'administrator' ) and ...
0
votes
0answers
21 views

Create new meta field with existing field data on publish

I am using a frontend publish plugin that uses Wordpress's default publishing hooks to publish, and I am trying to create a function that will grab the data of one of the fields in the frontend form, ...
0
votes
0answers
4 views

Skip Specific html tag From Keyword Auto link

I am really frustrated, I have tried working on this code but I am not getting it right, Though I am a novice in WP function coding. I want to skip specific html tag from my auto replace keyword with ...
0
votes
0answers
20 views

How to modify or override a core function (wp_star_rating)

I'm looking for the way to modify a core function, in this case the wp_star_rating() function, declared in wp-admin/includes/template.php Actually what I want is to change the $title variable, cause I ...
1
vote
1answer
24 views

Add Featured image column into wordpress admin on pages AND posts

I have created a column in my functions.php file to add in a column to see the featured image on posts. However i would like to do this for pages as well, but if i repeat the code replacing posts with ...
0
votes
0answers
6 views

How to allow only auto indentation on TinyMCE

I want that Wordpress (or TinyMCE or any plugin) could auto indent my HTML (as switching from Text to Visual does), because I have lots of old posts that I need to edit and they are kind of minified. ...
1
vote
1answer
11 views

WordPress menu link doesn't work properly

I am developing custom site. The header links work on home-page but when I go inside shop then the home-link becomes siteurl/shop how to solve this? <div id="content" class="site-content"> &...
0
votes
1answer
37 views

How Can I Concatenate A String With One Of My Custom Field Value Before Saving The Post?

My website is a daily deals and offers site. I promote many online stores with affiliate links. I have created a php script to detect any merchant's link (ex- Amazon) and convert it to my affiliate ...
0
votes
0answers
15 views

Classic TinyMCE messing up only Contributor's HTML

I use a plugin that loads pre-defined HTML for my posts. I don't need the Visual editor, so I've disable it for everybody. Also, I want TinyMCE not to mess with my code. Nothing, no auto formatting ...
0
votes
1answer
93 views

Wordpress upload_mimes not working for front-end uploads of 3D files

So, after the new WP updates my form will not allow certain files to upload. I have a Gravity form with an upload field to submit 3D print files. I can get one type of file to work, but not the others....
0
votes
0answers
24 views

Cleaner 'for each' loop for registering scripts in functions.php

I'm looking for a elegant way to register a ton of scripts I have sitting in a js directory on my server without having to sit and type them all out. I found this question here but it is 3 years ...
0
votes
1answer
17 views

Automated mark posts as featured every day

Hello Wordpress Community, I want to build myself a "recipe of the day" functionality. I'm looking for a way to mark 3 Custom Post Types per day as "Featured Posts" by a plugin or Cronjob. The ...
0
votes
0answers
18 views

Bifurcate woocommerce cart plugin in two parts

[woocommerce_cart] The above shortcode renders the woocommerce cart page, which will have these looks: What if we want just to generate just Part 1 or Part 2 as shown in the figure. Is that ...
0
votes
0answers
7 views

Keep Page hierarchical order on Control Panel when I use 'remove_cap' 'edit_others_pages'

I'm admin user and just created several editor users who are 'NOT' allowed to edit other pages. Let me call them 'master editor','editor A' and 'editor B'. 'master editor' can edit top level parent ...
0
votes
0answers
10 views

Custom Customizer Image Sanitize fails to update image

I use this custom sanitizer to get the appropriate image size so that anyone using my themes can't mess up and put an 8k image in the website. The code works, but the problem I have is that once the ...
0
votes
1answer
28 views

Is it possible to use array_walk() to append terms to an array of posts?

I'm creating a masonry post grid of animals. I plan to filter the the visible posts by toggling classes. The classes would in turn would be the post's. I'm using an MVC theme and would like to get ...
1
vote
1answer
43 views

Remove Font-Awesome MaxCDN Link & Load Locally

MaxCDN is slowing down my site so I want to load font-awesome locally but I can't seem to write the correct function to remove it. function remove_unwanted_css(){ wp_dequeue_style(‘font-awesome’, ‘...
0
votes
0answers
127 views

Load CSS file conditionally

Trying to load CSS file conditionally – only for specific pages with the following: add_filter('tablepress_use_default_css', 'tablepress_css_conditional_load'); function ...
0
votes
0answers
31 views

How to have multiple the_content() tags

I am designing a wordpress blog where you click on the title of the post and the content of the post opens up from the right side of the website. I was wondering if it was possible to have multiple ...
0
votes
1answer
22 views

How best to check if a user is from China and hide content?

To speed up my website in China I thought of hiding blocked services from Chinese users and wrote this and put it in functions.php $isInChina = false; $ip = $_SERVER['REMOTE_ADDR']; // This will ...
0
votes
0answers
22 views

How to enqueue reactjs built theme to index.php to build wordpress theme

I am trying to make a wordpress theme using create-react-app package. But the problem is i have no idea how to put these files in wordpress directory to render it on index.php or how to enqueue these ...
0
votes
1answer
18 views

Add HTML before a specific div?

I bought the "Woocommere Checkout Add-Ons" Plugin, which adds upsells to the checkout page - but it only allows to place text after the upsell checkbox. So I got the idea to add an image with some ...
0
votes
1answer
18 views

Override filter variable not working

I'm currently trying to override a filter in a plugin. This filter has 1 variable which defines a root path to a folder where some templates are located. This root path is normally in the assets ...
1
vote
1answer
168 views

Removing Default Gutenberg Blocks, But Keeping Reusable Block Functionality?

I have been follow a tutorial here: https://rudrastyh.com/gutenberg/remove-default-blocks.html Where it discusses how to remove default Gutenberg blocks like so: add_filter( 'allowed_block_types', '...
0
votes
1answer
18 views

How to include any template using Shortcode fuction?

function custom_code(){ return include( get_stylesheet_directory() . '/custom-template.php'); } add_shortcode('custom_shortcode','custom_code'); As you can check above I want to include a ...
0
votes
1answer
18 views

Return category name with & Ampersand doesnt work

I have a category named: This & That However, for some strange reason my switch code doesn't pick it up. When I output $firstcat it does return This & That which makes it even more cumbersome....
0
votes
2answers
40 views

CSS change in woo commerce Place Order Text [closed]

add_filter( 'woocommerce_order_button_text', 'woo_custom_order_button_text' ); function woo_custom_order_button_text() { return __( 'Your new button text here', 'woocommerce' ); } Above is the ...
0
votes
1answer
32 views

Why my wp_enqueue_script doesnt work on some page?

My wp_enqueue_script from my theme is working on home page and not on other page. This is my web : https://welgo.id. And here is not working : https://welgo.id/listing/rs-bandung-eye-center-bandung/ ...
3
votes
2answers
124 views

Influence of WordPress functions on site speed

We know, that wordpress has custom functions that create in wp-includes and etc... and its system has more includes and functions(without calling)... My question is: Is abound of wordpress functions ...
0
votes
1answer
25 views

Php function 301 redirect

I am using this code so that when the user visits the old permalink, he gets redirected to the new one. add_action( 'template_redirect', 'redirect_to_external_url' ); function ...
0
votes
1answer
25 views

Go top smooth function [closed]

I have a problem that I write the following code in the functions.php to realize the page go top. It works.but just work for the user fist visit the page and click the button for first time. I must ...
0
votes
0answers
18 views

Catch the first video,will it cause server pressure?

My mother tongue is not English. Here I use Google translation. I need to display the first video of the article on the home page. The following code is used But I have a question.Does this server ...
0
votes
0answers
19 views

Add number in increment of one to menu items

I'm trying to add sequential numbers to menu items in increments of one. So right now where I have the following: <li class="menu-item menu-item-type-taxonomy menu-item-object-category"></...
0
votes
0answers
52 views

Add hide featured image option

Hello, I wold like to add a check-box or button to have a choice between hide or display featured image in single post. i'm in wordpress 5.0.2 This is the code of my simple single.php in the theme : ...
0
votes
1answer
33 views

Can't properly set the_title add_filter to show short_URL

I am trying to show Bitly's Post short URLs for my blog posts but something seems off as when I am using this code, I see the output all over the page for menu items etc... Additionally, the URL ...
1
vote
2answers
20 views

Inserting a functions output after the content

So I am trying to add a button at the end of my blog posts, here is the code I have in the plugin so far: <?php /* Plugin Name: etc.... */ function shares_content() { ?> <div class='...
0
votes
0answers
25 views

Dynamically set front page featured image from first image in latest post's ACF gallery

My front page template is set to display the full content of the latest post using WP_Query and a custom page template. Now I want the home page featured image to dynamically change every time a new ...
0
votes
1answer
25 views

How to load a script code only in posts?

I want to load some JavaScript code only when it is posts, and not a home page or pagination! How can I do it with functions.php?
0
votes
1answer
19 views

Reference multiple style sheets, clearing styles for permalink page, custom fields for css

my wordpress theme will be styling posts on the index page based on their post-ID class -this will result in a lot of css code over longer durations of time. To keep the website lightweight as ...