How to display posts on a static page? (like search loop)

You could use query_posts() to set up a new loop in your page. Assuming that the posts you want are in the category ‘Noticias’, with a slug of ‘noticias’: query_posts( ‘category=noticias’ ); if( have_posts() ) { get_template_part( ‘loop’, ‘index’ ); } wp_reset_query(); // probably not necessary, if you don’t have a pre-existing Loop

How to add “Template” option in page attributes panel?

If there is everything OK with your template file (it should be placed in root directory of your theme) and the comment is correct then there can be one more thing… There is/was some mysterious bug, that was preventing template select from appearing. You can read about this bug here: https://core.trac.wordpress.org/ticket/18324 It’s closed, because it … Read more

Only show content if current page is NOT one of 2 page templates [closed]

If you want don’t want to show content if the current template is template-custom.php or template-custom2.php you can use: if (!is_page_template(‘template-custom.php’) && !is_page_template(‘template-custom2.php’)) { <!– show some content when you AREN NOT in template-custom.php NOR template-custom2.php –> } or if (is_page_template(‘template-custom.php’) || is_page_template(‘template-custom2.php’)) { <!– show some content when you ARE in template-custom.php OR template-custom2.php … Read more

Get_template_part inside a folder

I assume you have a file in templates/masterhead-templatename.php, and it works, it is ok. Correct me if I am wrong, you want to locate this file like this masterhead-templatename.php, basically one folder up, but this wordpress function does not work like this. If the file exists in the root’s theme folder, it does not recognize … Read more

How to check if a specific page uses a page template?

Page template is set in a post meta field keyed ‘_wp_page_template’ so, instead of using raw $wpdb query, you can run a WP_Query using ‘author’ argument and meta_query to retrieve pages from a specific author that also have a specific templates: $q = new WP_Query( array( ‘author’ => $user->ID, ‘post_type’ => ‘page’, ‘meta_query’ => array( … Read more

Page Automatically Generated from Theme?

Put this in your functions.php file: $contact_query = new WP_Query(array( ‘pagename’ => ‘contact’, ‘post_type’ => ‘page’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 1, )); if (! $contact_query->post_count) wp_insert_post(array( ‘post_name’ => ‘contact’, ‘post_title’ => ‘Contact’, ‘post_status’ => ‘publish’, ‘post_type’ => ‘page’, ‘post_author’ => 1, ‘page_template’ => ‘page-contact.php’, )); unset($contact_query); What does it do? If the contact page … Read more

Posts are duplicating on wp_post_update

Ah, I found the answer myself. I’ve added global $post before the loop and now all seems to works fine. I don’t know if this is a good practice, so if you have another ideas share them 🙂 Here is the revised code: add_action(‘save_post’, ‘bulk_refresh’); function bulk_refresh($post_id) { if($post_id != 123)//123 is the ‘certain page’ … Read more

Is there a way to set different post templates for parent posts and child posts in the same post type?

Simplest way is to use single_template filter hook (one of the {$type}_template hooks). It is fired by WordPress to filter the template file found for singular post requests. add_filter(‘single_template’, function($template) { $queried = get_queried_object(); if ( $queried->post_type === ‘clients_projects’ ) { // only for this CPT // file name per OP requirements $file=”clients_projects_”; $file .= … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)