Custom sidebar not showing in the dashboard

Register sidebar. add_action( ‘widgets_init’, ‘wpse_123456_widgets_init’ ); function wpse_123456_widgets_init() { $args = array( ‘name’ => __( ‘Sidebar name’, ‘theme_text_domain’ ), ‘id’ => ‘unique-sidebar-id’, ‘description’ => ”, ‘class’ => ”, ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</li>’, ‘before_title’ => ‘<h2 class=”widgettitle”>’, ‘after_title’ => ‘</h2>’ ); if ( function_exists (‘register_sidebar’)) { register_sidebar( $args ); } } … Read more

Display sidebar that created in functions.php

Here’s the way i would code it. Tested Add to functions file add_action( ‘widgets_init’, ‘wpsites_add_widget’ ); function wpsites_add_widget() { register_sidebar(array( ‘name’=>’Sidebar-Aries’, ‘id’ => ‘sidebar-aries’, ‘description’ =>’Display all the contents of sidebar at Aries page.’, ‘before_widget’ => ”, ‘after_widget’ => ”, ‘before_title’ => ”, ‘after_title’ => ”, )); } Or you could use this code in … Read more

Get a sidebar at the top of the page

This method works from your child themes functions.php file. Change the hook to a different position: //functions.php function wpsites_register_widget() { register_sidebar( array( ‘name’ => ‘After Header Widget’, ‘id’ => ‘after-header’, ‘before_widget’ => ‘<div>’, ‘after_widget’ => ‘</div>’, ) ); } add_action( ‘widgets_init’, ‘wpsites_register_widget’ ); add_filter( ‘loop_start’, ‘after_header_widget’, 25 ); function after_header_widget() { if ( is_active_sidebar( ‘after-header’ … Read more

Dynamically Register Sidebars For Each Top Level Page

try this code for creating unique sidebar for each parent page you can use $page->post_name(page slug) or $page->ID(page id) as sidebar id if ( function_exists(‘register_sidebar’) ){ /*extract all parent pages */ $topLevel = get_pages(array( ‘sort_column’ => ‘post_date’, ‘hierarchical’ => 0, ‘parent’ => 0 )); foreach($topLevel as $page){ /* register sidebar for each parent page */ … Read more

Accessing Media/Files outside the_content

Try the following code: $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ => null, ‘post_parent’ => $post->ID ); $attachments = get_posts( $args ); if ($attachments) { foreach ( $attachments as $attachment) { setup_postdata($attachment); the_title(); the_attachment_link($attachment->ID, false); the_excerpt(); } }

Is there a way to allow only certain type of widgets in the sidebars?

It is possible to hook to sidebars_widgets and find which widget is in which sidebar. function dump_sidebar($a) { echo ‘<pre>’.var_export($a,true).'</pre>’; } add_action( ‘sidebars_widgets’, ‘dump_sidebar’); By checking that array you could eliminate particular widgets. function limit_sidebar_wpse_101279($sidebars_widgets) { if (!empty($sidebars_widgets[‘sidebar-1’])) { foreach ($sidebars_widgets[‘sidebar-1’] as $k =>$v) { if (‘pages’ == substr($v,0,5)) { unset($sidebars_widgets[‘sidebar-1’][$k]); } } } return … Read more

Text snippets shared across posts

It sounds like you do want a custom post type, you just want to set the public argument to false. The register_post_type() has lots of arguments that will let you do everything you probably want. Along with public, you’ll probably set has_archive to false. Setting show_ui to true will allow you to manage the posts … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)