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
3k views

How to access global variable $menu inside a class function

am puzzling why can't i access the global variable $menu inside a php class function class adminMenus { public function getWPdefaultmenus(){ global $menu; return $menu; } } using ...
0
votes
0answers
28 views

I want to add values ​of a function in all posts in a particular category

I want to add values ​​of a function in all posts in a particular category, I get exactly what I want, but not the old problem appears in post_content(edit mode em dashboard) ...
1
vote
1answer
926 views

Auto Populate Custom Field with Complex Value That Increase by One?

Can somebody help me to sort this? I am using WP 3.5.2 and I have "Orders" post type where purchase_order custom field is located. This is the sample of purchase order record: POCOS20130051 PO - ...
3
votes
1answer
857 views

Remote upload file to server B

I'm aware this might be some of the hardest coding to do ever, but thought of giving it a try. Im basically trying to detect all (mp3) filetypes uploaded through the Wordpress media upload and send ...
0
votes
0answers
23 views

Sanitization Function in Wordpress (Example Twentyfifteen.1.4 Default WP Theme)

The ThemeForest Submission Requires some sanitization functions that should be incorporated in the theme - This page says this. The WordPress theme should make use of the following inbuilt ...
0
votes
1answer
23 views

Remove Featured Images from Posts Older Than a Certain Date

I run a network of sites, with hundreds of editors, and lately we've had image copyright trolls coming after us. Most of these images are a year old or older, so we're looking to remove all images ...
0
votes
1answer
12 views

Using depth=n in wp_list_pages

I'm wondering what is the proper way to use depth n in wp_list_pages. I currently have a menu in my sidebar that goes 4 levels deep but I'd like to prevent levels 3 & 4 from displaying. The ...
0
votes
0answers
18 views

How do link to the most recent post in a category (Cornerstone theme)?

Hello friends :) I am in a pickle. I am creating a website in X/Cornerstone for an artist who has many projects , each has of which has its own Wordpress site. All of them rely on blog posts to ...
0
votes
1answer
19 views

If is multiple page templates

Via functions.php, I'm trying to enqueue specific scripts and styles based on two separate page templates. Here's what I've tried: if ( !is_page_template('page-templates/page-index.php') && ...
2
votes
1answer
1k views

Define page template in wp_insert_post

How can I set which page template this page, created using wp_insert_post, uses? I want it to use template-blog.php This is my current function; add_action( 'admin_init', 'mytheme_admin_init' ); ...
0
votes
2answers
187 views

Guest Author - How to modify my custom function code if the guest author URL will follow a particular pattern/format?

Based on code the awesome G.M. provided in an earlier question (Use Custom Fields to Create Guest Author Link), I now have a custom function that uses custom fields to support guest authors. The code ...
0
votes
0answers
31 views

Subcategory generated based on title of custom post type

