How to create specific footers for specific pages in wordpress? - php

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

Related

Wordpress sidebar custom icon

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

Custom taxonomy images - output to single product pages

I'm trying to display images attached to custom taxonomies on the individual product pages. I've used the Custom Taxonomy plugin (https://wordpress.org/plugins/taxonomy-images/) and added the images using Advanced Custom Fields. I have 2 custom taxonomies called 'range_logo' and 'features', each with images assigned to them. I need to output the images to the single product page using the hook 'woocommerce_before_add_to_cart_form'.
As you can see below, I have tried outputting a line of text to test if the hook is working correctly, and it is, but the taxonomy image isn't shown when I add the code which is supplied with the Taxonomy Images plugin.
add_action(
"woocommerce_before_add_to_cart_form","product_taxonomy_image");
function product_taxonomy_image () {
echo 'Taxonomy image here';
print apply_filters( 'taxonomy-images-queried-term-image', '' );
}
Expected results are that the appropriate taxonomy image for the product would be displayed. Instead I got this error:
Notice: term_taxonomy_id is not a property of the current queried object. This usually happens when the taxonomy-images-queried-term-image-id filter is used in an unsupported template file. This filter has been designed to work in taxonomy archives which are traditionally served by one of the following template files: category.php, tag.php or taxonomy.php. Learn more about template hierarchy. in /var/sites/a/mysite.com/public_html/wpnew/wp-content/plugins/taxonomy-images/legacy/includes/public-filters.php on line 398
I'm using the Avada theme - maybe the layout of the theme's template files could be the reason for the error? I think I may need to use archive.php instead, but I don't have much experience with PHP.
I've tried a few possible solutions and have looked elsewhere for help, but I've hit a wall with getting this to work and I'm not sure what I should be trying next.
welcome to the community. First off, I would like to mention that you have written a bit confusing detail about the taxonomy images as you have mentioned using the plugin Taxonomy Images as well as Advanced custom fields
If you are using the former plugin, you can do something as shown below:
add_action("woocommerce_before_add_to_cart_form","product_taxonomy_image");
function product_taxonomy_image () {
print apply_filters( 'taxonomy-images-list-the-terms', '', array(
'before' => '<div class="my-custom-class-name">',
'after' => '</div>',
'before_image' => '<span>',
'after_image' => '</span>',
'image_size' => 'detail',
'taxonomy' => 'product_cat',
) );
}
The above code will give you the images from the category associated with that product. If it is another custom taxonomy that you created, please change the value in taxonomy parameter.
If you are using ACF you will have to get product terms first. Let me know if that's the case and I will share that code with you.

WordPress, Parse Shortcode within Shortcode

I'm working on a site for a client that runs a social ransom style blog. This is where the user has to click one of the social media buttons to get access to the content.
However, she is now going to use the OnePress Social Locker Plugin for wordpress which works by wrapping the content in specific tags, like so:
[sociallocker] Content Here will Be Locked [/sociallocker]
At the moment she already has her own custom shortcode in place which works like this:
[socialLock url="http://example.com" text="Click here to view content"] Content here will be locked [/socialLock]
The problem is that she has over 2,300 pages on her blog and to change every single one indv. through the dashboard will take ages and this is not a by the hour pay contract.
I thought that I would be able to pass the current shortcode into the new one like so:
function parseShortcode_func( $atts ) {
$atts = shortcode_atts( array(
'link' => '',
'text' => 'default text'
), $atts );
return "[sociallocker] {$atts['text']} [/sociallocker]";
}
add_shortcode( 'socialLock', 'parseShortcode_func' );
However that just outputs
[sociallocker] Click here to view content [/sociallocker]
Has anyone got any ideas how to parse this second shortcode within a shortcode?
The do_shortcode() function will reparse your output string.
return do_shortcode("[sociallocker] {$atts['text']} [/sociallocker]");

Custom post layouts in WordPress

I'm quite new to WordPress, and I'm trying to ease myself into it. I'm currently having a problem with the layout of posts.
One solution to a common layout problem is to require the user to put their content within separate divs within the WYSISYG editor. However, this is obviously not that user friendly.
One solution would be: when they create a new post, there are two separate WYSISWYG editors for that single post. One editor for images, one editor for text. This isn't exclusively a problem of separating images from text — more for separating content from content.
I'm not sure whether this would be with the functions.php or a plugin. I'd rather try and not use plugins if I don't have to.
Any information would be great.
Within the visual editor you can double click an image that you've included and within the advanced tab add your custom classes to it. WP also has alignleft, alignright and more classes for images. If my answer is off I think your question may need to be more pointed.
to solve your first, more specific issue regarding how to separate images from text (content).
As usual, there are many ways to achieve such result. I use this one:
As you may know, you can add images to every single post. The problem you certainly come up against is how to attach specific photos to a specific post without using a gallery placeholder inside the content (WYSISYG editor).
You can do so by uploading photos through "Add media" button. It is essential to "upload" those images to a post not to pick them from the media library. It is my understanding that without plugins this is the only way to genuinely attach images to a post.
The question arises how to get the attachment in your templates.
I use this generic function of mine written in functions.php to fetch attachments of a post:
function get_attachment($args) {
$defaults = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' =>'any', 'post_parent' => $post->ID);
$options = array_merge($defaults, $args);
return get_posts( $options );
}
Since you can upload other types of media (video, audio), there are examples how to use the mentioned function within your templates:
$gallery_images = get_attachment(array('post_parent' => $post->ID, 'post_mime_type' => 'image'));
$audio_files = get_attachment(array('post_parent' => $post->ID, 'post_mime_type' => 'audio'));
$video_files = get_attachment(array('post_parent' => $post->ID, 'post_mime_type' => 'video'));
To respond to your more generic question – separating content from content - indeed, you can alter the admin interface of "Add post form" by creating custom fields or meta boxes.
The help for creating meta boxes can be found in the Wordpress Codex, for instance here:
http://codex.wordpress.org/Function_Reference/add_meta_box
I hope it enlightens a bit.

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