Tagged: custom menu, Custom Post Type, logo, navigation
-
AuthorPosts
-
November 22, 2014 at 8:58 pm #356018
Hi everyone at Kriesi,
First of all, as I’ve said 1 million times before, LOVE your theme and amazing support! So thanks guys!
Okay here’s my questions: Using your great tutorial for creating custom post types and adding in the avia layout builder (https://kriesi.at/support/topic/displaying-custom-post-types-inside-of-the-avia-layout-builder/), I’ve created a custom post type called ‘SP’.
Now I’m hoping it’s possible to do 2 things:
– Use a custom menu for all SP posts (I’ve tried the “CE WP-Menu per Page” plugin, but it only works for ‘pages’ and I can’t seem to get my custom post to behave like a page so that the plugin recognizes it)
– Use a different logo for all SP posts (I saw your snippet for using a custom logo for the frontpage, but what I’d like is to assign the new logo to all pages that are either the ‘SP’ custom post or are labeled with the a certain ‘category’)Don’t know if this is way beyond doable or anything but thought it would be good to get your wise advice.
Thanks,
CamilleNovember 24, 2014 at 7:28 am #356561Hey camtay!
Thank you for using Enfold.
Please use these plugins to control the menu visibility:
https://wordpress.org/plugins/menu-items-visibility-control/
https://wordpress.org/plugins/zen-menu-logic/Since, you’re trying to show different menu items for a custom post type, the is_singular() conditional will surely help. Regarding the logo, you can add this on functions.php:
add_filter('avf_logo','new_logo_url'); function new_logo_url($use_image){ if(is_singular('sp')) { $use_image = "http://kriesi.at/wp-content/themes/kriesi/images/logo.png"; } return $use_image; }
You might need to change the custom post type id.
Best regards,
IsmaelNovember 25, 2014 at 2:19 am #357297Hi Ismael,
Wonderful, I will use one of these plugins, thanks!
As for the logo, can I add pages to this code, like this?
add_filter(‘avf_logo’,’new_logo_url’);
function new_logo_url($use_image){
if(is_singular(‘sp’); (is_page(42)); (is_page(68)) {
$use_image = “http://kriesi.at/wp-content/themes/kriesi/images/logo.png”;
}
return $use_image;
}November 25, 2014 at 8:02 pm #357856Hey Ismael,
I tried the code and it doesn’t change the url. What did you mean by “you might need to change the custom post type id”?
Thanks!November 26, 2014 at 6:01 pm #358401Hi!
On this line,
if(is_singular('sp')) {
You’ll need to change “sp” to the slug of your custom post type. See here for more info, http://codex.wordpress.org/Function_Reference/is_singular.
If you want to add pages then you can do this.
if( is_singular('sp') || is_page( array( 1, 2, 3 ) ) ) {
Where 1, 2, 3 are the ID’s of your pages.
Regards,
ElliottNovember 26, 2014 at 6:26 pm #358421Hi Eliott, I tried that but when I try to load a custom post, I get an error:
Parse error: syntax error, unexpected ‘}’ in /home/content/34/11243234/html/wp-content/themes/enfold-child/functions.php on line 68Here’s the code I pasted in (‘spicypresentations’ is the slug of my custom post) and line 68 is the last line:
add_filter(‘avf_logo’,’new_logo_url’);
function new_logo_url($use_image){
if(is_singular(‘spicypresentations’)) {
$use_image = “http://nutsandboltsspeedtraining.com/wp-content/uploads/2014/11/sp-logo-rough.png”;
}
return $use_image;
}If it helps, here’s my site: http://www.nutsandboltsspeedtraining.com
In case it helps, here are the other things I’ve put in the functions.php or my child theme:
<?php@ini_set(‘display_errors’, 0);
add_action(‘woocommerce_thankyou’, ‘affiliate_tracking’);
function affiliate_tracking( $order_id )
{
global $wpdb;$order = new WC_Order( $order_id );
$order_total = $order->get_order_total();
$shipping = $order->order_shipping;
$total = $order_total – $shipping;
$coupon = $wpdb->get_var($wpdb->prepare(“SELECT order_item_name FROM wp_woocommerce_order_items where order_id = ‘$order_id’ and order_item_type = ‘coupon'”));echo ““;
}// Hook in
add_filter( ‘woocommerce_checkout_fields’ , ‘custom_override_checkout_fields’ );// Our hooked in function – $fields is passed via the filter!
function custom_override_checkout_fields( $fields )
{
$fields[‘billing’][‘billing_email’][‘label’] = ‘Email (will also be used as your username)’;
$fields[‘account’][‘billing_email’] = $fields[‘billing’][‘billing_email’];
$fields[‘account’] = array_reverse($fields[‘account’]);
unset($fields[‘billing’][‘billing_email’]);
unset($fields[‘order’][‘order_comments’]);
$fields[‘billing’][‘billing_company’][‘required’] = false;
$fields[‘billing’][‘billing_phone’][‘required’] = false;
return $fields;
}add_filter (‘add_to_cart_redirect’, ‘woo_redirect_to_checkout’);
function woo_redirect_to_checkout() {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;
}add_filter(‘avf_blog_style’,’avia_change_archive_blog_layout’, 10, 2);
function avia_change_archive_blog_layout($layout, $context){
if($context == ‘archive’) $layout = ‘single-big’;
return $layout;
}add_filter( ‘post-format-standard’, ‘avia_category_content_filter’, 15, 1);
function avia_category_content_filter($current_post)
{
if(!is_single())
{
$current_post[‘content’] = get_the_excerpt();
$current_post[‘content’] .= ‘<div class=”read-more-link”>‘.__(‘Read more’,’avia_framework’).'<span class=”more-link-arrow”> →</span></div>’;
}
return $current_post;
}add_filter(‘avf_logo’,’new_logo_url’);
function new_logo_url($use_image){
if(is_singular(‘spicypresentations’)) {
$use_image = “http://nutsandboltsspeedtraining.com/wp-content/uploads/2014/11/sp-logo-rough.png”;
}
return $use_image;
}Thanks,
CamilleNovember 26, 2014 at 6:34 pm #358427I tried again just now. I cleared my cache, re-typed in the following:
add_filter(‘avf_logo’,’new_logo_url;);
function new_logo_url($use_image){
if(is_singular(‘spicypresentations’)) {
$use_image=”http://nutsandboltsspeedtraining.com/wp-content/uploads/2014/11/sp-logo-rough.png”;
}
return $use_image;
}And I got this message:
Parse error: syntax error, unexpected T_STRING in /home/content/34/11243234/html/wp-content/themes/enfold-child/functions.php on line 64Line 64 is this: if(is_singular(‘spicypresentations’)) {
November 26, 2014 at 7:27 pm #358480This reply has been marked as private.November 27, 2014 at 6:57 am #358854Hey!
I don’t see anything wrong with the code. Please replace it with this:
add_filter('avf_logo','avf_new_logo_url'); function avf_new_logo_url($use_image){ if(is_singular('spicypresentations')) $use_image = "http://nutsandboltsspeedtraining.com/wp-content/uploads/2014/11/sp-logo-rough.png"; return $use_image; }
Regards,
IsmaelNovember 27, 2014 at 8:05 am #358876Hm, still not working. Just tried your latest code and got:
Parse error: syntax error, unexpected ‘:’ in /home/content/34/11243234/html/wp-content/themes/enfold-child/functions.php on line 64Must just be conflicting with a plugin or other code somewhere…
Thanks anyway for your help!
November 28, 2014 at 6:18 am #359401Hi!
What is line 64 on your editor? The code doesn’t even have a colon symbol on it. Please get the code here: http://pastebin.com/KZsVBh5r
Best regards,
IsmaelNovember 28, 2014 at 8:08 pm #359847Hi Ismael, it just worked!!! I must have done something wrong last time!
Is there any way to control the size of this image?
Thanks so much!
November 30, 2014 at 5:42 am #360212Hey!
Try adding this to Quick CSS:
.single-spicypresentations .logo img { width: 220px; height: 120px !important; max-height: none !important; }
Change as needed.
Regards,
JosueDecember 4, 2014 at 12:03 am #362589Great, thank you!
-
AuthorPosts
- The topic ‘Different Main Navigation Menu and Logo for Custom Post Type?’ is closed to new replies.