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
1answer
14 views

Disable every rss feed except home feed

I would like to disable every feed (comments, category, tags, author) as detailed here: https://wordpress.org/support/article/wordpress-feeds/ except for the "home-page feed" that you can found here: ...
0
votes
1answer
17 views

Combine multiple menus using the filter wp_nav_menu_items

Is there a way to combine multiple menus in the functions.php file using wp_nav_menu_items()? I need to hook in a second menu to the main menu. The site has two separate menus in the header. One is a ...
0
votes
1answer
400 views

How do I change the URL returned by next_posts_link()?

I am integrating a WordPress blog into my existing portfolio, test.mysite.com. The WordPress default twenty twelve blog appears on test.mysite.com/blog/. I want to integrate WordPress functionality ...
0
votes
1answer
22 views

Get user by meta data key and velue

I have create custom user meta, but it was array how i can call only one of them by key like I want to get only course_id = 22 list. Here this my user meta array [certifications] => Array ...
1
vote
3answers
4k views

Automatically remove a canceled order in Woocommerce

Been looking around on this website and the internet but can't seem to find a solution. My client wants every order which has the order status cancelled to be completely removed out of WooCommerce ...
0
votes
1answer
10 views

Modifying the_posts_pagination from within functions.php instead of template files

I know that using a function like the following (in functions.php) allows me to customize pagination options: function custom_theme_pagination(){ global $wp_query; echo paginate_links(); } ....
0
votes
1answer
24 views

Trying to publish a little bit of Javascript on the homepage AND at the bottom

