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.

learn more… | top users | synonyms (2)

0
votes
2answers
492 views

Possible to register multiple custom taxonomies in one function?

I'm registering 7 custom taxonomies in my functions.php. Since each function uses the same labels and arguments and is attached to the same Custom Post Type, I'm wondering if it's possible to register ...
0
votes
1answer
18 views

To make some div display for a longer time

I have this code to display some of my div for 1 day then disappear. This code to be placed in functions.php function post_from_today_class($class) { //add .new-post-today to post_class() if newer ...
1
vote
1answer
451 views

Current path on page in functions.php

How can I get the current path of my page? I know how to do it inside a template file, but I need it inside functions.php. And it has to be before the send_headers hook, because I'll use this info to ...
0
votes
1answer
58 views

How to get subscription key or id using Woocommerce Subscriptions

I need to get the subscription key of a particular subscription to pass into a custom function. I have referenced the documentation where it shows how to get the key, but I have failed to integrate ...
-1
votes
1answer
26 views

Rename file after title , one small problem

I'm using this question: Change Attachment Filename which works but it has a problem. He renames every file with FileNameToRename and it's same image. What I want to do is instead of FileNameToRename ...
0
votes
2answers
29 views

How can I use custom menus with a Bootstrap WordPress theme?

I have this 'primary' menu with a few items in the CMS, which I can list nicely with this PHP code: $args = array( 'theme_location' => 'primary' ); wp_nav_menu( $args ); The PHP outputs ...
0
votes
1answer
22 views

Getting a 404 on single custom post type page when using rewrite on a custom taxonomy

I am getting a 404 on my single custom post types whilst using the 'rewrite' option in the custom taxonomy. If I take the rewrite out the single page works but the custom taxonomy archive then 404's ...
0
votes
1answer
16 views

Custom posts password protect

my site is highly based on clients and we want to have very strong password protection for a certain custom type post. We have a custom type post named "something" and here is it's declaration: ...
0
votes
0answers
61 views

Force update all posts in custom post type, no content changes

I have imported data from a custom post type that has location data for a map plugin (Progress Map). I have about 500+ posts each with different location data. For some reason the location data isn't ...
0
votes
1answer
22 views

Allow BBPress participant role to trash topics

I have a small project with BBPress roles, here is what needs to happen if at all possible. Participant Role Participants should be able to trash posts. Participants should be able to restore ...
0
votes
1answer
18 views

Search and Replace Script Loader in Head Only Works in Footer

I've got a function that uses script_loader_tag filter to search and replace adding asynch="asynch" attribute. It works. I don't want this doing anything in the footer, but rather the header alone. ...
3
votes
4answers
10k views

Ajax call always returns 0

I have a problem with AJAX returning 0 always! I have done everything by the book and can't figure out what is wrong? Please help!! Here is my Ajax call: //Pass data through AJAX var ...
0
votes
0answers
38 views

Benefits of Using Wordpress Methods over Straight SQL Queries

I am building a "wrapper" front-end for Wordpress. My thoughts were that simply using PDO to run all queries would make the processing much much faster. Of course what this means is that I miss out ...
0
votes
0answers
21 views

Woocommerce subscription hook after renewal

I have a web store where users can purchase subscriptions (1 month, 6 months, 1 year). My store uses Woocommerce Subscriptions v2.0.8. What I want to achieve is when a subscription is renewed, I want ...
0
votes
0answers
26 views

How to add a description of the shipping method, woocommerce?

How to add a description of the method of delivery. Like payment methods Is it possible to add textarea in the admin panel for editing shipping method? Thank you
0
votes
1answer
28 views

How To Display Category list from Portfolio post type plugin?

I'm new from WordPress development. I want to display portfolio category list in my theme, I'm useing portfolio post type plugin what must I do ? what code or WordPress function must implement in ...
0
votes
1answer
33 views

How to overwrite template.php file

I'm using a child theme for my website. I tried to enqueue template.php file wich exists in includes folder but making any change in the template.php file of the child folder didn't affect pages. ...
0
votes
0answers
34 views

Remove html content from Auto-Generated Excerpt

I've a website that syndicates content, and each article gets prepended with html content similar to "From Source A:" Wordpress obviously strips the html from that content when auto generating the ...
0
votes
1answer
213 views

Get all categories of custom post even not assigned

I know how to get all categories with get_categories and name custom taxonomy name, but wordpress only shows those categories those are assigned to a post. Those which are created, but not assigned, ...
-1
votes
1answer
17 views

Custom shortcode not being included in content paragraph [duplicate]

Ive created a custom shortcode via functions.php to display a phone number in the content when the shortcode is used in the WYSIWYG field. function contact() { $contact = ...
0
votes
0answers
43 views

Help needed with Wordpress Function/Loop please

I mostly come from a Front End/Design background and have built a few sites in Genesis/Wordpress but I am now delving into the world of making Custom Posts and pages through using a variety of ...
0
votes
1answer
42 views

How to get the original price of the product in woocommerce?

I have created the code to loop through the product list and display the price $args = array( 'post_type' => 'product', 'posts_per_page' => 100, 'product_cat' => 'hot-deals'); ...
0
votes
0answers
24 views

Featured image in custom post is being disabled

I'm trying to create a custom post as a plugin and so far I'm having some trouble trying to enable featured image on my custom post type. Right now I have created two custom post types but the problem ...
0
votes
0answers
27 views

Override Class in Child Theme

I'm trying to customize a theme using Child Theme but I can't find a way to override this class, anyone can help me ? I've tried if ( ! class_exists('Extra_Page_Post_Settings_Meta_Box extends') { // ...
0
votes
2answers
37 views

is_preview() always return false

I'm just starting out on a new Wordpress project and for some reason I can't get the previews working. I have disabled all of my plugins and still i always get false when using is_preview(). ...
0
votes
1answer
30 views

Code to insert code into single php

I'm using a plugin that puts stuff on my single.php page. I can turn off this stuff by inserting <!--code--> in the text side of the editor for any single post. I want to do <!--code--> ...
1
vote
1answer
53 views

Enabling post thumbnails for custom post type

I'm writing a custom post type as a plugin and trying to figure out how I can enable post thumbnails within plugin documentation/template instead of enabling it in the functions.php. I tried adding ...
0
votes
1answer
48 views

linking stylesheets and scripts with functions.php

I am following along with this tutorial. I am trying to link the javascript and css files that are usually linked in the header using wp_enqueue_scripts in functions.php. With what I have now, only a ...
0
votes
3answers
114 views

Check if Page Slug Exists, then display that Page's Title

Came across this function to check if a page exists by its slug and it works great function the_slug_exists($post_name) { global $wpdb; if($wpdb->get_row("SELECT post_name FROM wp_posts WHERE ...
3
votes
1answer
54 views

Display more recent and less recent posts in same category

Is there a way to display not just the-most-recent posts in a category, but the 3 posts in a category more recent (time-wise) than the current post? For example, Jan10post Jan15post Jan17post | ...
0
votes
0answers
15 views

Wordpress Costums Field Comment Box on Admin Page (Post Editing)

can help me about wordpress comment field on post editing in admin page? i want to change the default form like picture above : to like this...
0
votes
1answer
30 views

Image Crop Not Working

I am building a custom WordPress theme. I am using Advanced Custom Fields to have an area for the user to upload custom images. This is what I have in my functions.php file. My images aren't taking ...
0
votes
1answer
323 views

echo value from 'select' field type into page template using cmb2?

I'm using CMB2 plugin to add metaboxes into a custom post type. I'm adding the additional metaboxes via functions.php onto child theme. It may worth to mention that parent theme/custom post already ...
0
votes
1answer
38 views

add_rewrite_rule with bottom priority doesn't handle the Wordpress pages

I have a php file named test.php that outputs the page querystring parameter. I want to use add_rewrite_rule to serve my php file, while the WordPress pages which exist already or will be created ...
0
votes
1answer
58 views

How to append to title via functions.php for auto-posting plugin [duplicate]

What I've got so far I've finally got the functions.php plugin to append a string to custom post titles of a certain post type with this function: function append_album_review_to_title( $title ) { ...
0
votes
1answer
43 views

How add body_class from wp_termmeta

I need to assign a class to the body for woocommerce categories. What I've done: // add the fields when the term is created add_action( 'product_cat_add_form_fields', 'add_product_cat_class_field', ...
0
votes
0answers
42 views

How do I output the returned value of a function that uses an earlier hook?

If I define a function that retrieves a value within an action hook and returns it, what is the best way to call the function in a later hook? My general aim is to write reusable functions with ...
1
vote
1answer
32 views

Pages should have priority when using add_rewrite_rule

I'm using the following code to have dynamic pages function custom_rewrite_basic() { add_rewrite_rule('^prefix-(.*)', 'foo/bar/index.php?page=$matces[1]', 'top'); } add_action('init', ...
1
vote
3answers
456 views

Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php?

Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php? I have a mu-functions.php file in the mu-plugins folder. One function calls a javascript file (alerts.js) located in ...
0
votes
0answers
24 views

Woocomerce update variation sale price in functions

i need to write simple code that changes sale prices automatically. Got a lot of products, and sometimes we got promo for one variation of the specific product. Basically, what my codes does its ...
0
votes
1answer
28 views

Using two loops in one Wordpress template

Hi I am attempting to use two loops in my WP template as I am using advanced custom fields to display info from a custom post type (college) I have tested my code (label 'loop which doesn't work' ...
1
vote
2answers
60 views

override pluggable.php functions

I just not only want to override a pluggable function (wp_new_user_notification) but I want to make sure that if any other plugin is overriding the same function, so my function , override that too or ...
0
votes
1answer
57 views

How to display content If function exist/condition true?

I've created my custom posts. Data from the same is displayed in let's say single-custom-post.php. Now to clean that file and to remove 100 lines of code, I want to make a new file (let's call it ...
0
votes
0answers
14 views

Getting autoset_featured image to jive with Facebook SDK

I'm trying to set up the Facebook SDK on a site where I'm auto-fetching the first image in the article to become the "featured-image". I would like that auto-fetched image to also be the og:image, but ...
0
votes
1answer
30 views

Multiple navigation menu in same location

Is it possible to have multiple menus in same location but on different pages. My pages are now: cars --car details --car specs motorbikes --motorbike dealers --map --contact Plus about 20 other ...
3
votes
5answers
9k views

Why isn't is_page working when I put it in the functions.php file?

I have page called "Apple", the page's ID id 2533. In page.php file I have line: echo $bannerimg And this function in functions.php: if ( is_page( '2533' ) ) { // also tested with ...
8
votes
2answers
9k views

Remove “Category:”, “Tag:”, “Author:” from the_archive_title

I have the following code in my theme's archive.php: <?php the_archive_title( '<h1 class="page-title">', '</h1>' ); ?> This gives me titles like "Category: Russia", "Tag: ...
1
vote
1answer
194 views

I would like to use create a function in my custom plugin to tell WP to use a different header

I am well aware of the use of child themes for this. I know about get_header($name). I already understand the use of conditional tags. I want my plugin to remove the function: function get_header( ...
0
votes
1answer
1k views

Add a custom function to widget code

Hopefully, this is an easy question - I'm just a bit confused. I've got a custom widget with the usual structure: class My_Widget extends WP_Widget { function My_Widget() { // widget actual ...
1
vote
1answer
31 views

WooCommerce add_action hook results in 500 error

I am trying to add a line of text on the checkout page of the store that will go immediately after shipping row. I added the following to my child theme functions.php file: add_action( ...