-
AuthorPosts
-
April 28, 2013 at 11:57 pm #22575
Hi,
I would like to add the pages widget (or preferably a custom menu widget) to the main content area of the error404.php page (instead, or preferably, in addition to the avia combo widget). What would I need to add to error404.php to achieve this please?
April 30, 2013 at 7:16 am #116219Hi!
You can add the widget into the “Displayed Everywhere” widget area and use: http://wordpress.org/extend/plugins/widget-logic/ and the is_404() conditional to display the widget on the 404 page only.
Best regards,
Peter
April 30, 2013 at 1:46 pm #116220Hi Dude,
I already have the pages widget added to the sidebar, but I wanted to add it in to the main content area of the error404.php page, not a sidebar, just below the search box that appears and above where the avia combo widget appears. I have looked at the error404.php page and want the widget to appear above or instead of the code below:
<h3 class=''><?php _e('Feel like browsing some posts instead?', 'avia_framework'); ?></h3>
<?php
the_widget('avia_combo_widget', 'error404widget', array('widget_id'=>'404',
'before_widget' => '<div class="widget avia_combo_widget">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>'
));
?>I tried to change the widget name in the code above to the pages_widget, but it didn’t work!
May 1, 2013 at 6:02 am #116222Hi,
Open includes error404.php and find this code
<p><strong><?php _e('Nothing Found', 'avia_framework'); ?></strong><br/>
Place this code at the bottom.
<h3 class=''><?php _e('Feel like browsing some posts instead?', 'avia_framework'); ?></h3>
<?php
the_widget('avia_combo_widget', 'error404widget', array('widget_id'=>'404',
'before_widget' => '<div class="widget avia_combo_widget">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>'
));
?>Remove the same code below. Try to remove browser cache the reload the page.
Regards,
Ismael
May 1, 2013 at 11:56 am #116223Sorry Ismael, am I missing something? You’ve just given me the identical code that already exists on the error404.php and that I referenced in my 2nd post!!
That code displays the combo widget in the main content area of the 404 page. I want to add a custom menu or pages widget above this (or actually even above the search bar that appears above the combo widget)
Thanks,
Matt
May 2, 2013 at 8:12 am #116224Hi,
Sorry my bad. Please do this instead. On functions.php place this code at the very bottom.
function new_widgets_init() {
register_sidebar( array(
'name' => '404 Widget',
'id' => '404_sidebar',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2 class="rounded">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'new_widgets_init' );Now edit error404.php and find this code
<h3 class=''><?php _e('Feel like browsing some posts instead?', 'avia_framework'); ?></h3>
Below add this code
<?php
if ( dynamic_sidebar('404_sidebar') ) :
else :
?>
<?php endif; ?>Go to Appearance > Widget and add some widgets on 404 Widget Area.
Regards,
Ismael
-
AuthorPosts
- The topic ‘Add widget to error404.php page’ is closed to new replies.