Call custom posttype outside the functions.php

Step-by-step: If you put everything in your functions.php or plugin file, it should work just fine. We need a user meta field, where User can decide if they want to activate a certain CPT. add_action( ‘show_user_profile’, ‘my_user_meta_show_faq’ ); add_action( ‘edit_user_profile’, ‘my_user_meta_show_faq’ ); add_action( ‘user_new_form’, ‘my_user_meta_show_faq’ ); function my_user_meta_show_faq( $user ) { $show_faq = get_user_meta($user->ID, ‘show_faq’, … Read more

Divi theme including javascript

You might have to use get_stylesheet_directory_uri() instead of get_template_directory_uri() when you’re referencing files in a child theme. On a fresh install, I created and activated a child theme of twentyfifteen called child and run the following codes: echo get_stylesheet_directory_uri(); # Output: http://localhost/test1/wp-content/themes/child echo get_template_directory_uri(); # Output: http://localhost/test1/wp-content/themes/twentyfifteen Also, If you have tested the JS independently … Read more

How to show all posts of specific custom post type with their custom fields values?

The meta information is in a different db table from my understanding. What you’ll need to do is loop through each post and grab it’s meta data using get_fields(). Below is a sample from the query to find all the fields for a particular post. $rows = $wpdb->get_results($wpdb->prepare( “SELECT option_name, option_value FROM $wpdb->options WHERE option_name … Read more

All post of child category not in top category

Maybe something like this would do? $cat=”About us”; $tax = ‘category’; $cat_id = get_cat_ID($cat); $category = get_term_children($cat_id, $tax); $pre=””; foreach ($category as $sub) { $cat_list .= $pre . $sub; $pre=”, “; } query_posts(array( ‘cat’ => $cat_list, ‘posts_per_page’ => 1000)); echo ‘<ul>’; while ( have_posts() ) : the_post(); echo ‘<li>’; the_title(); echo ‘</li>’; endwhile; echo ‘</ul>’;

Rename file after title , one small problem

Use get_the_title() since you’re already being passed a post ID. function rename_attacment( $post_ID ) { $post = get_post( $post_ID ); $file = get_attached_file( $post_ID ); $path = pathinfo( $file ); //dirname = File Path //basename = Filename.Extension //extension = Extension //filename = Filename $newfilename = get_the_title( $post_ID ); $newfile = $path[‘dirname’] . “https://wordpress.stackexchange.com/” . $newfilename … Read more

why does WordPress custom css convert alpha to hex values?

if i’m not mistaken, not all browsers are 100% compatible with RGB color codes, so it might be happening in an effort to maximize cross-browser uniformity of appearance. this could also be done to facilitate transparency effects, which might be in another option field for Jetpack. there’s definitely less browser support for the extended hex … Read more