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

Get author meta of all writers

We know from the docs that you can get an author's meta like so: <?php get_the_author_meta( $field, $userID ); ?> But I would like to have a custom "About us" page which displays all the ...
0
votes
0answers
27 views

Strip <p> on get_the_content_limit

I would like to remove the paragraph tags < p > it generates, i tried adding strip tags but it doesn't seem to work. function the_content_limit( $max_characters, $more_link_text = ...
2
votes
1answer
323 views

Post thumbnail relative link and HTML modify

I want to remove the website url from all the_post_thumbnail() so they become relative and remove/add attributes from the output. So far I got the following code added to functions.php of the theme, ...
0
votes
0answers
36 views

How to define a product on sale on WooCommerce programmatically [on hold]

how are you? I'd like to define a WooCommerce product on sale programmatically, just using function.php and having the ID of the product. I did some searches in the WooCommerce documentation but it ...
2
votes
1answer
394 views

How to generate and display widgets areas dynamically?

I want display different content in sidebar for every category, but as I create new ones I have to create the area for it. How can I have widget areas for every category and also display them on theme ...
0
votes
1answer
40 views

send email to all registered users when post expires

I have a function which, when a post is published inside a CPT after three days the page is redirected to another URL/PERMALINK. This is the code: add_action('template_redirect', ...
0
votes
1answer
14 views

Function to erase every post from a taxonomy

I'd like to have a piece of code that erase every single post from a taxonomy of a post type when triggered. How can I do it? Thank you.
0
votes
2answers
22 views

Expected 'add_filter' (T_STRING)

I am trying to add a filter for get_avatar so I could implement an avatar alignment but when I do, I received expected 'add_filter' (T_STRING First Approach add_filter('get_avatar', ...
0
votes
2answers
201 views

How to redirect non-logged in users to a specific page?

How to redirect non-logged users requesting for a specific page/URL to another page/URL and display a message like "for members only". I know its quite easy to code using !is_user_logged_in() ...
0
votes
1answer
44 views

save_post not working

In order to create (or update, whenever a post is updated) a unix-timestamp meta, I used following code to fire on save_post. I pasted this code in functions.php. But I believe this is not working, ...
0
votes
0answers
34 views

Show Custom Post Type Results

Hopefully someone can help me here. I have a custom post type and with this post type I am able to show the title in a select option. Now what I want to happen is when that title is selected it will ...
-1
votes
1answer
30 views

reusing code in function and running it with loop

In variable.php , the page use to display any attributes related to a product. I want some changes in code but not for all pages, so i think only point it to create a function of variable.php, and ...
0
votes
1answer
44 views

Include a file that has a function in it

I am using include 'filename.php' to load a php file into a template file, simply because the original PHP template file was getting huge and I wanted to split up the sections into different files for ...
0
votes
2answers
62 views

Using <!--more--> tag to output text in Genesis?

here's what i'm trying to achieve! HTML: some text <!--more--> some text when post is loaded: some text MY TEXT WHICH WAS ADDED TO THE MORE TAG some text on my old WP site, i used this to ...
0
votes
1answer
20 views

Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?

I'm in the process of creating a leveled tutorial structure in WordPress and want to build it so that it sets up the front-end with no code needed from the user. So far, I have a custom post type ...
0
votes
2answers
62 views

Order get_users() by last login date. Is it possible?

I want to create a page that displays all the blog users ordered by the last login date. I've tried with the get_users() function and I can succesfully get the users' list, but not in the order I ...
0
votes
3answers
72 views

Redeclare function (override) [closed]

What is the best method, to change the previously declared function into the new one? for example, there is already declared: function smth(){ echo 'aaa'; } and i want that it displayed not aaa, ...
4
votes
2answers
820 views

Set JPEG compression for specific custom image sizes

I use various custom image sizes (by add_image_size) and I have set my JPEG compression to 30% with this filter: function jpeg_quality_callback($arg) { return (int)30; } add_filter('jpeg_quality', ...
-1
votes
2answers
28 views

Custom Post Type Search

I am new to wordpress and need to modify the default search functionality. What file do I have to look for or provide me with some tutorials.. Any help would be much appreciated
0
votes
1answer
109 views

how redirect users to custom login page when “login to reply” is clicked? [duplicate]

I am building my website on Wordpress and I have created my custom login page.But for a post when an user comments and other nonlogged see the comment with along with a line down "Login to reply".And ...
0
votes
0answers
20 views

How to Overwrite validate_plugin function

How can I overwrite the WordPress validate_plugin function. I need to disable that function alone for my plugin, and it should not affect any other plugin. I don't want the validate_plugin function ...
0
votes
2answers
35 views

What's wrong with my use of plugin_url()?

I keep getting the following message in the browser Fatal error: Call to undefined function plugin_url() in My code at present: add_action( 'wp_enqueue_script', 'load_jquery2' ); function ...
1
vote
4answers
7k views

How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?

I'm building a plugin and I want to add bits of javascript in the admin head but only for certain admin pages. I don't mean pages as in a WordPress page that you create yourself but rather existing ...
0
votes
2answers
31 views

Including php files within template

Let's say in my theme functions.php file, I included a php file that's only accessible in the admin control panel and named theme-options.php. require_once ( get_template_directory() . ...
1
vote
2answers
258 views

Filtering out the #more anchor link that gets produced by <!--more-->

Back in my naive days of theming, I had to make it so the link inserted by <!--more--> wouldn't dump the viewer at the anchor it produces. I made a dinky plugin that consisted of: function ...
1
vote
2answers
84 views

Programmatically Set First Image as Featured

I have over 400 posts with images inside them, I have got a new template which requires a featured image for each post, something my last template did not require... I am wondering if there is a ...
0
votes
1answer
34 views

When Author add new post change default status to pending

Same as above when Author add new post change default status to pending instead of published
0
votes
0answers
146 views

How do I remove code from Genesis Framework?

From the Genesis Framework framework.php template, I want to remove genesis_markup( array( 'html5' => '<div %s>', 'xhtml' => '<div id="content-sidebar-wrap">', ...
0
votes
0answers
64 views

Add link to Shopping Cart on Woocommerce's Checkout page [on hold]

My question is a simple one, I think. I want to place a link or button on the Woocommerce Checkout page saying "Return to My Cart" (obviously linking to the cart page) but I want it placed just after ...
0
votes
1answer
1k views

Disable single post page

Is there a way to disable single post page, for example when some tries to go to single post page to show 404 page.
0
votes
2answers
404 views

Code to auto expire posts after 30 days

I've tried the plugins that are available in the Wordpress plugins section but they seem to fail miserably. Initially, I used Auto Post Expire By User Role which worked for a time, but for some reason ...
0
votes
0answers
101 views

Set thumbnail from URL, by grabbing image in functions.php

So I've written a whole bunch of functions, which are used to display Vine videos. I then have a shortcode which outputs the code. The last thing I have to do is set the post thumbnail. I want to be ...
1
vote
1answer
153 views

Add description text under input field for new profile fields

How can I modify my following code to add some description text under the input fields? I tried modifying it as you can see with the facebook url field but the text shows up under the field label and ...
0
votes
1answer
438 views

Why a SlideShow (made using JQuery FlexSlider) can't work if I load it form functions.php but work if I load it from my footer.php file? [closed]

I have the following situation: I am carrying this pure HTML theme (that use BootStrap CSS framework) into a WordPress theme. This is the original pure HTML demo theme (I have the entire source code ...
0
votes
0answers
15 views

Function that returns all pages that uses a specific page template? [duplicate]

Is there a function that gets me all pages that uses a specific page template? Something like this maybe: get_posts( array("type"=>"page", "page_template"=>"my-template.php") );
0
votes
0answers
101 views

Call wp_create_user function from external?

I want to create New Users from external. I've found this is function in wordpress: wp_create_user( $username, $password, $email ); So how can i run this function from external call please? I ...
0
votes
2answers
60 views

Why I can't load my JavaScripts using an hook inside my functions.php file?

I am pretty new in WP (I came from Joomla) and I have the following problem: I am carrying this pure HTML theme (that use BootStrap CSS framework) into a WordPress theme. This is the original pure ...
1
vote
3answers
10k views

How to set and use global variables? Or why not to use them at all

UPDATE: My original question has been solved, but this is turning into a valid discussion about why not to use global variables, so I am updating the question to reflect that. The solution was ...
-2
votes
1answer
34 views

Changed functions.php file and now site is blank [closed]

I tried to change the functions.php CSS page, commenting out the original load fonts function and replacing it with my own. Now, when I try to access the site, I just get a blank page. Even worse, ...
-1
votes
1answer
21 views

What is wrong with this dbDelta syntax?

I know there's a million questions about this, but I've searched a bunch and haven't found any solutions that fix my problem. This is the function which I hook upon plugin activation: global $wpdb; ...
1
vote
2answers
2k views

Load post with a different template?

Let's say I have a single.php file with a certain layout (graphic intensive). I want to create a sort of plain-text version of the same page that is only called when the user clicks the provided ...
0
votes
0answers
19 views

Wordpress Native Function To Show Publish Box, Select Categories Form etc On Plugin Page

The picture above showing the default forms those are available on metabox of wordpress post/page editor screen. Is there a wordpress native function to show those forms on a custom plugin page ...
0
votes
2answers
73 views

Load parent theme files before child theme functions.php

I am creating a theme framework to use in future wordpress themes that I develop. I would like to include dependant files such as classes inside the parent theme before the child theme functions.php ...
0
votes
1answer
32 views

Syling Custom Fields echo's from from functions.php

With the help of User Borek I've managed to get Custom Fields displaying on my siteby putting the below in the functions.php: function custom_field_before_content() { if(is_page() || is_single() || ...
0
votes
1answer
28 views

Overwriting a Shortcode

I have a theme that extends the Visual Composer plugin with a slider on the front page. The slider will show five testimonials from five different customers. I want to add the featured image of each ...
1
vote
1answer
42 views

Adding a class to tag list in a function

How can I add a class to the function so I can style the output tags as boxes in css? <?php if(get_the_tag_list()) { echo ...
-1
votes
1answer
31 views

Display Video as Post Thumbnail

I use the Nova free theme, from the Theme in Progress studio. I would like to display a video like a thumbnail image, as shown in this theme http://themeinprogress.com/demo/sueva/ How can I do this? ...
0
votes
1answer
44 views

How to use get_template_directory_uri() to load an image that is in a sub-folder of my theme?

I am pretty new in WordPress and I have the following doubt about how to insert in my homepage an immage that is in a subfolder into my theme directory. So I have the following situation: Into my ...
1
vote
1answer
800 views

Image media upload metabox

I've created my first image upload metabox but seem to be having problems. The data doesn't get saved when I add an image then update the page - I'm sure this is a typo on my end which I'm failing ...
0
votes
1answer
30 views

fire action when post is being edited as well as saved?

I'm trying to fire some code when a page is edited and/or saved. This code works: add_action( 'save_post', 'add_promoted_meta_data' ); function add_promoted_meta_data( $post_id ) { echo ...