Wordpress sidebar custom icon - php

I'm in the process of setting up a sidebar on my wordpress site, the sidebar lists all pages within the current section using the code below:
<?php
wp_list_pages( array(
'title_li' => '',
'child_of' => wp_get_post_parent_id(),
'link_before' => '+',
) );
?>
The + icon in the link_before field adds the icon before the page name is output. Ideally what I'm wanting to do is output the pages icon attribute in here, although I can't seem to work out a way to do this.
The page has an icon saved as a custom field, which can be easily output on the page itself using the code below.
echo get_post_meta($post->ID, 'Icon', true);
if anyone's aware of a method which would make this achievable, please let me know.
Thanks

Related

Having trouble getting WP Customizer Color Picker to actually change colors on my site

I'm busy developing my first custom theme on WordPress. I have converted and created all the files and everything is working as it should. The original files are based on Bootstrap, but I have converted the stylesheets to not be dependant. I am finally at a place where I want to allow users some customization and among other things, would like to add the ability to change theme colors.
I created a separate customize.php file that handles my customizer code. I have also added the WP Color Picker component and it does show up in the WP dashboard > Appearance > Customize window. The problem is that it doesn't actually work...
As part of my testing, to ensure that Bootstrap wasn't affecting anything, I created a div and gave it a custom class name (one that isn't found anywhere else on the website), I gave the div some height and width, and inside, I added a p-tag just to have some content. What I would like to do, is create a section (in the customizer) that will allow users to change the background color of the div
In the customize.php file:
<?php
function myTheme_customize_register($wp_customize){
$wp_customize->add_section('colors', array(
'title' => __('Colors', 'myTheme'),
'priority' => 30
));
$wp_customize->add_setting('bg_color', array(
'default' => '#f0a709',
'transport' => 'postMessage', // I have also tried 'refresh'
));
$wp_customize->add_control( new WP_Customize_Color_Control ($wp_customize, 'bg_color', array(
'label' => __('Background Color', 'myTheme'),
'section' => 'colors',
'settings' => 'bg_color',
)));
}
add_action('customize_register', 'myTheme_customize_register');
In my functions.php:
<?php
function myTheme_customize_css(){ ?>
<style type="text/css">
.hi{
background-color: <?php echo get_theme_mod('bg_color', '#f0a709'); ?> !important;
}
</style>
<?php
}
add_action('wp-head', 'myTheme_customize_css');
require get_template_directory().'/inc/customize.php';
?>
In the Customizer, the section 'Colors' is available and also the Color Picker, but selecting another color does nothing. The option for additional CSS is also available, and to test, when selecting the div and giving it a custom bg-color, the color does indeed change. I have also created another section of code in the customizer.php which handles some custom footer settings, things like heading text and button customization, and that's working just fine. I have a feeling the solution is really simple but I'm just not seeing it. Any help would be greatly appreciated.
The action will be like this :
add_action('wp_head', 'myTheme_customize_css');
You write the action name wrong. It will work as expected.

How to create specific footers for specific pages in wordpress?

So - I've been running around ways to do this and get half way there which is a bit infuriating!
Using jetpack portfolio - I want to show normal categories in my blog section and posts, and jetpack project types on the portfolio page and single projects.
My current code looks like this - and shows the jetpack portfolio types for the first post on the archive-jetpack-portfolio, and display correctly on the single project. but doesn;t work at all for the blog posts.
<?php
if (is_page_template('page-blog.php','single.php','index.php' )){
wp_list_categories(array(
'show_option_all' => '',
'title_li' => '',
'separator' => '%20',
'orderby' => 'name'
));
} else {
the_terms($posts->ID, 'jetpack-portfolio-type');
}
?>
So if these pages - show this, else show this. I know the $post-ID is where it's falling over for the archive page. Don't know why the blog bit isn't working.
Hope that's enough to go on. I bow to your infinite knowledge hive-mind!
Depending on custom template you have created you will need to call for custom footer using get_footer function. Here you can read more about get_footer function. You just need to specify $name parameter.
Monika

WordPress: Adding Theme Support

I am trying to add the "Custom-Background" theme hook for a WordPress site.
In my functions file, the one for the theme folder, I added
add_theme_support( 'Custom Background', array (
'background-color' => '#000000',
'background-size' => 'cover'
) );
It seems to work because going into the WordPress Dashboard -> Appearances -> Background, I can add an image and have it shown in the Customizer space. But when I actually go to the page itself, it shows me a blank white background.
Is there an additional code I need to add to my '.php' files? There was a similar post previously here:https://wordpress.stackexchange.com/questions/259315/custom-background-image-not-showing-up
But I believe this does not work anymore, or maybe I'm doing my process wrong.
Based on the codex sample you need this format
$args = array(
'default-image' => 'https://cdn.pixabay.com/photo/2015/12/01/20/28/road-1072823__340.jpg',
'default-size' => 'cover',
);
add_theme_support( 'custom-background', $args );
Thank you for replying. I found out what the issue was with my code. It wasn't that my code was in an incorrect form, but I had forgotten to put a
<body <?php body_class();?>>
wherever I put my tag in.