This is what I have in my functions to create a category based on the title of a custom post type "attorneys": add_action('save_post', 'add_title_as_category'); function add_title_as_category( ...
1
vote
2answers
2k views

Posts to expire (deleted) after a date

I am creating a coupon site from scratch. I have reviewed many code examples on the Internet, but have not found anything that will work, as my requirements are little different. I need help in ...
0
votes
1answer
1k views

How to echo Widget Title in Custom Frontend-Template Box

I've created a custom Widget with the help of following code: // Creating the widget class wpb_widget extends WP_Widget { function __construct() { parent::__construct( // Base ID of ...
0
votes
1answer
1k views

Creating wordpress user registration form

I am having a form page called Test Form with this form : <div id="container"> <form action="wp-content/themes/max-magazine/TestForm.php" method="post" name="myForm"> User <input ...
0
votes
2answers
50 views

Fetching $_POST from Page Template into functions.php

I'm having an issue with the order WordPress is loading page templates and functions.php. I have front-page.php which has $_POST['sort-by'] allowing users to sort posts using a drop-down menu. It's ...
3
votes
3answers
5k views

Get user id from email?

I'm working on an email system, and I'm onto the unsubscribing stage. Since most of my users would not know their user ID, I'm asking them to put their email into a text box (definitely preferred, ...
0
votes
2answers
931 views

AJAX values converted to PHP Variables?

I just started playing with Wordpress and I have a question about the AJAX side of things. I think that I understand how the AJAX front-end to server side processing, back to font-end works. But, I ...
0
votes
2answers
449 views

How to create an option page for this simple plugin

I know how to write WordPress plugins but I have no idea how we could create an option page for our plugin. I have read lot of tutorials but I still have no idea about creating option pages. So just ...
1
vote
4answers
5k views

redirect wp-login.php to another page

I would like to redirect this page wp-login.php to /login page. So when a user clicks on a link like this <a href="/wp-login.php">login</a>, wordpress will redirect him to /register . I ...
1
vote
2answers
259 views

Can wp_list_comments output into variable?

Is there any way how to output wp_list_comments() into a variable? Something like $output = wp_list_comments(array('reverse_top_level' => false ), $comments); I am writing a plugin and it would ...
1
vote
1answer
772 views

Using add_filter() in Widgets

Just have a query reference the add_filter() function. Can you use this function inside a WordPress widget class. Example I have a widget with dynamic created code that I want to pass to another ...
1
vote
2answers
442 views

changing behaviour of get_search_form

I created a function to display a search box and named it my_get_search_form(). That is a copy of original get_search_form() function. When I call the function, the output is this: Search in ...
0
votes
1answer
19 views

Can plugin automatically update if i hide the update notification?

I'm trying to remove the plugin update functionality from specific plugins. I have searched about it and find a good answer. According to the answer below function actually hiding the update ...
1
vote
1answer
3k views

How to integrate owl carousel into theme without using a plugin?

I've been trying to integrate the owl.carousel into my theme but can't get it to work. The instructions on the page are not for WordPress so I need help with how to properly enqueue the required files ...
0
votes
1answer
1k views

Session is not starting

I've read the usage of session() in WordPress from here and here. And I placed the following code into the very starting of my functions.php: /** * ENABLING SESSION TO THE SITE * Thanks: Shazzad ...
11
votes
1answer
6k views

Solution to render Shortcodes in Admin Editor

I have asked this question about a year ago and I am hoping there is some type of simple solution which will allow me achieve my objective. So here it goes: I often utilize shortcodes within the ...
0
votes
1answer
43 views

async javascript and css for wordpress

I'm trying to make JS and CSS asynchronous without plugins(I know this is possible, without much of coding). As I'm not really know php, I would like you to help me a little bit over here. I found ...
0
votes
0answers
14 views

How to load comments based on URL parameter(s), not post ID?

I've modified my wordpress install to grab data from an external db instead of relying on the post system. The problem is, the same comments are loaded regardless of the URL - of course this is to be ...
0
votes
1answer
40 views

contactform7 remove tags with “wpcf7_autop false” from functions.php

i want to remove those <p> and <br/> tags from my contactform7 forms. now they have this wpcf7_autop which can be set to false when inserting: define('WPCF7_AUTOP', false); to ...
0
votes
0answers
25 views

Limiting Wordpress search to category description

I'm working on a project where i need to customize the Wordpress search engine. I want to be able to search the category description in the 'wp_term_taxonomy' table. There are quite some snippets ...
1
vote
0answers
35 views

Multisite Ajax serialize return error [object Object]

Working on custom WP theme, i'd like to add some "add_testimony" linked to custom post. Form is real simple, here it is : <!-- Add testimonial --> <div class="col-md-12"> ...
0
votes
0answers
34 views

I would like to write the output of a function in normal post.php fields

I have this function, and it prints, displays these values ​​directly in the published posts: function gen_num() { global $post; $mixnames = get_post_meta( $post->ID, 'fieldnames', true ); ...
0
votes
0answers
27 views

How can create pagination for specific category posts?

I'm trying to create pagination for specific category post in custom template, i create a function which is returning the all post pagination. I have overall 39 posts which are for different ...
1
vote
1answer
31 views

functions.php How to add css/js depending on Template Name?

How to add custom CSS and JS files depending on the Template Name? For example my normal pages will all have a green background color. Now I want that Blue Template will have a blue background color ...
0
votes
1answer
9 views

Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )

I was learning from the WordPress codex about global variables and after var_dump($post) I found out that $post has a property called comment_count I was wondering whether I can directly use ...
0
votes
2answers
489 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
449 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
51 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
25 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
21 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
55 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 ...