phaidonas
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Check if is category pageI dont think so that is an array if you dont declare it so, I think it takes the class as an instance, Never less i did it with jquery which has better selector, but maybe also works with javascript.I just thought it after using the jquery
Here the code:
<?php $Archive_Id = get_page_by_path('southarchive'); ?> <script type="text/javascript"> $( ".page-item-<?php echo $Archive_Id->ID?>" ).addClass( "ActiveArchive" ); </script>The problem was the echo
😛I will also try the post_class, i have an underscore theme.
I dont think so putting the class inside the page file will work,because also then i will have to active it somehow from the category file because only then i want this class to exist.Forum: Developing with WordPress
In reply to: Check if is category pageit works like a charm thank you, i have an other question somehow similar, the category page is a redirect of a page.I want to take the page by class (page-item-id) and give also an other class.
The code that i used is a mixture of php and javascript but it doesnt work.Here:<?php $Archive_Id = get_page_by_path('southarchive'); ?> <script> var y = document.getElementsByClassName("page-item-<?php$Archive_Id->ID;?>"); y.className += " ArchiveActive"; </script>- This reply was modified 9 years, 1 month ago by phaidonas.
Forum: Developing with WordPress
In reply to: Check if is category pagethe code exists in a category-[myslug].php page, i tried it but either it does nothing either it gives the class in all the titles. i tried this kind of code:
$Awards_id= get_cat_ID('awards'); $Press_id= get_cat_ID('press'); $News_id= get_cat_ID('news'); $Commercial_id= get_cat_ID('commercial'); $args = array( 'orderby' => 'name', 'parent' => 0, 'exclude' => array($Awards_id,$Press_id,$News_id ) ); $categories = get_categories( $args ); if(is_category('myslug')){ foreach ( $categories as $category ) { echo '<a>term_id ) . '">' . $category->name . '</a><br/>'; } }else{ foreach ( $categories as $category ) { echo '<a>term_id ) . '">' . $category->name . '</a><br/>'; } } ?> </div>- This reply was modified 9 years, 1 month ago by phaidonas.
Forum: Developing with WordPress
In reply to: Posts by catecoryYeah it works! Thank you very much.
Forum: Developing with WordPress
In reply to: Feutured image if existsi want to display only if there is a featured image, not any other image assigned to the post, the problem is that also displays posts (with blank) that have not feature image but have images assigned to them.I wanted to make it easier for the client, but maybe i have to tell him that he has to assign feature image to all the posts.The problem is that he has some incomplete posts, and i wanted to make him free from the trouble of putting feature images to all the posts now, and do it with his own time.
Forum: Developing with WordPress
In reply to: Posts by catecoryIt is also the same with post types?because I search it,a little complicated, declare the post types, assign them and then use them with single-{post-type }.php
Forum: Developing with WordPress
In reply to: Posts by catecoryhere is the code of single.php:
<?php /** * The template for displaying all single posts * * @link https://developer.ww.wp.xz.cn/themes/basics/template-hierarchy/#single-post * * @package South_Arch */ get_header(); ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php while ( have_posts() ) : the_post(); get_template_part( 'template-parts/content', get_post_format() ); endwhile; // End of the loop. ?> </main><!-- #main --> </div><!-- #primary --> <?php get_footer();and here is for content.php:
<?php /** * Template part for displaying posts * * @link https://codex.ww.wp.xz.cn/Template_Hierarchy * * @package South_Arch */ ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <div class="PostContent"> <header class="entry-header"> <?php if ( is_single() ) : the_title( '<div class="entry-title">', '</div>' ); else : the_title( '<div class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></div>' ); endif; if ( 'post' === get_post_type() ) : ?> <div class="entry-meta"> </div><!-- .entry-meta --> <?php endif; ?> </header><!-- .entry-header --> </div> <div class="entry-content"> <?php the_content( sprintf( /* translators: %s: Name of current post. */ wp_kses( __( 'Continue reading %s <span class="meta-nav">→</span>', 'south-arch' ), array( 'span' => array( 'class' => array() ) ) ), the_title( '<span class="screen-reader-text">"', '"</span>', false ) ) ); wp_link_pages( array( 'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'south-arch' ), 'after' => '</div>', ) ); ?> </div><!-- .entry-content --> </article><!-- #post-## -->Forum: Developing with WordPress
In reply to: Posts by catecoryI have this plug in, the url is post, i know i have to many templates,and i could be more optimal if i used archive-{myslug}.php but i started it like this, and now i find difficult to change it.(When i fulfill the site i will try to change it. )Both urls are posts,displaying from single.php the second i havent made it yet, but it is also a post with different css.
Forum: Developing with WordPress
In reply to: Feutured image if existsit doesnt seem to have any difference
also this doesnt make any change:$the_query = new WP_Query( $args ); if ( has_post_thumbnail() ) { // The Loop if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); echo "<div class=FrontImage>"; the_post_thumbnail('full'); echo "</div>"; } } /* Restore original Post Data */ wp_reset_postdata(); } else { // no posts found }or this
$the_query = new WP_Query( $args ); // The Loop if ( $the_query->have_posts() ) { if ( has_post_thumbnail() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); echo "<div class=FrontImage>"; the_post_thumbnail('full'); echo "</div>"; } } /* Restore original Post Data */ wp_reset_postdata(); } else { // no posts found }or this:
$the_query = new WP_Query( $args ); if ( has_post_thumbnail() ) { // The Loop if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); echo "<div class=FrontImage>"; the_post_thumbnail('full'); echo "</div>"; } } /* Restore original Post Data */ wp_reset_postdata(); } else { // no posts found }or this
$the_query = new WP_Query( $args ); // The Loop if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { if ( has_post_thumbnail() ) { $the_query->the_post(); echo "<div class=FrontImage>"; the_post_thumbnail('full'); echo "</div>"; } } /* Restore original Post Data */ wp_reset_postdata(); } else { // no posts found }Forum: Developing with WordPress
In reply to: Posts by catecoryHere is the hierarchy of the theme:
Hierarchy1:
Hierarchy1Hierarchy2:
Hierarchy 2And here is the post content used from single.php:
Post,single.phpand here is an example mock up how i want to be seen the posts in the news category:Example post content
Thank you.
Forum: Developing with WordPress
In reply to: Posts by catecoryAs i undestand it, and searched, i think i mean about post types,or (maybe) single-{posttype}.php.But i dont understand fully how to assign one or use it.
Thanks and sorry for noob questionsForum: Developing with WordPress
In reply to: Posts by catecoryi mean the display code for the post itself not the code that displays the posts of a category.The code that the content.php has of displaying the content of the post.
Forum: Developing with WordPress
In reply to: Posts by catecoryok good,thank you very much very explain-full, now the final question, is any way to create a post-{mypost}.php or maybe post-{category slug of my post}.php, for custom display of inside the post? Because i have may categories and some of them have to be displayed differently.
Thank you again.I think with practice it will be also more explainable.
- This reply was modified 9 years, 1 month ago by phaidonas.
Forum: Developing with WordPress
In reply to: Posts by catecoryi have arrange all the site like this, yes i understand that is sub-optimal, the bar avatar in the bar is going to the other side because a css interruption.Except the archive-{mypage}.php could i also use the page-{mypage}.php.And what is the point of the page templates?
Thank you.
- This reply was modified 9 years, 1 month ago by phaidonas.
Forum: Developing with WordPress
In reply to: Filter by categoryIt works like a charm, as i realize wordpress functionality, it seems very good, is there any other option to filter the post by category dynamically, and also create a category all without reloading the page?