I am using a custom post type to allow a client to add job listings to their site using the Avada Theme. The desired archive layout involves using pre-built fusion toggles to display each job post (individual job posts use Advanced Custom Fields). I have created a custom archive-employment.php to run my code for this page in and was successfully able to create toggles for each post, however, each toggle acts independently and does not close when another one opens. Here is what I have so far:
<?php echo do_shortcode ('[fusion_accordion type="accordions" boxed_mode="" border_size="" border_color="" background_color="" hover_color="" divider_line="" title_font_size="" icon_size="" icon_color="" icon_boxed_mode="" icon_box_color="" icon_alignment="" toggle_hover_accent_color="" hide_on_mobile="" class="" id="hr-employment"]'); ?>
<?php if(have_posts()) :
while(have_posts()) : the_post();?>
<div class="entry-content">
<?php $title = get_the_title(); ?>
<?php $dept = get_field("department"); ?>
<?php $jobType = get_field("job_type"); ?>
<?php $salary = get_field("salary"); ?>
<?php $desc = get_field("job_description"); ?>
<?php $addInfo = get_field("additional_info"); ?>
<?php echo do_shortcode ('[fusion_toggle title="'.$title.'" open="" ]Department: '.$dept.' </br> Job Type: '.$jobType.' </br> Salary: $'.$salary.' </br> Description: PDF[/fusion_toggle]'); ?>
</div>
<?php endwhile;
endif; ?>
<!--<?php echo do_shortcode ('[/fusion_accordion]'); ?> Plain Text Error; Not a Valid Shortcode Operator -->
How do I make it so that the [fusion_accordion] shortcode is executed only once and is wrapped around the [fusion_toggle] shortcodes that run in the while loop?
Related
I've created custom post type as single-service.php and I have several custom taxonomies under service posts like education, recruit and health.
I currently created some queries and under each query, I want to create a button which direct the users the contact form page of that service. It is like when you get into a single service page which is categorized under education there will a button directs them to education contact form page likewise for recruit page.
I have tried below link but somehow it does not work. I am not sure whether I am using correct code or where do I make mistake
<?php if (in_category( 'education', $post->ID )) : ?>
<?php echo '<div class="button">Contact us</div>'; ?>
<?php elseif (in_category('recruit', $post->ID)) :?>
<?php echo '<div class="button">Contact us</div>'; ?>
<?php elseif (in_category('health', $post->ID)) :?>
<?php echo '<div class="button">Contact us</div>'; ?>
<?php endif;?>
I solve my problem by creating two custom fields in the template page and linking them with :
<div class="service-button">
<?php $info = get_post_meta(get_the_ID(), '_post_info', true); if (!$info) $info = array(); ?>
<a class="form" style="background-color:<?php echo $info['color'] ?>" href="<?php echo $info['form'] ?>">Contact us</a>
<?php if ($info['website']) : ?>
<a class="website" style="background-color:<?php echo $info['color'] ?>" href="http://<?php echo $info['website'] ?>"><?php echo $info['website'] ?></a>
<?php endif; ?>
</div>
I can't seem to display only the content I request. I am using the Advanced Custom Fields (ACF) plugin with my Wordpress site, and using a repeater field with a multiple select field for "departments \ job titles".
With the code below, I am looking to display only the content which has the value that equals what I select. Maybe I am looking at this wrong but the content displays whether the strpos is true or not.
<?php if (get_field('policy_links') ): ?>
<center><h3><a name="All"></a>All Employees</h3></center>
<hr>
<ul class="bullets">
<?php while (has_sub_field('policy_links')) : ?>
<?php $jobtype = get_sub_field('who_is_this_for'); ?>
<?php if (strpos ($jobtype, 'ma') !== false) { ?>
<li><a href="<?php the_sub_field('link_to_the_document'); ?>">
<?php the_sub_field('display_name'); ?></a><span> - <small>
<?php the_sub_field('link_notes'); ?></small></span>
<?php the_sub_field('who_is_this_for'); ?></li>
<?php } else { ?><p>fail </p>
<?php }; // end of the loop. ?>
<?php endwhile; // end of the loop. ?>
</ul>
<?php endif; ?>
Your if statement should be done like this:
<?php if(get_sub_field('who_is_this_for') == 'strpos') { ?><?php }?>
Where "strpos" is the value you select (if I follow correctly).
It would probably be beneficial to actually see your fields.
I was on the right track. It turns out the ACF is converted to an array when multiple values are selected. I performed an implode to the variable then used the converted string performed the validation.
thanks for the help
Because I am not a professional programmer, I can’t get the ACF integration up for the fishpig magento running.
Bought both the FishPig-ACF Add-on and the ACF Pro.
Installed both and made a custom field named “repeater” and as the autor describes in his manual, I added this code to the /post/view.phtml:
<?php $value = $post->getMetaValue('repeater') ?>
So my view.phtml looks like this:
<?php
/**
* #category Fishpig
* #package Fishpig_Wordpress
* #license http://fishpig.co.uk/license.txt
* #author Ben Tideswell <help#fishpig.co.uk>
*/
?>
<?php $post = $this->getPost() ?>
<?php if ($post): ?>
<?php $helper = $this->helper('wordpress') ?>
<?php $author = $post->getAuthor() ?>
<div class="page-title post-title">
<h1><?php echo $this->escapeHtml($post->getPostTitle()) ?></h1>
</div>
<div class="post-view">
<p class="post-date when"><?php echo stripslashes($this->__('This entry was posted on %s<span class=\"by-author\"> by %s</span>.', $post->getPostDate(), $post->getAuthor()->getDisplayName())) ?></p>
<?php echo $this->getBeforePostContentHtml() ?>
<?php $value = $post->getMetaValue('repeater') ?>
<div class="post-entry entry std<?php if ($post->getFeaturedImage()): ?> post-entry-with-image<?php endif; ?>">
<?php if ($post->isViewableForVisitor()): ?>
<?php if ($featuredImage = $post->getFeaturedImage()): ?>
<div class="featured-image left"><img src="<?php echo $featuredImage->getAvailableImage() ?>" alt="<?php echo $this->escapeHtml($post->getPostTitle()) ?>"/></div>
<?php endif; ?>
<?php echo $post->getPostContent() ?>
<?php else: ?>
<?php echo $this->getPasswordProtectHtml() ?>
<?php endif; ?>
</div>
<?php echo $this->getAfterPostContentHtml() ?>
<?php echo $this->getCommentsHtml() ?>
</div>
<?php endif; ?>
But in fronted the ACF is not shown.
THX for any help
You have copied and pasted the following code:
<?php $value = $post->getMetaValue('repeater') ?>
This code generates the repeater value and saves it in a variable named $value. That's it. This code doesn't do anything with this value or print it to the screen so the fact that nothing is displayed is correct.
To view what's inside the field, try the following:
<pre><?php print_r($post->getMetaValue('repeater')) ?></pre>
The above code will print out the value of the repeater field to the screen. Assuming you have set a value for this field for the current post, this value be an array containing the data that you set. You will then need to make use of foreach loops to cycle through the array and process/display the data.
Using Advanced Custom fields I've created a simple field that allows me to have a custom banner image of each page/post at the top of the page. My issue is that it's displaying the banner image of the most recent post at the top of the category page too. I'd like to be able to add a customized image for the categories but I'm not sure where to go from here.
Here is my code:
<?php if(is_front_page()) : ?>
<div class="homepage-slider">
<?php layerslider(1) ?>
</div>
<?php else : ?>
<?php
if( get_field('banner_image'))
{
echo '<img src="';
the_field('banner_image');
echo '">';
}
else
{
echo '';
}
?>
<?php endif; ?>
This loop brings in all the pages and shows it on a single page. How can I edit it so that I only bring in one page identified by its ID? (the page wont change)
Thanks
<section id="<?php echo $post->post_name;?>" class="page-area<?php echo $bgClass;?>"<?php echo $style;?>>
<div class="wrapper"<?php if($fullEmbed<>''):?> style="width:100%"<?php endif;?>>
<?php if($hideTitle!='Yes'):?>
<hgroup class="title">
<h1<?php echo $font;?>><strong><?php echo $mainHeading;?></strong></h1>
<?php if($subHeading<>''):?><p<?php echo $font;?>><?php echo $subHeading;?></p><?php endif;?>
</hgroup>
<?php endif;?>
<?php if($fullEmbed<>''):?>
<div class="full-embed"><?php echo van_shortcode($fullEmbed);?></div>
<?php else:?>
<div class="entry"<?php echo $font;?>>
<?php van_content(true,true);?>
</div>
<?php endif;?>
</div>
</section>
<?php endwhile;?>
You mean like:
<?php
$page_id = 123; // 123 should be replaced with a specific Page's id from your site, which you can find by mousing over the link to edit that Page on the Manage Pages admin page. The id will be embedded in the query string of the URL, e.g. page.php?action=edit&post=123.
$page_data = get_page( $page_id ); // You must pass in a variable to the get_page function. If you pass in a value (e.g. get_page ( 123 ); ), WordPress will generate an error. By default, this will return an object.
echo '<h3>'. $page_data->post_title .'</h3>';// echo the title
echo apply_filters('the_content', $page_data->post_content); // echo the content and retain WordPress filters such as paragraph tags. Origin: http://wordpress.org/support/topic/get_pagepost-and-no-paragraphs-problem
?>
Straight from the WP Codex http://codex.wordpress.org/Function_Reference/get_page