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)

1
vote
0answers
55 views

WooCommerce email shipping text value

I'm attempting to use the 'woocommerce_order_shipping_to_display' filter to show 'Free' in the WooCommerce email table when no shipping charges will be incurred. In the image, I'm trying to get 'Flat ...
2
votes
2answers
136 views

Display 4 chronological posts starting with a random post

I know that I can display 4 random posts by doing something like: get_posts('orderby=rand&numberposts=4');   What I'm trying to achieve is starting with a random item, but then showing ...
0
votes
1answer
83 views

There is no existing custom fields' value in functions.php

I'm using WooCommerce and Advanced Custom Fields plugin. I have a function for calculate my product's discount, like this: function woo_add_cart_fee() { global $woocommerce; $discount = ...
0
votes
0answers
14 views

How to get all the posts to a image (media)?

I would like to fetch all the posts in which a particular image is used. Lets say image_xya.jpg is attached in following articles- Article 1 Article 2 Article 3 Now I would like to display all ...
0
votes
2answers
27 views

I can't enqueue my scripts - They literally aren't being added to my site

Ok, I've literally copy-pasted different enqueueing code from about 5 different sources (Including wordpress), and not a single one works. Here's the code I'm using in functions.php: <?php ...
0
votes
0answers
16 views

Need some Tweak my nextpage Function

How I can get the next post URL when I'm on the last page ? e.g. I want go to the nextpost when i'm on the last page... This code need some tweak... Here is my Function: function next_page( $i ) { ...
0
votes
0answers
25 views

Login with user in custom created table

I was trying to add more features in login page, that i created a extra "myusers" table and trying to add two tabs in login screen,with the second tab i want login using my created users in 'myusers' ...
0
votes
0answers
15 views

How do I display continuous loop of multiple (4) previous adjacent posts while viewing the current post

I found a great article that enables me to display previous 4 adjacent posts here: Getting the Next and Previous Posts Titles in the Sidebar? @sorich87's explanation works great for me on my website. ...
0
votes
0answers
25 views

wp_delete_comment is doing nothing

I'm using front page delete links for users to delete their own posts and comments. The links are generated on the page like this : <a href="#" data-id="<?php the_ID() ?>" ...
0
votes
0answers
119 views

Image rotation issue (horizontal picture uploading as vertical) — Exif issue?

I am building a classifieds site on WordPress where users can upload their ads/images from front-end. However, when horizontal pictures are uploaded, they upload as vertical. I looked into the issue ...
0
votes
1answer
56 views

Define PHP variable from a seperate API if statement

I am trying to put together a function that will echo certain text based on a range of numbers. One of number(s) I am trying to compare against is echoed in my template as such -- <?php if ( ...
0
votes
1answer
21 views

Fail to get the total number of posts

I would like to get the total number of posts by the following code: <?php $published_posts = wp_count_posts()->publish; echo 'Total posts: '; $published_posts; ?> The result ...
0
votes
1answer
115 views

How to use get_posts() function in functions.php

I am trying to load posts with ajax. But I am not getting any content of the posts. I am not posting my javascript since it is pretty straight. Here is my code in inc/helper-functions.php which is ...
0
votes
0answers
23 views

weird redirect from Movable Type installation

I'm helping a friend moving his blog from MT to wordpress, in order to do so I have created a truth table on the database (rosetta) by looking at all the old static files and I've created a relation ...
0
votes
1answer
64 views

Add the title of a widget as an ID - for anchor links

I'm currently building a WordPress theme where my page consists of widgets. One widget is a part of the page. I'd like to be able to use anchor links with them, and to do this, I would like to output ...
0
votes
1answer
26 views

New functions in separate directory — better, portable way

I am just now learning WordPress theming as I have time. Currently I have a bunch of overrides for many woocommerce defaults in my theme I have: // CUSTOM FUNCTIONS require get_template_directory() ...
0
votes
1answer
28 views

hide shortcode using hooks

Hi i'm trying to hide a shortcode using hooks, my shortcode is this [abc] I have use this code: remove_shortcode( 'abc' ); this code above removes the shortcode but when i refresh the page I can ...
5
votes
1answer
158 views

How to get the image EXIF date/time and use it for the WP post date/time

I currently have the following working function. add_action('add_attachment', 'create_post_from_image'); function create_post_from_image($id) { if (wp_attachment_is_image($id)) { $image = ...
0
votes
0answers
140 views

WooCommerce order bulk edit with custom hooks in function.php

I'm working on a Wordpress site with WooCommerce. I have to implement some additional functions, one of them is some simple operation after marking the order completed. I use ...
0
votes
1answer
39 views

Disabling visual editor on a specific post

I would like to disable the visual editor for post id 416 on my local WordPress installation, to do so (following this answer) I added: add_filter( 'user_can_richedit', 'wpse_58501_page_can_richedit' ...
0
votes
1answer
34 views

Problem with comments_number()

The following code: echo '<ul>'; while ( $query->have_posts() ) { $query->the_post(); $title = get_the_title(); echo '<li>' . $title . comments_number() . ...
0
votes
1answer
48 views

How to add schema markup to WordPress menu function

I would like to add to my main nav items and it seems like the only way to do that is by changing the menu function. Below is the structure I am trying to implement: <ul itemscope ...
1
vote
0answers
64 views

Customize WordPress Media Manager - Media Window

Im trying to customize the wordpress media manager "add media" window to get it as simple as possible to use. So i want to disable/ hide the following fields/ functions because i dont need some or ...
0
votes
0answers
15 views

Intercept an image before it's uploaded to Media Library

I've got a WordPress website where I need to have some posts with gifs as thumbnails. After researching this topic a bit I realized that I have to intercept the gif before it's passed into Media ...
0
votes
0answers
37 views

How to wrap all elements in a div inside a post

How to wrap all elements in a div inside a post? eg <p>...</p> <h1>...</h1> <img> turns to <div class="para"><p>...</p></div> <div ...
0
votes
1answer
65 views

wp_usermeta - Read from database, but save function broken

I added a custom field to the profile-page of WordPress users called "uidnumber" and it reads values from the database just fine, however it just doesn't save anything. I'd rather save it in ...
0
votes
0answers
29 views

Follow author on muti-user WordPress site

How to add follow author function on muti-user based WordPress site? I fount this page but couldn't get it to work or understand how he got this working. Making Wordpress author follow button, need ...
0
votes
1answer
40 views

Pagination on Custom Post

I'm trying to figure out how I can display pagination on my wordpress template. Here is my work in progress. So far the page link doesn't show up <div class="eight columns"> <ul> ...
0
votes
1answer
88 views

How to override filter in child theme?

I'm trying to override a parent theme filter in a child theme; I must have the syntax wrong as the override is being completely ignored. Here's what's in my child theme's functions.php: //* remove ...
0
votes
1answer
101 views

Problem with hidden products on woocommerce

I'm dealing with a common problem for what I saw. When I hide "Out of stock" products, they keep counting on the pages. For example: I show 24 items per page, if 10 are out of stock and I hide them ...
0
votes
3answers
102 views

Get array of metakey in all posts

My posts contain a meta-field that holds an external id. I'm trying to create a function with a loop that goes through all posts and puts all the meta-keys in an array and returns this array. This ...
0
votes
1answer
69 views

remove/hide wp-editor

I have created a meta-box for a certain page_template. So if the adminpage is loaded with the template it shows the metabox. This does not require the wp-editor to add content. So I would like to ...
0
votes
1answer
54 views

How to rename “Publish” metabox title in post screen

I've looked everywhere trying to find how to rename the "Publish" metabox title in the WordPress backend post screen. There's help for every other metabox for changing titles and there's help for ...
1
vote
1answer
103 views

Converting html to wordpress images not showing

I am trying to convert a html page to wordpress but I am stuck on a few issues. Images I add to gallery and try to display on the pages don't appear. Slideshow doesn't appear. Note:If I use the wp ...
0
votes
1answer
24 views

How to use wp_list_categories with plugin category?

Attempting to use: <?php wp_list_categories( $args ); ?> And this works fine to display a list of the default Wordpress category group used for posts(?) but I'm looking to pull a category ...
0
votes
0answers
68 views

Override Wordpress Timber Template locations for Woocommerce

I need to overwrite the page template locations for Woocommerce using timber Wordpress. To change the location for the twig files was no problem. All page Templates are stored in the theme root ...
0
votes
0answers
32 views

wp_enqueue_scripts - force .js file to be last included file after plugin js files

I need to include a custom jquery script and need this to run after everything else. I have included it using the following code in the functions.php file: function add_custom_scripts() { ...
0
votes
0answers
11 views

Custom html for uploaded images [duplicate]

I'd like to make life easier for the guy who is going to upload posts on a wordpress site. The default html that is created upon upload doesn't work well with the design of the site, so I'd like to ...
0
votes
1answer
82 views

Using fwrite() and “a” appends multiple times instead of once

I'm doing some testing as I'm new to PHP and Wordpress. On refresh the following code runs functions.php <?php $content = "some text here\n"; $fp = fopen($_SERVER['DOCUMENT_ROOT'] . ...
0
votes
0answers
24 views

Customize theme, woocomerce registration, What hooks to use?

I'm using this theme http://wp.contempographicdesign.com/wp_automotive_2/ for a project and now the clients want more specific changes 1.- The user needs to have a subscription plan in order to post ...
0
votes
0answers
41 views

WordPress registration: checking external database to see if name/email exists, then show error message

During registration (creating a new user account), in addition to checking the wordpress database, to see if user name or email already exist, I want to also check an external database. My code ...
0
votes
1answer
63 views

How do I hook into the container of wp_nav_menu?

I know I can edit the items within the wp_nav_menu by declaring a custom walker, but I want to add some code just inside the container, which isn't handled by a walker. It's in ...
0
votes
0answers
47 views

Is it OK to include files using ABSPATH?

I was using the following: get_home_path(); in my functions.php as referenced in the docs – but I get the error: Call to undefined function get_home_path() in ... I'd like to include a file using ...
1
vote
0answers
42 views

Attempt to change jQuery version caused White Screen of Death

I'm working on a client's WP installation, and I'm attempting to replace the default jQuery library included with WordPress to a newer version. I inserted the following script into the site's ...
0
votes
2answers
33 views

How to use theme function in post/page?

I want to be able to reference the theme directory in a page/post using php code. I don't know how to do this with WordPress but other CMS use something like a path_to_home php variable like <img ...
1
vote
1answer
163 views

Add itemprop Schema.org Markup to li Elements in wp_nav_menu

I currently call menus with a basic wp_nav_menu code: <?php wp_nav_menu( array('theme_location' => 'primary') ); ?> I am trying to find the easiest way to add itemprop="url" to the line ...
0
votes
0answers
55 views

Author info does not show up when author has no posts

When author has no posts, it does not display author name or bio (below code). I tried http://codex.wordpress.org/Author_Templates#Custom_Author_Information but it give me Notice: Trying to get ...
0
votes
1answer
52 views

str_replace function in theme

I am trying to change the color to red on certain words on my site. However the below code changes each word to "array". Can someone tell me what is wrong with my code? function ...
0
votes
2answers
60 views

Add Top-Level Menu that opens URL

Below code adds My Page button in Admin Menu. It will take you to your author page when you click on it. However, it also opens up new page(Empty page). I want it to just take you to author page and ...
1
vote
1answer
73 views

Is it possible to change any of the HTML/URL returned from the_category()

I've found this is on of my theme files: <?php the_category( ' ' ) ?> Ideally I'd like to wrap the whole thing in a function and replace some of the URL's being output, but I don't seem to be ...