Custom post type and permalink issue
The filter for post permalinks is post_link. Hook your update_article_permalink function to the post_link filter to apply your function whenever get_permalink is called.
The filter for post permalinks is post_link. Hook your update_article_permalink function to the post_link filter to apply your function whenever get_permalink is called.
What you are looking for is called a Custom Post Type, or CPT in short term. To register a new post type, you can use a simple code like this, which will add a new post type called article to your admin panel: function register_my_post_type() { $labels = array( ‘name’ => __( ‘Articles’, ‘text-domain’ ), … Read more
I found the answer: add_action(‘add_meta_boxes’, ‘add_contact_form_meta_box’); function add_contact_form_meta_box() { add_meta_box(‘contact-form-meta-box-id’, ‘Submission Data’, ‘contact_form_meta_box’, ‘contact_form’, ‘normal’, ‘high’); } function contact_form_meta_box($post) { echo get_post_meta($post->ID, ‘first_name’, true); }
Declaring a shortcode is as easy as using this: add_shortcode(‘jobs’, ‘callback_function’); function callback_function(){ $content=””; $args = array( ‘post_type’ => array(‘job’), ‘posts_per_page’ => 20 ); $the_query = new WP_Query( $args ); if ($the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); if ( 683 !== get_the_ID() ) { $content .= ‘<a href=”‘. get_the_permalink().'” class=”jobs”>’; } $content … Read more
I’m not that familiar with the posts-to-posts Plugin, but your main problem may be that the category page doesn’t know which building you chose in the step before if you don’t transmit it in a parameter or save it in a session or cookie. Maybe it would be better to output the connected items on … Read more
Your query should look like this (more or less) $args = array( ‘post_type’ => ‘FAQ ‘, ‘tax_query’ => array( array( ‘taxonomy’ => ‘faq_category’, ‘field’ => ‘slug’, ), ), ); $query = new WP_Query( $args );
Get the Attribute value in the shortcode and get the custom field values: function product_func($atts) { $post_id = $atts[‘code’]; $key = “my_custom_field_key”;//for 1 field, you can do this 6 times for the 6 values $custom_value = get_post_meta($post_id, $key, true); return $custom_value; } add_shortcode(‘product’, ‘product_func’); if you want to debug the post meta field values use … Read more
SOLVED: I had this in the function to save the meta data (like an idiot!!) if ( !$value ) delete_post_meta( $post->ID, $key ); // Delete if blank So it wasn’t saving the meta value if set to 0. I changed it to: if ( !$value ) add_post_meta( $post->ID, $key, ‘0’ ); // add 0 if … Read more
Firstly assign your Custom fields group to the post type you are trying to show them in, then call them in that post types template like you have done already. For the template part, you need to copy single.php from the Parent theme. EDIT: For the cutomizr theme you have to make changes in the … Read more
You are missing the {…} around the calls to wp_dequeue_script. That means only the first one is associated with the if statement, and the rest are being executed for every case. Update your code to the following: add_action( ‘wp_enqueue_scripts’, ‘dequeue_my_scripts’, 999 ); function dequeue_my_scripts() { if ( ‘guide’ == get_post_type() ) { wp_dequeue_script( ‘dw_focus’ ); … Read more