New answers tagged

-2

function get_image_id($image_url) { global $wpdb; $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url )); return $attachment[0]; }


2

I can already tell that you're using ACF - if you don't want to change the return settings for the field, you can bypass ACF and just pull the image ID directly from post meta: $image_url = get_field( 'my_field_name' ); $image_id = get_post_meta( $post->ID, 'my_field_name', true ); $image_meta = wp_get_attachment_metadata( $image_id );


-2

<?php global $post; $child_pages_query_args = array( 'post_type' => 'page', 'post_parent' => '93', 'orderby' => 'date DESC' ); $child_pages = new WP_Query( $child_pages_query_args ); ?> <?php if ( $child_pages->have_posts() ) : while ( $child_pages->have_posts() ) : $child_pages->the_post(); ?> <div ...


2

Use wp_enqueue_scripts instead on init. This will ensure you the template is already loaded. add_action('wp_enqueue_scripts', 'maps_scripts'); Or you try to check the template using get_page_template_slug() instead of is_page_template: $tmp = get_page_template_slug($post_id); // provide page/post ID if('page-about.php' == $tmp) { // enqueue scripts ...


0

Templates might load faster because they don't have to do a database query, they have already all the text hardcoded in them. Also, this might not be the right way to do it and you might have problems or conflicts if you are not doing it right. Considering the fact that the speed diference will be very small, I sugest you should go with a page created in ...


-1

Shortcodes are intended to return values, or echo them. You can use the include to the file you have, but unless you serve the intended $atts to the function there you won't see anything. Basically no one can help you unless we see the rest of your code. My best guess is that you need to declare the variable globally from the attributes in the shortcode and ...


1

You are probably confused by the output of array_values() which will always get you only array values without keys while $atts variable is actually an associative array. To extract your attribute use $arr = $atts['tablepageid']; Cheers


0

where it should be placed whether in page-template directory or at theme root directory? It should be placed at the root directory of the the active theme. If you take a look at template heirarchy, you can see that for taxonomy the flow is: taxonomy-$taxonomy-$term.php --> taxonomy-$taxonomy.php --> taxonomy.php So the correct name for term ...


1

The best practice for editing a Woocommerce theme is similar to Wordpress as you should use Hooks and Filters when possible. https://docs.woothemes.com/document/introduction-to-hooks-actions-and-filters/ But if you do need to edit a template Woocommerce outlines this on their website as well: https://docs.woothemes.com/document/template-structure/ You just ...


0

comment is related to post, page, or custom post type content, not an archive page, so I think you rather need add a front form than comment form on archive pages. You can use the "visual form builder" or some other front form plugins to get the done.


1

You can try to build some options custom page to allow users to change some text. there are many plugins for easily creating that functionality. I will suggest you the most popular - https://www.advancedcustomfields.com/add-ons/options-page/ You can use the following code with ACF PRO: /** * Create ACF setting page under Campaign CPT menu * * @since ...


1

You can use Options API or Setting API to store the data in the database. Write a plugin to create a meta box for the introduction text and show that text on the archive-unicorn.php. Or you can utilize the description parameter when you register_post_type and print it in the archive-unicorn.php like this: $unicorn_obj = get_post_type_object('unicorn'); if ...


0

This has happened two times for me. At the first time I changed the encoding of the file (header.php I think) to UTF-8 without BOM and all templates disappeared. Changed it back to regular utf-8. At the second time I somehow edited/renamed the index.php (/themes/theme_name/index.php). Just had to create an empty index.php and now everything seems to be ok. ...


2

Yes, you can use page template for your contact page. Page templates have nothing to do with SEO. The contents inside the page template do.


1

You need to create attachment.php in your child theme. Please check here for more details.


0

I think the slug of our page and post-type become the same. Please change any -one of them ie, post_type=>'color' and page slug to colors. Hope it helps


0

Your question not so much clear but try the following instruction which i understand. First you create page template-color.php and than give template name like <?php /* Template Name: Color */ ?> Now at admin area you create page color and select template Color. Than hit the url of cutom post type page like abc.com/color. In this way you can ...


0

Must be something with your setup. Following works for me (inside child theme - should work for any theme though): single.php: global $post; $bla = $post->post_title; error_log('post title is: ' . $bla); include('included.php'); included.php: error_log('i am included file: ' . $bla); Output in debug.log: post title is: Hello test i am included ...



Top 50 recent answers are included