The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

WordPress guru’s?

  • # January 30, 2013 at 12:19 am

    Are there any WordPress guru’s that visit here? This forum has been spectacular for css, javascript and some php questions but I am wondering how it would handle some advanced WordPress issues?

    # January 30, 2013 at 12:38 am

    @cybershot What’s your question exactly?

    # January 30, 2013 at 12:41 am

    This reply has been reported for inappropriate content.

    5 hours of trying and I got nothing. I am including all posts and pages into the index.php to make a one page WordPress site. I am using pre_get_posts to include posts and pages.

    function posts_and_pages_on_home( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
    $query->set( ‘post_type’, array( ‘post’, ‘page’ ) );
    add_action( ‘pre_get_posts’, ‘posts_and_pages_on_home’ );

    so that gets all the posts and pages and puts them on my homepage. The problem with that is that it does not get the page templates. So I had to run a second query to get all page templates

    $args = array( ‘meta_key’ => ‘wp_page_template’,’post_status’ => ‘publish’);
    $templates = get_pages($args);

    foreach ( $templates as $template){
    $templateName = $template->meta_value;
    $pageName = $template->post_name;
    if( $templateName != ‘default’ && $templateName !=”) { ?>
    <li id="page
    so that one fetches all my templates just fine. So I found that I needed to exclude the page from the main query above so that there won’t be two pages in the code with the same name displaying different content. one page for the page I created to assign the template to and the second page is the actual template content. The first page being just a blank page that has that template assigned. After hours of trying and reading different methods. I thought I might have had it with the request filter

    function request_filter($request){
    //get all pages by the meta key and value of of _wp_page_template
    $args = array( ‘meta_key’ => ‘_wp_page_template’,’post_status’ => ‘publish’);

    //get all pages based on the args above
    $templates = get_pages($args);

    foreach ( $templates as $template){
    //get all pageID’s of every page template
    $pageID = $template->ID;
    //exclude it from the query
    $request = ‘-‘.$pageID;
    return $request;

    maybe I am missing something.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed