I tried following the instruction s but can't get the plugin to work, the fields show in admin and i upload images with them but when I publish and view the post no images show. Do I need to add something to template files for this to show?
Reading from the producer's page they state that for images/files their API returns a URL.
That might mean that the plug-in is not integrated with the native file handling functions. And you might need to use their template tags like <img src="<?php the_field('name') ?>" />.
file: public_html/wp-content/themes/theme_name/category.php
somewhere after this
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<img src="<?php the_field('name') ?>" />
...
Yes, you need to add:
<?php the_field('field_name'); ?>
Check ACF docs: http://www.advancedcustomfields.com/docs/code-examples/
Related
I have a ticket sales form written in Angular. How can I insert this form on the main page of Wordpress site? May be with usingthe tag iframe or can there be better solutions for this task? Thank you for attention!
I think a best solution to this is to create a new page template (you can google it to get more accurate info), see what is page templates here.
Basically, you will create a new file on your theme root, with the prefix page-, e.g: page-tickets.php. And then the very first thing that must appear on your page is a comment,like this: // Template Name: Tickets Page. Your page will be something like this:
<?php
// Template Name: Tickets Page
get_header();
?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
// Angular + Html codes here!
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<script>angular and js imports</script>
<?php get_footer(); ?>
With that, when you will create a new page in Pages -> New (or edit), in the right bottom side will be available an option to you to choose a page template, like this:
That's all, I hope it helps you.
We have a SaaS product for various clients. Each customer has its own installation in a Virtual Machine. Our user guide has been in Word/PDF. Customer have been able to modify the user guide to add the brand (logo, product name) in the user guide.
Now we want to set up the user guide in Drupal. To move the content of the user guide into Drupal is easy. The challenge is the customization for each customer. We don't want to install Drupal in each Virtual machine and replicate the content.
When someone clicks on "help" in our product they can get to Drupal and we can add parameters for 'client', 'version number' etc. to the URL. Drupal could process this to customize the set up. We can also use the client information for unique login for each client.
I was able to modify the logo by changing $logo in the page template. However, it changes the logo globally for all clients. The latest click to Drupal sets the logo.
I don't know how/where I can set up a logic to customize the logic based on the login. So Client A sees a different logo than client B accessing the same Drupal installation at the same time. In addition we would like to be able to customize the product name in a similar way.
I don't expect any program code (but I would not mind a module). Just some ideas on how to develop this would be great.
This has been the code in the page template. However, the logo changes every time a new client goes to the guide. Is there anything like a session or logoArray[client] feature that I could use to make the logo unique for every client even though many clients access the page concurrently?
<?php
$arglist = drupal_get_query_parameters();
if ( count( $arglist ) > 0 ):
$theme_name = 'bootstrap_ivs7';
$var_name = 'theme_' . $theme_name . '_settings';
$settings = variable_get($var_name, array());
if ( $arglist['logoflag'] == 'logoclient1' ): ?>
<?php if ($logo):
$logo='http://localhost/ivs7/sites/default/files/logo_client1.png';
$settings['logo_path'] = $logo;
variable_set($var_name, $settings);
<?php endif;
else:
if ( $arglist['logoflag'] == 'logoclient2' ):
$logo='http://localhost/ivs7/sites/default/files/logo_client2.png';
$settings['logo_path'] = $logo;
variable_set($var_name, $settings);
<?php
else:
$logo = 'http://localhost/ivs7/sites/all/images/logo_default.png'; ?>
$settings['logo_path'] = $logo;
variable_set($var_name, $settings);
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<?php
<a class="logo navbar-btn pull-left" href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>">
<img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
</a>
?>
From a custom module or a theme, you can can implement hook_preprocess_HOOK() to alter the variables of any template. Likely the variables you want to customize per client are all used in the page.tpl.php template, so that would be XYZ_preprocess_page() (where XYZ is the name of your theme or module).
Using WordPress 3.7.1 I am trying to display all Regular Post on my created page lest say TestPage. Here are the steps I took to do this:
1- Generate a Custom Page Template called:Test Page and loaded by following code
2- Generate a Page Called TestPage based on Test Page Template
after updating the page I am not getting any of Post on the page while I have already generated some!
<?php
/*
Template Name: Test Page
*/
?>
<?php get_header(); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title() ;?></h1>
<?php the_content(); ?>
<?php endwhile; else: ?>
<p>Sorry, this page does not exist</p>
<?php endif; ?>
<?php get_footer(); ?>
he abouve code actually is loading the page whit title and content of the TestPage and not by Posts!Can you please let me know why this is happening?
You must understand the difference between post and page.
A page is associated with a template. Through code, you can lists posts or other pages using this page /template.
The above code will only display the Page data
You don't want to create many pages using the same tempalte in order to show different data with the same tempalte. Instead you create posts and give them a category.
Then you can fetch these posts and display them in the same way asthe test-page.
You can either use get_posts or wp_get_recent_posts.
Or, if you really want to list pages, use wp_list_pages.
Besides that, you should look at http://codex.wordpress.org/Pages and http://codex.wordpress.org/Posts
Can help somebody. I spent several hours to find solution but without results
I tried to display the list of categories on homepage wordpress blog thru following code
<?php $category = Mage::registry('wordpress_category') ?>
<?php if ($category): ?>
<?php echo $category->getId() ?>: <?php echo $category->getName() ?>
<?php endif; ?>
But the method
Mage::registry('wordpress_category')
always return null.
I found that, i should probably be using the Fishpig_Wordpress_Block_Category_View. But i dont know where i should put it.
The following code will retrieve the current category when viewing a category page in your blog:
<?php Mage::registry('wordpress_category') ?>
This is not what you need. To view a list of categories, you could create a custom collection using the following:
<?php $categories = Mage::getResourceModel('wordpress/post_category_collection') ?>
A better way would be to use the category widget block:
<block type="wordpress/sidebar_widget_categories" name="wp.categories" template="wordpress/sidebar/widget/categories.phtml" />
You can create this in PHP using the following code:
<?php echo Mage::getSingleton('core/layout')
->createBlock('wordpress/sidebar_widget_categories')
->setTemplate('wordpress/sidebar/widget/categories.phtml')
->toHtml() ?>
The above code uses the default template, however, feel free to use your own custom template.
I know this may be a simple question but I am a total beginner at Wordpress coding and PHP. I am looking to embed five attachments to each post on my site, so I know it has got to do with inserting something into single.php or loop.php. So let's say I have 8 or 10 photos attached to a post, I want the single post page to show 5 of those photos and have a link to the 'gallery'/attachment.php page. Something like what this website does on this page, the 6 photos at the end of the post entry (http://www.celebuzz.com/2011-05-27/kim-kardashian-kris-humphries-makes-first-post-engagement-public-appearance-photos/)
I have tried using the wordpress [gallery] insert but all it does is show all the pictures and I don't want to use a plugin because I feel that it is overkill and all it needs is some code to call up 5 attached photos. Hope someone can help. Thanks in advance
Try using custom field template plugin
http://wordpress.org/extend/plugins/custom-field-template/
I know you don't want to use plugin. But, for the sake of the questions and I know someone will eventually landed here from search engine.
You can use attachment plugin. This plugin is quite simple and very straightforward.
Once installed, it will add new meta box on post creation page.
You can add as much as images you like and the loop part of your template page, you add this snippet:
<?php
if( function_exists( 'attachments_get_attachments' ) )
{
$attachments = attachments_get_attachments();
$total_attachments = count( $attachments ) > 5 : 5 : count( $attachments );
if( $total_attachments ) : ?>
<ul>
<?php for( $i=0; $i<$total_attachments; $i++ ) : ?>
<li><img src="<?php echo $attachments[$i]['location']; ?>" alt="<?php echo $attachments[$i]['title']; ?>" /></li>
<?php endfor; ?>
</ul>
<?php endif; ?>
<?php } ?>