Angular + WordPress - wordpress

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.

Related

AFC - show files in comments

I'm trying to add feature to my website where users will be able upload files in comments.
I'm trying to do that using Advanced Custom Fields plugin.
Some parts of job are done. I have upload option while writing comment and after submiting comment the file is visable via Wordpress administration.
Comment administration (file is visable at the bottom)
https://i.imgur.com/zIyjy0M.jpg
Custom field settings
https://i.imgur.com/nqNQK5N.png
Code for frontend I'm using in comments template
<?php
$cfile = get_field('comment_file');
if( $cfile ): ?>
<?php echo $cfile['filename']; ?>
<?php endif;
?>
The problem is - I can't see file in frontend part of website. Like there is no file(s).
$comment = get_comment(); // Here you can get single Comment array
$cfile = get_field('comment_file', $comment); // Then you need to pass Comment variable with get_field
if( $cfile ): ?>
<?php echo $cfile['filename']; ?>
<?php endif;
You can visit below link for Reference - https://www.advancedcustomfields.com/resources/get-values-comment/

Categories with post from child categories on front page

I am developing my first WordPress site and I am using the Customizr theme. I need to build a front page, that shows the latest posts from 2 categories - News and Events and all their child categories. So my category tree looks like this:
Articles
-News
--First news child category
--Second news child category
-Events
--First events child category
--Second events child category
and I want the front page to show the category News and the category Events with all the posts in their child categories packed in 2 containers with the headlines News and Events respectively. I am a total newbie in WordPress and I've searched for days for a solution, but I think I'm searching with the wrong keywords, because I didn't found what I need. I've created a child theme, and I'm currently trying to make an index.php with The Loop to achieve that. I've also tried making a static front page which uses a different template.
So which is the right way to do that? Can you please at least give me some pointers? Thank you!
If i understood corectly you can achieve expected result with Category Parameters for WP Query. Then you can loop over posts like this:
<?php
$the_query = new WP_Query( "category_name=news,events"); ?>
<?php if ( $the_query->have_posts() ) : ?>
<!-- pagination here -->
<!-- the loop -->
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php endwhile; ?>
<!-- end of the loop -->
<!-- pagination here -->
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
Also, to customize your front page better make a new template (home.php), do your job there and then asssign it to an empty page and make that page your front page from Settings->Reading

Cant' Grab WordPress Built-in Posts Through Loop

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

How to display list categories in wordpress integration magento

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.

Password protecting not working for custom post type single-template.php? - Wordpress

I have created a custom post-type 'Clients' where admin user can create new clients, add pictures and details to post, then password protect the page so only a particular client can access the content.
For displaying content of this post-type on the front end, I'm using a single-clients.php template. It displays the content perfectly, but the password protect function does not display the form and hide the content, even if I'm in a different browser, cache cleared/logged out of Wordpress (viewing it as a regular end-user would).
What might I be doing wrong here?
<?php get_header(); ?>
<div class="container-client">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
Display all fields and content for post-type
<?php endif; ?>
<?php endwhile; else: ?>
<div class="alert-box error">Sorry, this page no longer exists :( — Back to home</div>
<?php endif; ?>
</div>
<?php get_footer(); ?>
This is roughly how my single-clients.php page is setup. Is there any way to manually display the password function so that when end-user visits page, the content is hidden and password form is displayed?
I had exactly this problem and after some trying and reading the codex I came up with this solution:
<?php
add_filter('single_template', function($single_template) {
global $post;
if ($post -> post_type == 'your-custom-post-type') {
if (!post_password_required()) {
$single_template = 'path-to-your/single-your-custom-post-type.php';
}
}
return $single_template;
});
?>
This way the page is only rendered in the custom sinlge view after entering a password, if it is password protected.

Resources