Add sub-pages to the navigation menu on a customized Wordpress theme using php, css, and jQuery?

I'll try making my story short and concise.
I work for a small family owned company.
The web developer parted ways with the company.
I was appointed to maintain this site:
http://tintedadvertisinggraphics.com/
All I have to do is update content (add subpages and text)
I'm having a super hard time because the theme does not natively support a menu which means everything is hard coded. I tried going to Wordpress > pages > and adding them but it didn't work.
I finally figured out how to show the subpage button under services that says logo (http://tintedadvertisinggraphics.com/window-graphics/) by adding the page id to this piece of header.php:
<?php wp_list_pages('title_li=&include=8,4,53,51,132,146,152,246'); ?>
<!-- <li <?php if (is_category('1')){echo 'class="current_page_item"';}?>>BLOG</li>-->
SO my question is where do I go from there? How do I make the sub-page button I made work? How do I make it so that when the sub-page button is clicked it opens up the page (logos.php) I created? I have been using firebug like crazy and I know, or mostly think, that I have to find wherever it says li.page_item? And I thought it was in a php file and then I thought maybe css but if my fears are correct it's jquery and I have no idea where to even begin. So any help will be most appreciated!!
Ya know, it might be easier to just add support for nav menus and replacing that code.
In your functions.php file you can add_theme_support('menus'); (See Codex on Theme Support) anywhere which will allow you to create menus under Appearances -> Menus. You can then replace the wp_list_pages() with wp_nav_menu('Menu Name here'); and it will be much easier to maintain in the long run. If you want to go further you can add a custom walker to include subpages automatically: View Auto-Submenu Walker
Step 1: Create a menu. Add the following code to your functions.php:
function register_RayEames_menu() {
register_nav_menu('header-menu',__( 'Menu Main' ));
}
add_action( 'init', 'register_RayEames_menu' );
Then, nearby where you want these menus in the code, you include it. Now, your needs may be different from mine, but you need to know that wp_nav_menu() has a lot of powerful options available to you. This is based on one of my own sites:
<?php
$defaults = array(
'theme_location' => 'header-menu',
'menu' => 'Menu Main',
'container' => false,
// 'container_class' => '',
// 'container_id' => '',
'menu_class' => 'nav',
// 'menu_id' => '',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
// 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
'depth' => 0,
'walker' => ''
);
wp_nav_menu( $defaults );
?>
Dive into wp_nav_menu()'s documentation.
Once you do that, you can go into the backend of the site and do Appearance > Menus to define what goes there - including posts, pages, categories, arbitrary urls, whatever.

wordpress multiple pages on one page

i am developing a CMS site in wordpress ...
the final web page should some what look like :
Website
I want just one page (front page) and on that i want to display subpages titles in it. (About,Home,People)...
So when the subpage title is clicked it should expand and display the the page content in the panel,on same page and at same place.
any ideas regarding same?
Thanks in advance...:)
EDIT1
[accordions]
[accordion title="Accordion 1"]
Accordion 1 Content here
[/accordion]
[accordion title="Accordion 2"]
Accordion 2 Content here
[/accordion]
[accordion title="Accordion 3" last="last"]
Accordion 3 Content here
[/accordion]
[/accordions]
after puting the above code in the page content looks like this:
but on click of ACCORDION 1 its not getting expanded..
You can write your own template, which does a query (checks for a subpage), and adds its content between div tags.
When it's done, then it's time for JS/jQuery . Search for tab jQuery scripts, so you get some information.
Anyway, you will mostly need to use hide() / show() functions to reach something like that.
Also, did you made that template, and are you familiar with programming in WP?
<?php
$args = array(
'numberposts' => -1,
'post_parent' => $post->ID,
'post_type' => 'page',
'post_status' => 'publish',
'orderby' => 'menu_order,title',
'order' => 'ASC'
);
$my_pagelist = get_children($args);
?>
Above is code for displaying subpage content, below is the jQuery tutorial for tabs.
http://jqueryui.com/demos/tabs/
EDIT:
Also, check this site - http://www.learningjquery.com/2006/09/slicker-show-and-hide it will show you some info about show/hide functions. Also more information about WP get_children function is found here - http://codex.wordpress.org/Function_Reference/get_children
If I understand your question correctly, in the latest version of WordPress.
Login to your admin panel.
Click on the 'Settings' tab, then the 'Reading' sub-tab.
Change the 'Front page displays' option to 'A static page'.

Categories