Tagged: x
-
AuthorPosts
-
April 25, 2016 at 6:03 am #898435
Julian BParticipantHey guys!
I inserted this code into my wp-index.php to show content above my blog layout:
<?php // ============================================================================= // VIEWS/INTEGRITY/WP-INDEX.PHP // ----------------------------------------------------------------------------- // Index page output for Integrity. // ============================================================================= ?> <?php get_header(); ?> <div class="x-container max width offset"> <div class="<?php x_main_content_class(); ?>" role="main"> <?php $custom_blog_page_content = get_post(346); echo apply_filters( 'the_content', $custom_blog_page_content->post_content );?> <?php x_get_view( 'global', '_index' ); ?> </div> <?php get_sidebar(); ?> </div> <?php get_footer(); ?>This works great but I’m using WPML on my website and don’t know how to translate the content if someone switches the language.
I hope you guys can help me.Best regards
Julian
April 25, 2016 at 12:26 pm #898944
ThaiModeratorHi Julian,
Please find this code:
<?php $custom_blog_page_content = get_post(346); echo apply_filters( 'the_content', $custom_blog_page_content->post_content );?>Then replace with this:
<?php if(function_exists("icl_object_id")){ $postID = icl_object_id(346, 'post', false); } else { $postID = 346; } $custom_blog_page_content = get_post($postID); echo apply_filters( 'the_content', $custom_blog_page_content->post_content ); ?>Hope it helps 🙂
April 25, 2016 at 1:23 pm #899050
Julian BParticipantThanks a lot, worked out perfect!!!
Your support really is outstanding 🙂I have another question I’m not sure how to solve. I totally tweaked my header and inserted a custom build HTML menu.
My global header looks like this:<?php // ============================================================================= // VIEWS/GLOBAL/_HEADER.PHP // ----------------------------------------------------------------------------- // Declares the DOCTYPE for the site and includes the <head>. // ============================================================================= ?> <!DOCTYPE html> <!--[if IE 9]><html class="no-js ie9" <?php language_attributes(); ?>><![endif]--> <!--[if gt IE 9]><!--><html class="no-js" <?php language_attributes(); ?>><!--<![endif]--> <head> <?php wp_head(); ?> </head> <body <?php body_class(); ?>> <?php do_action( 'x_before_site_begin' ); ?> <header class="cd-header"> <nav> <ul> <li class="headerdate"><a href="../../../"><img style="padding-right:15px" src="../../../wp-content/themes/x-child/img/fuchs-logo.svg"/></a></li> <li class="headerdate leftt">Fuchsbau Festival</li> </ul> <ul class="cd-secondary-nav"> <li><a href="../../../"><img style="padding-right:15px" src="../../../wp-content/themes/x-child/img/fuchs-logo.svg"/></a></li> <li><a href="../../../programm/">Programm</a><span class="dot-divider">·</span></li> <li><a href="../../../festival">Festival</a><span class="dot-divider">·</span></li> <li><a href="../../../tickets/">Tickets</a></li> </ul> </nav> <!-- cd-nav --> <ul class="social-navbar"> <li><a class="hvr-buzz-out" href="https://www.facebook.com/fuchsbau.hannover/" target="_blank"><img src="../../../wp-content/themes/x-child/img/social-facebook.svg"/></a></li> <li><a class="hvr-buzz-out" href="https://twitter.com/fuchszwitschern/" target="_blank"><img src="../../../wp-content/themes/x-child/img/social-twitter.svg"/></a></li> <li><a class="hvr-buzz-out" href="https://www.instagram.com/fuchsbaufestival/" target="_blank"><img src="../../../wp-content/themes/x-child/img/social-instagram.svg"/></a></li> </ul> <div class="hashtagright"> <a href="<?php the_permalink() ?>?lang=de">DE</a></br> <a href="<?php the_permalink() ?>?lang=en">EN</a> </div> <a class="cd-primary-nav-trigger" href="javascript:void(0)"> <span class="cd-menu-text">Menu</span><span class="cd-menu-icon"></span> </a> <!-- cd-primary-nav-trigger --> </header> <nav> <ul class="cd-primary-nav"> <div class="x-container max width"> <div class="x-column x-sm border-module-header x-1-3" style="padding: 0px; " > <div class="x-text hdg-header" style="padding: 20px 5px 20px 25px;" > <p><span>Fuchsbau Festival</span></p> <a href="../../../festival/">Festival</a><br/> <a href="../../../programm/">Programm</a><br/> <a href="../../../tickets/">Tickets</a><br/> <a href="../../../bewerben/">Bewerben</a><br/> <a href="../../../volunteers/">Volunteers</a><br/> <a href="../../../faq/">FAQ</a><br/> <a href="../../../kontakt/" >Kontakt</a><br/> </div> </div> <div class="x-column x-sm border-module-header x-1-3" style="padding: 0px; "> <div class="x-text hdg-header" style="padding: 20px 5px 20px 25px;"> <p><span>Weitere Projekte</span></p> <a href="../../../erobern/">jmdn. etw. er · obern</a><br/> <a href="https://www.facebook.com/Cirque-%C3%89lectrique-480211905445763/" target="_blank">Cirque Électrique</a><br/> </div> </div> <div class="x-column x-sm border-module-header x-1-3" style="padding: 0px; "> <div class="x-text hdg-header" style="padding: 20px 5px 20px 25px;"> <p><span>Fuchsbau e. V.</span></p> <a href="../../../verein/">Über den Verein</a><br /> <a href="../../../verein/">Spenden</a><br /> </div> </div> </div> </ul> </nav> <div id="top" class="site"> <?php do_action( 'x_after_site_begin' ); ?>Is there a way to translate the static html I inserted? Maybe with WPML string translation?
Like X is outputting the footer content. This is how it shows up in WPML string translation menu:
I really hope you can help me out here. Best regards,
Julian
April 26, 2016 at 7:15 am #900176
JackKeymasterHi there Julian,
Thanks for writing back!
Take a look at this for a getting started guide with translations https://premium.wpmudev.org/blog/creating-translatable-wordpress-themes-plugins/ basically you should be able to use the X textdomain which is __x__ then wrap your html with the translatable functions, update your .mo and .po files and then it should show up as translatable within WPML. 🙂
Thank you!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-898435 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
