Your code will never get to the is_page_template()
if
statement because is_page_template()
can only be true when is_page()
is also true.
It also looks like you’ve got some muddled elseif
syntax (I think that’s what you want?) and some generally inefficient code that repeats a lot.
I’d do this:
<?php if( is_page_template('right-sidebar.php') ) { // check for page template
$layout_classes="col-lg-7 col-md-12";
} elseif( is_single() || is_page() ) { // it's not the page template. Is it at least a post or page?
$layout_classes="col-lg-8 col-lg-offset-2";
} else { // I suspect you want a fallback condition, not sure what it is.
$layout_classes="{something}";
} ?>
<div class="col-lg-12">
<div class="row">
<div class="<?php echo $layout_classes; ?>">
Related Posts:
- Connection lost. Saving has been disabled… (Updating Posts/Pages)
- how to limit edit_form_after_title hook to page and post edit only?
- Strategy for handling hierarchical pages with empty parent content
- How to add a new tab to page editor
- disable password protected page for logged users
- How to change post to page
- Why do I need to use The Loop on pages (inside page.php etc)?
- Create custom page in WooCommerce
- Determining Slug Before and After Edit
- Automatically create pages in a post based on number of words
- Static posts page with home.php
- Change WordPress post-state in Admin Area
- how to show all post in my page-grid.php template page
- eBooks download website, page or post?
- Can I hide a specific post from latest posts page?
- Hide add new page button
- How to show post(excerpt) from specific category on wp page?
- How To Keep Posts from Being Displayed Two or More Times on My Homepage? [closed]
- How to restore permanently trash page? [closed]
- Custom Blog Post Page
- Creating a Page of Posts
- Private Posts/Pages & Search
- White Blank Page when Updating and Publishing Page/Post
- post-page: reference to parent page?
- Dashboard :10 Last draft page and 10 last pending review page (metabox)
- page.php showing loop of posts and not page content
- Can I divide the pages into categories?
- How do I get blog posts to appear within CMS?
- Drag posts and pages so you can sort them in order
- How to include the latest post of a specific category on a matching page
- post categories
- Integrate OpenStreetMap on WordPress
- What’s the best way to render Visual Composer in posts, not pages?
- Overwrite posts/pages via import
- Auto-realod with new posts // Ajax call
- Start post pagination at 0 instead of 1
- Is there a way to specify an extra class for a post or page with no title?
- Using wp_list_pages() after calling query_posts()
- Display Posts on Custom Page
- Multiple Loops Breaking Pages
- “about us”, ” contact” sections should be article(post) or page in the simple small Business website?
- disable Tab post on nav-menus page (Admin)
- Proper way of establishing custom landing pages in WordPress
- How to detect when admin user is on the All Posts page?
- Custom Permalink Structure for Pages & Posts
- Getting a “404 Not Found” error when “Preview Changes” is clicked
- My Custom Post Type Still Using index.php
- Make ‘blog’ page show content as well as posts underneath it
- Post/page title to permalink transformation – what is behind the scenes?
- Would a “hub” page work better as a page or a post?
- Setting limit to posts or page creation
- Using Posts Like a Page
- Pagination for normal (standard) posts on a page with a custom loop?
- Page of posts made to look like homepage
- post/page content
- How to link post titles on page A to its posts on page B?
- WordPress Architecture as a CMS – Posts & Pages
- Is it to possible to insert a page in the post depending on the category ofthe post
- How can I add a page that shows posts from a single category?
- Permanently deleted posts still exist
- Automatic duplicate/copy of post to a related page in WordPress
- Is there a way to know when a page has been updated and do some action only once?
- Yoast breadcrumb URL shows category instead of the page
- Please help a newbie with blog page issue?
- Nestling Posts Under Page & Justify Text
- Added a ACF field to custom page and want the results to show as a column in admin
- Deleted page still shows and is showing posts archive
- How to create page with post content in it?
- Put page on Archived statut after end of publication date
- Disable pagination in posts and pages
- Single Sidebar; multiple templates! How?
- WordPress for business site
- How do I make it so that new posts within a certain category go into a certain page?
- Any difference betweenn posts and pages for one page?
- Show only top 3 posts from 3 categories in order on home page
- Add custom class to existing menu items from custom meta
- Bulk replacing content of multiple pages/posts?
- Allow users to create their own page/s
- how to change the permalink to a specific location?
- some posts being displayed as pages
- One of my posts is displayed as page
- Make Show Notes for Individual Podcast Episodes Easy to Find (multiple URL’s?)
- Get part of a page url
- can’t post immediately
- Displaying only posts from a certain category on my custom page template
- I need to create a page or post hierarchy
- Home page: using custom fields for posts and pages
- Where are my posts linked to? I keep getting a Not Found Error, and I have no single.php page
- The loop: more posts than I want to fit on one page
- Automatically delete default posts and pages on theme install?
- How do I add an article to specific page?
- Custom post page has attributes of latest post [closed]
- WordPress “Posts Page” isn’t showing template dropdown
- Adding Count Post in Page
- Insert Shortcode exactly at the end of the content
- How to find the page of specific post?
- How to have 2 posting pages on a blog
- change page name on page list
- Automatically search and replace link in content (pages/posts)?
- How to remove slug from CPT correctly?