Assuming that the 'blog'
slug is correct, your code would work. I would suggest making a separate template for the page, namely page-blog.php (see http://codex.wordpress.org/images/1/18/Template_Hierarchy.png and http://codex.wordpress.org/Template_Hierarchy) where you set up the structure and appearance of the page exactly as you want it to be.
WordPress will automatically look for the file when opening a page with the name of 'blog'
(that is, the slug must be 'blog'
). Also, the code you posted above would normally go in loop.php, granted that you are using the default template-setup.
Related Posts:
- display most popular tags in two columns
- dynamic sidebar not showing anything
- WordPress widget/sidebar dividers?
- Missing sidebar parameter “fix” – before_content
- Dynamic Sidebars & Echo
- How to determine if the sidebar is empty? Or not active?
- Add a select-option to the default widgets
- Stuck with sidebar registering
- Retrieve the whole widget sidebar and pass it inside an html
- Loading Widgets Via Child Theme
- How can the searchform.php know if it’s used on a registered sidebar id ‘sidebar-1’ or ‘sidebar-2’?
- How to list categories by page id in wordpress
- how to run a php code in widget?
- My custom widget won’t stay in the widget area after I refresh the widget page
- How to include checkbox in widget backend form?
- Limit the number of inactive widgets
- Create Image Uploader for Widget
- How to get the registered sidebar’s name by its id?
- Displaying a variable stored in functions.php inside widget
- Get the sidebar ID in which the current widget was dropped
- Transform php code into a widget?
- How do I create a drop down menu in a widget?
- WordPress widget in custom theme
- How to allow PHP In WordPress text widget
- Infinite-Scroll Plugin and Jetpack Infinite Scroll Plugin – Adding to “Thoughts” Theme
- Anything I can add to functions.php to make text widgets accept PHP?
- WordPress menu deletes when trying to add a hook
- PHP contact form returns warning in text widget [closed]
- How can I add a specific, custom widget to my theme’s header.php?
- Get widget settings function?
- Widgets not showing in my custom theme
- Class ‘WP_Widget’ not found
- Count widgets of a certain type
- How to group 2 radio buttons in a widget?
- Inject PHP code into “sidebar-content” – code before my WooCommerce sidebar widget?
- custom widget on the footer
- Where do posts get the sidebar from?
- Create onClick Event to Re-load a Widget
- How to put a variable in a instance in the widget
- Extending the WP_Widget_Text class
- WordPress Shortcodes.. printf is outputting a random number… Can’t figure out WHY?
- get widget number from array dynamically
- Theme developement – incative sidebars
- Hide subcategories (widget)
- Adding a widget function into the php theme file
- How to edit widget code to add unique class name to each div?
- Generate sidebar depending on height of post
- If has $title in widgets
- Archives shortcode displaying above widget title
- Widgets in the loop if active
- if statement with is_active_sidebar()
- Sidebar not appearing in footer, but it appears everywhere else!
- Hook called before text widget save
- How to remove sidebar primary widget on Mobile on category page [closed]
- Widgets not showing on custom theme
- My website is not showing Footer section
- WordPress widget and customize.php not working in Ubuntu16.04 VPS
- How can I display Custom Post type Custom Columns and its Content in a Dashboard Widget?
- Removing sidebar on category pages
- How to use title attributes in sidebar widget?
- Show different website layout if no sidebar added
- Why the dynamic_sidebar() call is putted into an ul tag?
- Display Custom Field in Sidebar if Value is Present
- Some problems in custom widget
- How a HTML form can trigger a PHP function?
- How to use wp_get_attachment_image or wp_get_attachment_image_src instead of $instance[‘single_feature_image_uri’]
- How to stop hiding buttons forward / backward in pagination?
- How to create a widget with a populated dropdown?
- Force Sidebar on Full Width page
- Add widget area from visual editor
- Display child-page links in sidebar on both Parent Pages AND Child Pages
- Blog Image and Title in Right Sidebar
- is_user_logged_in() not working in homepage
- Dynamic_sidebar load in string makeup
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- Featured Products not showing up in “Featured” area of homepage
- (Who to follow) Twitter widget
- Widget Logic – display on page and all child
- Add disclaimer before certain posts and pages
- Widget Update problems using a for loop
- Non-static method error when trying to use class in widgets
- Slider from different widgets
- Even with PHP plugin get_posts not working in widget area
- Cannot access variables within a widget
- WP_Widget dynamic field array with external AJAX
- if conditional in sidebar plugin Password content shortcode
- List sibling pages widget, exclude current page
- Template from scratch: Sidebars not showing widget
- Name Input from widget displays Sidebar name instead of saved data
- WordPress – show number of comments for each post in widget
- Widget header unique classes
- Banner editable from backend
- how to remove sidebar from particular one page
- Listing current pages subp page in list items in the sidebar
- Using a loop to build and update widgets
- How to display different widgets on specific pages, hide from other pages
- PHP Widget and do_shortcode
- Sidebar doesnt get updated?
- Edit the Publish Widget Options
- How to define template directory in this widget code