Custom style user profile pages in Drupal 6 - drupal

I wish to display my tabs (View / Edit etc.) in a sidebar and not on top of the node but only when I am viewing my own profile (maybe when viewing other users profiles too). In my page.tpl.php I have this snippet:
<?php if (!empty($tabs)): ?><div class="tabs-wrapper"><?php print $tabs; ?></div><?php endif; ?>
And I guess it should be something like if (!empty($tabs) && !$user_profile_page) but I can't make it work.

You want to do this using multiple template files in your theme. In your theme you need to copy page.tpl.php and rename it to either:
page-user.tpl.php
(theme all user profile pages at once)
page-user-<id>.tpl.php
(theme a particular user's profile (where <id> is the user id)
Then you just style those particular template files with the tabs you want (no if statements required).

Related

Add Shortcode to All Post Types

I want to display shortcodes (I'm using fruitful Shortcode) above the post title tag (H1). And I want to display it to all my post (also as a template).
i want to be like this
Thanks.
If you want to adjust the way your single posts are displayed for all the posts, you have to edit the single.php file in your theme folder. You can do this in the backend under "Design" -> "Theme Editor" or you can access the folder and files via FTP.
For your default posts in wordpress you just need to open the single.php file and look for the h1 with your title. It can look something like:
<h1><?php the_title(); ?></h1>
Above that (if you want to display it above), you can put your shortcode with the do_shortcode() function:
<?php echo do_shortcode('[name_of_shortcode]'); ?>
If you are not using normal posts of wordpress but custom post types or something else, please have a look at the wordpress template hierarchy to find out, which file to edit or how to name the new files for creating template files: https://developer.wordpress.org/themes/basics/template-hierarchy/
If you are using a theme that is not made by you, you should make sure you keep your theme updateable. So if you overwrite the single.php, with the next update of your theme, the file will not have your edits. You need a child theme, if you want to keep your parent theme up to date but also customize it in the page templates. Here is a nice tutorial for child themes: https://www.smashingmagazine.com/2016/01/create-customize-wordpress-child-theme/

How to name different footer files which can be selected in wp-admin's page editors

Seen this done before in other templates, just wondering if anyone here knows how to do this.
I have one template I have created, and two hard coded footer files. footer.php and footer-1.php.
I want to be able to select between using either footer.php or footer-1.php in wp-admin via the pages editor.
So far all I have found so far is adding something like this to the top of the file:
Template Name: footer_1
However, this requires that a secondary header and other files are also included, it won't allow just a change of footer alone.
Can anyone tell me how I can name different footer files so that wordpress detects them in wp-admin and allows me to switch between them.
I do not require adding widgets to these, there is simply two styles of footer and they have no correlation to page or category to hard code, they have to be selected in the admin area manually.
To dynamically change your footer with a admin editor option, do the following:
Open the page you want to customize in editor
Locate Custom Fields meta box in editor (If it is not visible tick the box Custom Fields in the Screen options dropdown at top right)
Select Add Custom Field in Custom Fields meta box
Enter footer_template in Name field and an arbitrary id in the Value field
Select Update to save your settings
Open your theme folder and locate page.php file
Open page.php file and locate the very last line <?php get_footer(); ?>
Delete the line in step 7 and add the following:
<?php
$scriptonomy_footer_meta = get_post_meta(get_the_ID(), 'footer_template', true);
get_footer($scriptonomy_footer_meta); ?>
Save and close page.php file
Make a duplicate of footer.php and name it footer- plus any arbitrary id you chose in step 4, ie: footer-1.php or footer-two.php
Now you can assign any custom footer to any page. You can do the same for the header as well using this technique.

how to add wordpress theme in page which take template of external php file

I want to make php file "demo.php" in geany editor and then I want to add that page in my website.To do this task I have add "demo.php" in folder "wordpress/wp-content/themes/my_wesite_theme" ,after that my wordpress show that file as template "demo" , up to this its ok.
After that i want to add new page "new-page-of-site" in wordpress which take template of "demo" which is my php file template ,after selection of that template when i view "new-page-of-site" in browser it show only output of that page without wordpress theme ,so how can I include wordpress theme in that page.
This is a simple process and is very easy to do.
First of all, you need to name the template correctly. This just means adding the prefix page- before the name of the template. Like so:
page-demo.php
Next, you have to add a tiny bit of code to the top of the template page just so that WordPress will know what the template is called.
Open up the new page-demo.php that you have created, and add this code to the top:
<?php
/*
Template Name: Demo
*/
// names the template
get_header(); // gets the header detail
?>
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
//
// Post Content here
//
} // end while
} // end if
?>
<?php
get_footer(); // gets the footer detail
?>
I've added some code for the actual page but you'll want to change it up to fit your actual page layout.
When you get into the WordPress admin area for adding new pages, on the right hand side below the save button, you should have an area for changing the template, just choose the new option, save and then you should be able to view the page with the new template.

Make another content list as content file of wordpress

I have page I want to display the page in different style (not as the content.php file ) so now I made copy the content.php file and just modified it. I want to display only for one page and other pages should display like content.php . So how can I change the index page to display the particular as new content-list page. My page name is News and it should be display like content-list.php.
For display indiviual page you have to make a Template for that page and from
Dashboard-->Pages open the page where you want to display that template, on right hand side you have seen TAMPLATE-->DEFAULT TEMPLATE, select template you have created...
Syntax for new template
<?php
/*Template Name:abc
*/
?>
<?php get_header();?>
<!--------------------------------------->
CONTENT FOR PAGE
<!--------------------------------------->
<?php get_Footer();?>
I don't know about which file you're referring to as content.php
I have page i want display the page in different style
So, if you want to display a page with a different style, you should have a look at WordPress Template Hierarchy.
You can create another page template, use custom files like header-{name}.php and footer-{name}.php and use get_header() and get_footer() with the appropriate arguments(the {name} you mentionned to call these files.

sidebar in wordpress

I want to display different dynamic sidebar on different pages, how do I access multiple sidebar on my pages.
Place some form of hook on different pages.
Open sidebar.php in your themes and check for presence of hook.
You should create files like sidebar-xxxx.php and include it, using get_sidebar(xxxx) in the different templates and souhld register them on the functions.php. If you do not wanna create these files you can register the sidebars on functions.php and in the sidebar.php use:
global $wp_query;
$page_name = $wp_query->post->post_name;
<ul>
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar-'.$page_name) ) : ?>
<?php endif; ?>
</ul>
create a new sidebar
and you can link them inc with is page
if(is_page(5)) {
include('new-sidebar.php')
}
is page id is 5 lets say thats the id for your home page
just check the ids of your pages and seperate them
if you want them tho show in the page childs to
just write
if(is_page(5) || $post->post_parent) {
include('new-sidebar.php')
}
zou can even write a function either
For different sidebars, i thing you have to do is to create the sidebar which you want as many as you want and save those sidebars as sidebar1.php, sidebar2.php and so on.
And,just include it in the different pages where you want it to display like this:
<?php include('sidebar1.php'); ?>
And, like wise for other sidebars of other pages.

Resources