Post content, PHP help
Post content, PHP help
Post content, PHP help
function default_comments_on( $data ) { $myCustomPostType = array(“my_custom_post_type_1”, “my_custom_post_type_2”, “contacts”); /* Custom Post Type Array */ if (in_array($data[‘post_type’], $myCustomPostType)) { $data[‘comment_status’] = ‘open’; } return $data; } add_filter( ‘wp_insert_post_data’, ‘default_comments_on’ ); Add this code in functions.php
You can use the function wp_list_pages. If the default output isn’t enough you can write a custom walker for that function.
You need to work out what page level you are on first, so that you know the correct ID to pass to the child_of argument of wp_list_pages. Give this a try: global $post; $page_level = 0; $post_parent = null; // Work out what page level we’re on if($post->post_parent > 0) { $post_parent = get_post($post->post_parent); $page_level … Read more
user specific private content
PHP Select Doctors ‘doctors’, ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘dptmnt’, ‘value’ => $dpt, ‘compare’ => ‘LIKE’ ), ‘order’ => ‘ASC’ ), ); $events = new WP_Query($args); while ($events->have_posts()): $events->the_post(); ?> “> HTML Select Department ‘dpt’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’ ); $events = new WP_Query($args); while ($events->have_posts()): … Read more
When you create a template page, it does not create a WordPress URL for it. So for example, if you create a PHP file called contact-content.php it doesn’t generate example.com/contact/. If you don’t want to manually create a page and assign a Page Template to it (which by the way would normally be named something … Read more
Well, if you take a look at the indentation of the code, which is correct, it should be pretty clear, why it is so. if (is_page(‘mounting-guides’)): $guides = get_field(‘guide_pdfs’); // you don’t do anything in this case elseif (is_page(‘user-manuals’)): $guides = get_field(‘user_manual_pdfs’); // you don’t do anything in this case elseif (is_page(‘cleaning-guides’)): $guides = get_field(‘cleaning_guide_pdfs’); … Read more
The simplest solution (as in requiring the least work) would be to just make $count a global variable. So in index.php you’d have: global $post; $count = 0; And in content.php you’d just need to use $global $post; to access it: <?php global $post; if ($count == 0) { ?> However, I think this is … Read more
I would recommend using WordPress custom fields. You can add them using the WordPress API or using a plugin like Advanced Custom Fields If so, create a Repeater field that contains Image field. Use this to show your repeater field.