<script type="text/javascript"> function toggleDiv() { var triggeredDiv = document.querySelector('.triggeredDiv'); if (document.getElementById('myonoffswitch').checked) { ...
0
votes
1answer
7 views

Woocommerce singe product custom gallery output works just on the first slide

I copied the "product-image.php" to my theme folder in order to change the HTML output a bit, so instead of using wc_get_gallery_image_html I created my function and changed the output there. Here's ...
0
votes
1answer
30 views

Access to “My Site” is missing from the admin bar

You know there´s a direct access to every wordpress site right on the left side of the admin bar (or tool bar) once you get access to the wp dashboard which is intended to connect your website backend ...
0
votes
1answer
24 views

Getting the post terms 'wp_get_post_terms' per post when within the functions.php file

I have used a form with an Ajax action to pull post information through on submit. It works a charm. However, I have used categories to separate the work into categories. One of which is the brand. ...
0
votes
1answer
26 views

Contact Form 7 If Condition

I have used the following code to successfully redirect a form to an URL after submission using contact form 7. <add_action( 'wp_footer', 'redirect_cf7' ); function redirect_cf7() { ?> <...
0
votes
0answers
11 views

Problem with Showing Download Price

There is problem to showing the download price after using Discount pro plugin. As you see in Screen Shot below when we enable showing Show discounted price? in edd settings Price didn’t shown correct ...
0
votes
1answer
2k views

Load Post into DIV with Ajax

I'm loading posts via Ajax into a div that I have set up on index page. index page loop: <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div> <button ...
0
votes
1answer
413 views

How to get tags and categories?

I used the following code to get tags from the post and then simply echo them: $posttags = get_the_tags($post->ID); if ($posttags) { foreach($posttags as $tag) { echo $tag->name . ', ';} ...
2
votes
3answers
2k views

Attach a private function at a hook?

I have a class with some private & public functions. The thing is that I don't want some of the functions to be able to be called outsite of the class, so I want to make them private. But I need ...
0
votes
0answers
13 views

How to define multiple custom field values from $post_content

I was trying to find a way to input custom field values using the WordPress iOS app (since it does not support them at the moment) and I came upon a very nice plugin called CF setter that does just ...
0
votes
1answer
400 views

Help with my first Metabox helper class

I'm working on a metabox helper class and everything works well, but the radio image field. The images show up, but they aren't clickable. // Print radio_image input. private function ...
0
votes
1answer
407 views

Wordpress Jquery+scripts enqueue issue

I'm having some issues in loading a custom jquery slider into a wordpress site I'm working on: I'm not super proficient with theme development but I'm studying hard and I spent lots of days trying ...
0
votes
0answers
11 views

Logo custom width not implementing

add_theme_support( 'custom-logo', array( 'height' => auto, 'width' => 200, 'flex-width' => true, 'flex-height' => true, ) ); and function ...
0
votes
1answer
23 views

Check if post visited first time

How to check if post visited first time? If post already never visited by nobody.
0
votes
1answer
28 views

Enqueing External JS on the remote server JS

wp_register_script( 'custom-js', 'https://s3.amazonaws.com/codexo/custom.js', array( 'jquery' ), '1.1', true ); wp_enqueue_script( 'custom-js' ); Above is the function through which I am ...
0
votes
1answer
401 views

Ajax not working properly

I'm working an Ajaxifying form. This form is a custom page template. The saving of the data is working, but when the form is submitting, the page is redirects to websiteurl/wp-admin/admin-ajax.php ...
-1
votes
0answers
18 views

How to create Radio buttons on Dokan vendor new product creation page also already created pages

I am using the Dokan Multivendor Plugin. I want to add radio buttons on Dokan Multivendor New product creation page also the existing product pages. Here in WordPress wp-admin, I am adding ACF plugin ...
0
votes
3answers
1k views

Removing Unnecessary Text from Admin Menu without CSS

I am looking for a way to remove all the unessesary text from default worpdress metaboxes. Preferably I would like to ensure that the content is not just hidden through CSS but actually removed from ...
1
vote
1answer
50 views

Use of undefined constant bloginfo

I am a webmaster of a site which was made with WordPress. I don't know PHP. I changed PHP version from 5.6 to 7.2. Since this change, I have an error on my site : Warning: Use of undefined constant ...
1
vote
1answer
416 views

Dumping variable in custom pre_gets_post function in functions.php, returns NULL

Problem Summary: I am using firePHP to analyze my variables in a custom function, but it does not display their contents into the console as I would expect. I also used var_dump(), it returns NULL. ...
0
votes
1answer
33 views

add referrer to woo

we just moved from Shopify to Woo and wanted to add a custom field "referrer" to an order, to track our ads. I found this article, but somehow does not manage to make it work. maybe it is a bit ...
0
votes
1answer
445 views

custom COOKIE on custom page

i have problem with create function for set cookie dynamically. when i try in custom page i have of course header is set and i tried something like this: in custompage.php: myfunction($cookiename,$...
0
votes
1answer
20 views

Setting custom canonical urls

I have a page that requests and displays information from a database. All is fine but I'm having some trouble setting custom canonical URLs for this single page only and its URLs (with parameters ...
0
votes
1answer
8 views

Function for Sticky Post on Categories causes issues with 404 behavior

I want to how sticky posts on category pages and I am using a code on my function.php file in order to manage it. The sticky posts are being shown on the category pages, everything is OK. But with ...
1
vote
1answer
418 views

Ajax load more button for comments wordpress

I have my own Ajax load more button system but for posts now i decide to make the same thing but for comments so after check get_comments i found that i can't get the CURRENT page of comments like ...
0
votes
1answer
410 views

Backstretch.js and thumbnail sizes to reduce loading time

I am using backstretch.js to set a featured image as a full size background image (as per this tutorial). I would like to combine this approach with different thumbnail sizes in order to reduce ...
0
votes
1answer
418 views

How to load jQuery in TOP of wp_footer?

I have added this code to load Google hosted jQuery function replace_jquery() { if (!is_admin()) { wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery....
0
votes
1answer
440 views

Convert all uploaded PNG files to PNG-8 format

Running a high trafficed platform. In my quest to minimise bandwidth costs, I added a high JPEG compression on all JPEG uploads (check solution in my previous question). However, Wordpress does not ...
0
votes
1answer
25 views

How to redirect (301) trashed post to it's parent taxonomy TERM ARCHIVE instead of 404 page

I have a taxonomy called "Sports", that includes terms: Football, Rugby, Tennis... What I want to achieve is when (for instance) a post that has the term football is trashed and a visitor try access ...
0
votes
1answer
32k views

If user is logged-in display/hide something

I want to check at page load if the user is logged in or not and hide the login mask I programmed accordingly. There is a reason I'm using said login mask instead of redirecting to the WordPress ...
1
vote
3answers
908 views

How to output a PHP file values by shortcode?

I'm trying to output the values of two custom fields created by ACF plugin in a custom post type. I actually need this to be displayed in a popup window. wordpress popup plugins don't support php code,...
0
votes
1answer
29 views

providing access to post_id or post inside functions.php

I'm trying to add metaboxes to the bottom of any post which is created from a specific post template. ie I don't want metaboxes on all my posts, just certain posts. At the point when I decided to ...
0
votes
1answer
14 views

add_filter function concatenate string and locate_template function

I am trying to inject a small php component to the end of my main site navigation. I have written this filter: add_filter('wp_nav_menu_items', 'add_css_switcher', 10, 2); function add_css_switcher(...
1
vote
1answer
422 views

how to en-queue jQuery to load before the </body> tag

I've enqueued all my scripts on function.php to load before the tag by passing 'true' to the fifth argument. It does works for all of them BUT jquery, any idea what I'm doing wrong? ...
1
vote
1answer
421 views

Skt full width basic slideshow problem

Background: I am making a photography website and thought that skt full width is a good theme for the landing page. It worked out all right. Then I started to get fancy. I wanted my client to be able ...
3
votes
1answer
2k views

Slugs as breadcrumbs for Pages

I´m trying to create a function that creates a breadcrumb trail of Page slugs outside of The Loop. These breadcrumbs show the path from the homepage to the current (sub)page. For example, on the ...
0
votes
1answer
25 views

add code in functions.php will slow down the Execution speed?

I put these code in functions.php to custom what I need. before I add these code,the back_end`s ttfb is 746ms. after adding,the ttfb is 3.6s !!! speed becomes slow obviously! Is there any way to ...
0
votes
1answer
445 views

Update to functions.php not showing in dashboard

Some time ago, I added the following lines to my custom theme's functions.php file, in order to allow authors on my site to edit posts and drafts from all users: function add_theme_caps() { $role = ...
0
votes
1answer
23 views

Strip div From Excerpt

I have the_excerpt() in a specific page, I need to strip a div and keep the text, but only in the excerpt of that page. I believe I need to create a function with custom excerpt, but I don't how to ...
0
votes
0answers
46 views

How to offset main query without affecting other queries and backend

I'm trying to offset my main blog query by 3 posts whilst trying to get the pagination to function correctly. I've been following the codex reference here but I'm struggling to get it working as I ...
0
votes
1answer
14 views

Defined function isn't showed on page

I've defined a function in function.php and then I tried to call it but it's not visible when I call it. This is the function function social_sharing_buttons($content) { global $post; if(!...
0
votes
2answers
26 views

Woocommerce image sizes missing from Appearance › Customize but not declared by theme

I would like to resize the 100px x 100px store thumbnail images. The sizes are supposed to be set under Appearance › Customize › WooCommerce › Product Images These size settings are missing. After ...
0
votes
1answer
464 views

Rewrite permalink for multiple post types (CPT) with taxonomy term

I need your help. I need to create a similar structure mentioned on this thread and below are the details of my project requirement: I have three custom post types, let's say company-directory, video ...
1
vote
1answer
83 views

how to fix Warning: Use of undefined constant _ - assumed '_' (this will throw an Error in a future version of PHP)

Warning: Use of undefined constant _ - assumed '_' (this will throw an Error in a future version of PHP) in D:\xampp\htdocs\keuangan_rs\aksi_konten.php on line 52 elseif($aksi=="edit" AND $_POST['...