Hi I am trying to use the advanced layer slider in my wordpress post page. However my code pasted in the header.php file works only on the pages, not posts, I can see the shortcode showing up though in the top of the posts page. Is there anyway to include the code needed from the plugin easily?
Thanks in advanced,
James
Sorry about the formatting
Single.php
<?php
global $avia_config;
/*
* get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory.
*/
get_header();
$title = __('Blog - Latest News', 'avia_framework'); //default blog title
$t_link = home_url('/');
$t_sub = "";
if(avia_get_option('frontpage') && $new = avia_get_option('blogpage'))
{
$title = get_the_title($new); //if the blog is attached to a page use this title
$t_link = get_permalink($new);
$t_sub = avia_post_meta($new, 'subtitle');
}
if( get_post_meta(get_the_ID(), 'header', true) != 'no') echo avia_title(array('heading'=>'strong', 'title' => $title, 'link' => $t_link, 'subtitle' => $t_sub));
?>
'>
<div class='container template-blog template-single-blog '>
<main class='content units <?php avia_layout_class( 'content' ); ?>' <?php avia_markup_helper(array('context' => 'content','post_type'=>'post'));?>>
<?php
/* Run the loop to output the posts.
* If you want to overload this in a child theme then include a file
* called loop-index.php and that will be used instead.
*
*/
get_template_part( 'includes/loop', 'index' );
//show related posts based on tags if there are any
get_template_part( 'includes/related-posts');
//wordpress function that loads the comments template "comments.php"
comments_template( '/includes/comments.php');
?>
<!--end content-->
</main>
<?php
$avia_config['currently_viewing'] = "blog";
//get the sidebar
get_sidebar();
?>
</div><!--end container-->
</div><!-- close default .container_wrap element -->
Page.php
<?php
global $avia_config;
/*
* get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory.
*/
get_header();
if( get_post_meta(get_the_ID(), 'header', true) != 'no') echo avia_title();
?>
<div class='container_wrap container_wrap_first main_color <?php avia_layout_class( 'main' ); ?>'>
<div class='container'>
<main class='template-page content <?php avia_layout_class( 'content' ); ?> units' <?php avia_markup_helper(array('context' => 'content','post_type'=>'page'));?>>
<?php
/* Run the loop to output the posts.
* If you want to overload this in a child theme then include a file
* called loop-page.php and that will be used instead.
*/
$avia_config['size'] = avia_layout_class( 'main' , false) == 'entry_without_sidebar' ? '' : 'entry_with_sidebar';
get_template_part( 'includes/loop', 'page' );
?>
<!--end content-->
</main>
<?php
//get the sidebar
$avia_config['currently_viewing'] = 'page';
get_sidebar();
?>
</div><!--end container-->
</div><!-- close default .container_wrap element -->
Header.php
<?php
global $avia_config;
$style = $avia_config['box_class'];
$responsive = avia_get_option('responsive_layout','responsive');
$blank = isset($avia_config['template']) ? $avia_config['template'] : "";
$headerS = !$blank ? avia_header_setting() : "";
$headerMenu = $responsive ? avia_get_option('header_menu','mobile_drop_down') : "";
?>
class=" ">
" />
RSS2 Feed" href="" />
" />
';
?>
* tag of your theme, or you will break many plugins, which
* generally use this hook to add elements to such
* as styles, scripts, and meta tags.
*/
wp_head();
?>
'body')); ?>>
<div id='wrap_all'>
<?php if(!$blank){ ?>
<header id='header' class=' header_color <?php avia_is_dark_bg('header_color'); echo " ".$headerMenu; ?>' <?php avia_markup_helper(array('context' => 'header','post_type'=>'forum'));?>>
<?php
if($responsive && $headerMenu == 'mobile_slide_out')
{
echo '<a id="advanced_menu_toggle" href="#" '.av_icon_string('mobile_menu').'></a>';
echo '<a id="advanced_menu_hide" href="#" '.av_icon_string('close').'></a>';
}
$social_args = array('outside'=>'ul', 'inside'=>'li', 'append' => '');
//subheader, only display when the user chooses a social header
if(strpos($headerS,'social_header') !== false)
{
?>
<div id='header_meta' class='container_wrap container_wrap_meta'>
<div class='container'>
<?php
/*
* display the themes social media icons, defined in the wordpress backend
* the avia_social_media_icons function is located in includes/helper-social-media-php
*/
if(strpos($headerS,'bottom_nav_header') === false) avia_social_media_icons($social_args);
//display the small submenu
echo "<nav class='sub_menu' ".avia_markup_helper(array('context' => 'nav', 'echo' => false)).">";
$avia_theme_location = 'avia2';
$avia_menu_class = $avia_theme_location . '-menu';
$args = array(
'theme_location'=>$avia_theme_location,
'menu_id' =>$avia_menu_class,
'container_class' =>$avia_menu_class,
'fallback_cb' => '',
'container'=>'',
'echo' =>false
);
$nav = wp_nav_menu($args);
echo $nav;
$phone = avia_get_option('phone');
$phone_class = !empty($nav) ? "with_nav" : "";
if($phone) echo "<div class='phone-info {$phone_class}'><span>{$phone}</span></div>";
/*
* Hook that can be used for plugins and theme extensions (currently: the wpml language selector)
*/
do_action('avia_meta_header');
echo '</nav>';
?>
</div>
</div>
<?php } ?>
<div id='header_main' class='container_wrap container_wrap_logo'>
<?php
/*
* Hook that can be used for plugins and theme extensions (currently: the woocommerce shopping cart)
*/
do_action('ava_main_header');
?>
<div class='container'>
<?php
/*
* display the theme logo by checking if the default logo was overwritten in the backend.
* the function is located at framework/php/function-set-avia-frontend-functions.php in case you need to edit the output
*/
echo avia_logo(AVIA_BASE_URL.'images/layout/logo.png', false, 'strong');
if(strpos($headerS,'social_header') !== false && strpos($headerS,'bottom_nav_header') !== false) avia_social_media_icons($social_args);
/*
* display the main navigation menu
* modify the output in your wordpress admin backend at appearance->menus
*/
$extraOpen = $extraClose = "";
if(strpos($headerS,'bottom_nav_header') !== false){ $extraClose = "</div></div><div id='header_main_alternate' class='container_wrap'><div class='container'>"; }
echo $extraClose;
echo "<nav class='main_menu' data-selectname='".__('Select a page','avia_framework')."' ".avia_markup_helper(array('context' => 'nav', 'echo' => false)).">";
$avia_theme_location = 'avia';
$avia_menu_class = $avia_theme_location . '-menu';
$args = array(
'theme_location' => $avia_theme_location,
'menu_id' => $avia_menu_class,
'container_class' => $avia_menu_class,
'fallback_cb' => 'avia_fallback_menu',
'walker' => new avia_responsive_mega_menu()
);
wp_nav_menu($args);
echo '</nav>';
/*
* Hook that can be used for plugins and theme extensions
*/
do_action('ava_after_main_menu');
?>
<!-- end container-->
</div>
<!-- end container_wrap-->
</div>
<div class='header_bg'></div>
<!-- end header -->
</header>
<?php } //end blank check ?>
<div id='main'>
Related
My PHP isn't great!
I have some metaboxes in a wordpress website that displays a column type layout. I can output the metabox content as follows:
<?php
// Group ID
$columns_values = rwmb_meta( 'columns_solutions' );
if ( ! empty( $columns_values ) ) : ?>
<section class="columns">
<?php foreach ( $columns_values as $columns_value ) {
// Grab the image
$columns_imgs = isset( $columns_value['_rtl_column_solutions_image'] ) ? $columns_value['_rtl_column_solutions_image'] : array();
foreach ( $columns_imgs as $columns_img ) {
// Set each image size for the responsive background
$column_image_lg = RWMB_Image_Field::file_info( $columns_img, array( 'size' => 'column-lg' ) );
$column_image_md = RWMB_Image_Field::file_info( $columns_img, array( 'size' => 'column-md' ) );
$column_image_sm = RWMB_Image_Field::file_info( $columns_img, array( 'size' => 'column-sm' ) );
$column_image_xs = RWMB_Image_Field::file_info( $columns_img, array( 'size' => 'column-xs' ) );
}
// Grab the title, oversized text and general text
$column_title = isset( $columns_value['_rtl_columns_title'] ) ? $columns_value['_rtl_columns_title'] : array();
$column_oversized = isset( $columns_value['_rtl_columns_oversized'] ) ? $columns_value['_rtl_columns_oversized'] : array();
$column_general_txt = isset( $columns_value['_rtl_columns_general_text'] ) ? $columns_value['_rtl_columns_general_text'] : array();
?>
<div class="columns-wrapper">
<div class="column">
<?php if(!empty($column_title)) { ?>
<div class="section-title">
<h2>
<?php echo $column_title; ?>
</h2>
</div>
<!-- /.section-title -->
<?php } ?>
<?php if(!empty($column_oversized)) { ?>
<div class="oversized">
<?php echo $column_oversized; ?>
</div>
<!-- /.oversized -->
<?php } ?>
<?php if(!empty($column_general_txt)) { ?>
<?php echo wpautop($column_general_txt); ?>
<?php } ?>
</div>
<!-- /.column -->
<div class="column">
<div class="image min-height cover bg-responsive" style="background-image: url(<?php echo LAZY_IMG; ?>);"
data-lg="<?php echo $column_image_lg['url']; ?>"
data-md="<?php echo $column_image_md['url']; ?>"
data-sm="<?php echo $column_image_sm['url']; ?>"
data-xs="<?php echo $column_image_xs['url']; ?>">
</div>
<!-- /.image -->
</div>
<!-- /.column -->
</div>
<!-- /.column-wrapper -->
<?php } ?>
</section>
<!-- /.columns -->
<?php endif; ?>
Output as below:
This is a clonable meta group, I would like to be able to swap the content and the image (left & right) with each odd and even foreach loop/array.
I feel so stupid, all I needed was to count the posts and output alternate html.
I wrapped my code above in this:
<?php $counter = "";
foreach ( $columns_values as $columns_value ) {
$counter +=1;
// all my var stuff here
?>
<?php if($counter == 1) { ?>
<div class="columns-wrapper odd">
<!-- HTML here for the first loop -->
</div>
<?php }
// If the second item in the loop
elseif($counter == 2) {
// Reset the counter
$counter = 0;
?>
<div class="columns-wrapper even">
<!-- Other HTML here for the second loop -->
</div>
<?php } //end the elseif $counter ?>
<?php } //end the foreach stuff ?>
I need to edit this code in a Joomla template so that it shows the page heading (id="jf_page_heading") only when I'm in category blog view and hide it when I'm inside the article.
<?php
$menu = JFactory::getApplication()->getMenu();
$active = $menu->getActive();
if (is_object($active)) {
$pageHeading = $active->params->get('page_heading');
$show_pageHeading = $active->params->get('show_page_heading');
// CALL
if($pageHeading != ''){ // or - if($pageHeading != '' && $show_pageHeading){
?>
<div id="jf_page_heading">
<div class="rt-container">
<div class="rt-block">
<h1><?php echo $pageHeading; ?></h1>
<?php echo $gantry->displayModules('jf-page-heading','basic','basic'); ?>
<div class="clear"></div>
</div>
</div>
</div>
<?php } } ?>
How should I edit it?
To show page heading in category blog view, you don't need to edit the code. Rather you can simply enable the show page heading parameter in your category blog menu. For hiding the page heading in article view, you need create a override for it in your template folder.
Article path: site/templates/html/com_content/article/default.php
Comment the page heading html section you want to hide.
Alternative way, if you want to do it through code as you are using gantry template in category blog view if the code is not present -
You should not check $pageheading in if condition but check the show_pageHeading variable.
Category-blog path: site/templates/html/com_content/category/blog.php
<?php $menu = JFactory::getApplication()->getMenu();
$active = $menu->getActive();
if (is_object($active)) {
$pageHeading = $active->params->get('page_heading');
$show_pageHeading = $active->params->get('show_page_heading'); // returns 1 or 0 if set to Yes or no in menu item
// check if showpageheading is set in menu item
if($show_pageHeading){ ?>
<div id="jf_page_heading">
<div class="rt-container">
<div class="rt-block">
<h1><?php echo $pageHeading; ?></h1>
<?php echo $gantry->displayModules('jf-page-heading','basic','basic'); ?>
<div class="clear"></div>
</div>
</div>
</div>
<?php } } ?>
Follow point(1) for hiding page-heading in article view.
Hope this helps.
Try something like
$input = JFactory::getApplication()->input;
if (
$input->getCmd('option') == 'com_content' &&
$input->getCmd('layout') == 'blog' &&
$input->getCmd('view') == 'category'
) {
// Show title
}
I would like to be able to have the html content of a wordpress page. I try to use this kind of code :
$my_id = 5369;
$post_id_5369 = get_post($my_id);
$content = $post_id_5369->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
But it returns empty an empty string whereas when I access to the page, the content is not empty. Indeed, there is php code inside the content of the page I would like to get. So, how I can do to get the content of this page knowing that there is php code inside?
data content :
<div id="content" class="oe">
<?php $loop = new WP_Query( array('post_type'=>'mcm')); ?>
<div id="slid" class="div-slider">
<?php
/* get value */
$appercu_collection = get_post_custom_values ( "o" );
if ($appercu_collection) { // si appercu
class Image {
public $link;
public $image;
}
/* init value */
$imageCollection = array ();
/* complet collection */
foreach ( $appercu_collection as $img ) {
$img_tmp = new Image ();
$img_tmp->image = wp_get_attachment_image_src( $img , 'medium' )[0];
array_push ( $imageCollection, $img_tmp );
}
display_slider ( $imageCollection );
}
?>
</div>
<div id="content-meta">
<div class="meta-detail-header"><?php echo get_post_custom_values ( "_at" )[0]; ?></div>
<div class="meta-detail-title"><?php the_title(); ?></div>
<div class="audio">
<div id="audio-inner">
<?php $au = get_post_custom_values("_au");
if ($au) {
$urlguid = wp_get_attachment_url ( $au [0] );
if ($urlguid) {
display_audio ( $urlguid );
}
}
?>
</div>
</div>
</div>
<div id="ex">
<?php
$newdebut = get_long_formatted_date( $date_debut[0] );
$newfin = get_long_formatted_date( $date_fin[0] );
?>
<div id="expo-temp-dates"><?php echo sprintf( __( 'From %s to %s' , 'wptouch-pro' ) , $newdebut , $newfin );?></div>
<?php
$tar = get_post_custom_values("_tarif");
if($tar) { ?>
<div id="exprice"><?php echo $tar[0]; ?></div>
<?php }?>
</div>
<div id="content-o" >
<!-- GET Content -->
<div id="content-description" class="detail-container">
<?php display_zoom_controls(); ?>
<?php echo wpautop( wptouch_the_content() ); ?>
</div>
<!-- GET BONUS -->
<div id="content-bottom-sticky">
<a href="<?php echo $url_guide;?>"
class="tappable-button tappable dark" role="Button"><?php _e( 'TUIDE' , 'wptouch-pro' ); ?></a>
</div>
</div>
<?php endif; ?>
<!-- inside intervalle -->
<?php endwhile;
wp_reset_postdata();?>
<?php if( ! $content) { ?>
<div id="title" class="title">
<h2><?php _e( 'N' , 'wptouch-pro' ); ?></h2>
</div>
<?php }?>
I finally resolve my problem by doing an ajax request to my page and get the content thanks to
wp_remote_get . Indeed, It was a page with a custom type post and custom fields.
Here is my code :
$resp = wp_remote_retrieve_body( wp_remote_get($url,$option));
$doc = new DOMDocument();
$doc->loadHTML($resp);
$element = $doc->getElementById('content');
$content = $doc->saveHTML($element);
$content contains the html content of the element with the id "content" of the page whose url is $url.
Currently my image gallery has 4 images per row. If the screen is minimized below the width of those 4 images, one image will drop to the next line and there will be a line break before the next row. Is there any way to make gallery continuous instead of having the break in images when the screen is resized? Ideally, I would like to start with 5 images per row, then if the viewer has a smaller screen, it will automatically adjust the number of images per row to fit whatever size window they are using.
Here is a link to the gallery: http://rabbittattoo.com/?gallery=gallery
And the PHP:
$pp_gallery_style = get_option('pp_gallery_style');
if($pp_gallery_style == 'f')
{
include_once(TEMPLATEPATH.'/gallery-f.php');
exit;
}
if(!isset($hide_header) OR !$hide_header)
{
get_header();
}
$caption_class = "page_caption";
$portfolio_sets_query = '';
$custom_title = '';
if(!empty($term))
{
$portfolio_sets_query.= $term;
$obj_term = get_term_by('slug', $term, 'photos_galleries');
$custom_title = $obj_term->name;
}
else
{
$custom_title = get_the_title();
}
/**
* Get Current page object
**/
$page = get_page($post->ID);
/**
* Get current page id
**/
if(!isset($current_page_id) && isset($page->ID))
{
$current_page_id = $page->ID;
}
if(!isset($hide_header) OR !$hide_header)
{
?>
<div class="wrapper_shadow"></div>
<div class="page_caption">
<div class="caption_inner">
<div class="caption_header">
<h1 class="cufon"><?php echo the_title(); ?></h1>
</div>
</div>
</div>
</div>
<!-- Begin content -->
<div id="content_wrapper">
<div class="inner">
<!-- Begin main content -->
<div id="gallery_wrapper" class="inner_wrapper portfolio">
<div class="standard_wrapper small">
<br class="clear"/><br/>
<?php
}
else
{
echo '<br class="clear"/>';
}
?>
<?php echo do_shortcode(html_entity_decode($page->post_content)); ?>
<!-- Begin portfolio content -->
<?php
$menu_sets_query = '';
$portfolio_items = 0;
$portfolio_sort = get_option('pp_gallery_sort');
if(empty($portfolio_sort))
{
$portfolio_sort = 'DESC';
}
$args = array(
'post_type' => 'attachment',
'numberposts' => $portfolio_items,
'post_status' => null,
'post_parent' => $post->ID,
'order' => $portfolio_sort,
'orderby' => 'date',
);
$all_photo_arr = get_posts( $args );
if(isset($all_photo_arr) && !empty($all_photo_arr))
{
?>
<?php
foreach($all_photo_arr as $key => $portfolio_item)
{
$image_url = '';
if(!empty($portfolio_item->guid))
{
$image_id = $portfolio_item->ID;
$image_url[0] = $portfolio_item->guid;
}
$last_class = '';
$line_break = '';
if(($key+1) % 4 == 0)
{
$last_class = ' last';
if(isset($page_photo_arr[$key+1]))
{
$line_break = '<br class="clear"/><br/>';
}
else
{
$line_break = '<br class="clear"/>';
}
}
?>
<div class="one_fourth<?php echo $last_class?>" style="margin-right:24px;margin-bottom:24px;margin-top:-20px">
<a title="<?php echo $portfolio_item->post_title?>" href="<?php echo $image_url[0]?>" class="one_fourth_img" rel="gallery" href="<?php echo $image_url[0]?>">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/timthumb.php?src=<?php echo $image_url[0]?>&h=370&w=350&zc=1" alt=""/>
</a>
</div>
<?php
echo $line_break;
}
//End foreach loop
?>
<?php
}
//End if have portfolio items
?>
</div>
<!-- End main content -->
<br class="clear"/><br/>
</div>
<?php
if(!isset($hide_header) OR !$hide_header)
{
?>
</div>
<!-- End content -->
<?php get_footer(); ?>
<?php
}
?>
Thank you in advance for you help!
I am using the same theme as this site http://foreignpolicydesign.com/v3/. However, my test site does not distribute the blog entries in columns
What might be causing this problem? I am suspecting it is whatever sets the $col_class to set the x1 ~ xN, but I cannot find the source of this variable.
Here is the code:
<?php include (TEMPLATEPATH . '/tanzaheader.php');
// [grid column setting]
$col_w = 200; // width of grid column
$gap_w = 35; // padding + margin-right (15+15+5)
$max_col = 5; // max column size (style div.x1 ~ xN)
// * additional info *
// check also "style.css" and "header.php" if you change $col_w and $gap_w.
// - style.css:
// div.x1 ~ xN
// div.grid-item
// div.single-item
// ... and maybe #sidebar2 li.widget.
// - header.php:
// gridDefWidth in javascript code.
//
// if you want to show small images in main page always, set $max_col = 1.
// [grid image link setting]
$flg_img_forcelink = true; // add/overwrite a link which links to a single post (permalink).
$flg_img_extract = false; // in single post page, extract thumbnail link to an original image.
$flg_obj_fit = 'large-fit'; // none | small-fit | large-fit ... how to fit size of object tag.
// * additional info *
// if you use image popup utility (like Lightbox) on main index, set $flg_img_forcelink = false;
?>
<!-- <?php if (is_singular()) : $is_top_single = true; /* wide column for single post */ ?> -->
<?php /* make a new query for grid items (in single page) */
$new_query_arg = 'paged='.$paged;
// use this code if you want filter items by category.
$arr_catID = array(20);
foreach( get_the_category() as $cat) $arr_catID[] = $cat->cat_ID;
if ( count($arr_catID) ) $new_query_arg .= '&cat=' . join(',', $arr_catID);
query_posts($new_query_arg);
?>
<!-- <?php endif; /* end of if is_singular() */ ?> -->
<div id="grid-wrapper">
<?php if (have_posts()) :
if ( $is_top_single ) $GLOBALS['more'] = false; //important
while (have_posts()) : the_post(); ?>
<?php
$content = get_the_content('Details ยป');
$content = apply_filters('the_content', $content);
list($col_class, $grid_img) = adjust_grid_image(
$content,
$col_w,
$gap_w,
$max_col,
$flg_img_forcelink,
$flg_obj_fit
);
?>
<div <?php post_class('grid-item ' . $col_class); ?> id="post-<?php the_ID(); ?>">
<h2 class="post-title"><?php the_title(); ?></h2>
<?php if ($grid_img) echo '<div class="grid-image">' . $grid_img . '</div>'; ?>
<div class="post-body">
<?php
$content = preg_replace('/<img(?:[^>]+?)>/', '', $content); // remove img tags
$content = preg_replace('/<a([^>]+?)><\/a>/', '', $content); // remove empty a tags
$content = preg_replace('/<p([^>]*?)><\/p>/', '', $content); // remove empty p tags
$content = preg_replace('/<object(.+?)<\/object>/', '', $content); // remove object tags
echo $content;
?>
</div>
<p class="post-meta">
Published on <?php the_time( get_option('date_format') ); ?> <?php the_time(); ?>.<br />
Filed under: <?php the_category(', ') ?> <?php the_tags('Tags: ', ', '); ?>
<?php edit_post_link(__("Edit This"), '(', ')'); ?><br />
<?php /*comments_popup_link();*/ ?>
</p>
</div>
<?php endwhile; else : ?>
<div class="grid-item x1">
<h2>Not Found</h2>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
</div>
<?php endif; ?>
</div><!-- /grid-wrapper -->
<div class="pagination" id="grid-pagination">
<?php paginate_links2($is_top_single); ?>
</div>
<?php /* reset the query */
wp_reset_query();
?>
</div><!-- /container -->
<?php include (TEMPLATEPATH . '/tanzafooter.php'); ?>
The columns are not created by PHP code, they are created dynamically by a jQuery plugin.
Your theme is referencing it here:
http://wpbeta.nfshost.com/wp-content/themes/js/jquery.vgrid.0.1.4-mod.js
But that returns a 404 file not found error.