0

I am using this template: http://demo.undsgn.com/studiofolio/front-page/

I tried to make some modifications because I need the homepage template to display an excerpt beneath each thumbnail. I copied the template called front-page.php, renamed it to front-page-excerpt.php and made my modifications and it worked.

The problem is there is a framework behind it that controls which template is shown on the homepage. The framework is: http://aquagraphite.com/2011/09/slightly-modded-options-framework/

In the backend it looks like this:

enter image description here enter image description here

In the backend my new template isn't showing up, and I think I found the problem. The template is called in the backend options panel like this:

    $querystr = "
    SELECT $wpdb->posts.* 
    FROM $wpdb->posts, $wpdb->postmeta
    WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id 
    AND $wpdb->postmeta.meta_key = '_wp_page_template' 
    AND $wpdb->postmeta.meta_value = 'templates/front-page.php' 
    AND $wpdb->posts.post_status = 'publish' 
    AND $wpdb->posts.post_type = 'page'";

    $pageposts = $wpdb->get_results($querystr, OBJECT);

When I change it to:

        AND $wpdb->postmeta.meta_value = 'templates/front-page-excerpt.php'

My modified templates show up, but the original templates are not displayed. I tried to put both in it like this:

    $querystr = "  
    SELECT $wpdb->posts.* 
    FROM $wpdb->posts, $wpdb->postmeta, $wpdb->postmeta AS mt1
    WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id 

    AND $wpdb->postmeta.meta_key = '_wp_page_template'   
    AND $wpdb->postmeta.meta_value = 'templates/front-page.php'
    AND mt1.meta_key = '_wp_page_template'
    AND mt1.meta_value = 'templates/front-page-excerpt.php'

    AND $wpdb->posts.post_status = 'publish' 
    AND $wpdb->posts.post_type = 'page'";

    $pageposts = $wpdb->get_results($querystr, OBJECT);

It doesn't work at all. What am I doing wrong?

  • 2
    That theme appears to be a commercial theme, mean the source code is unavailable and testing is all but impossible. That makes this question off-topic. Try to contact the theme developers. – s_ha_dum Jan 31 '14 at 14:17
  • thanks rachel . you are right but to this modification the developers give no support and i need thins layout changes very urgently . if u want i can send you my theme for testing . hahahah – user45966 Feb 1 '14 at 9:02
1

No idea why you're using clunky custom SQL, use a meta query instead.

$pageposts = get_posts(
    array(
        'posts_per_page' => -1,
        'post_type'      => 'page',
        'post_status'    => 'publish',
        'meta_query'     => array(
            array(
                'key'   => '_wp_page_template',
                'value' => array(
                    'templates/front-page-excerpt.php',
                    'templates/front-page.php',
                )
            )       
        ),  
    )
);
  • perfect that worked !!! Thanks so much ! I didnt made it that way because i dont understand the code . hahah – user45966 Feb 3 '14 at 17:39
0

If you want to select both template, you should use OR and not AND operator

$querystr = "  
SELECT $wpdb->posts.* 
FROM $wpdb->posts, $wpdb->postmeta, $wpdb->postmeta AS mt1
WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id 

AND ($wpdb->postmeta.meta_key = '_wp_page_template'   
OR $wpdb->postmeta.meta_value = 'templates/front-page.php')
AND mt1.meta_key = '_wp_page_template'
AND mt1.meta_value = 'templates/front-page-excerpt.php'

AND $wpdb->posts.post_status = 'publish' 
AND $wpdb->posts.post_type = 'page'";

$pageposts = $wpdb->get_results($querystr, OBJECT);
  • Thank you so much Matthieu. I think we getting closer. I didnt understand why but now it shows each and EVERYPAGE ever made in the options panel . why that? it filters it with our 2 meta_values right!? but it shows every page which are not front-page.php or front-page-excerpt.php. funny fact: if there is only a page applied to front-page.php ist showing nothing in the panel sidebar . when i apply a page to front-page-excerpt.php it shows everypage. Do you think we gettin this right ? – user45966 Feb 1 '14 at 9:11
  • maby important this code appears in two files 1 ind theme-options.php and a second time ind base.php – user45966 Feb 1 '14 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.