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
13 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
24 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
33 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
2k 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
196 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
34 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

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 type="...
0
votes
2answers
75 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, ...
1
vote
2answers
268 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
2answers
572 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 http://...
0
votes
1answer
32 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 ...
12
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
82 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
15 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
60 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 wp-config....
0
votes
0answers
38 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
50 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
35 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
30 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
49 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
12 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 $post-&...
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 ...
0
votes
1answer
100 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
30 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
31 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 ...
-1
votes
1answer
18 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
79 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
29 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
33 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
11k 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
42 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
51 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
62 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
44 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
42 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
51 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
237 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
20 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 = get_field('contact',...
0
votes
0answers
44 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
91 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
35 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
33 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
50 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
39 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
87 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
71 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
220 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 ...