Articles of php

If Statement Post Formats: No post format selected

I’m working with post formats, most of my code looks similar to this: if ( has_post_format( ‘standard’ )) { echo ‘<?php get_sidebar(); ?>’; } if ( has_post_format( ‘aside’ )) { echo ‘this is an aside’; } if ( has_post_format( ‘chat’ )) { echo ‘this is the video format’; } But I also want one of […]

REQUIRED: get_bloginfo('template_url') was found in the file search.php. Use get_template_directory_uri() instead

Theme Check error → REQUIRED: get_bloginfo(‘template_url’) was found in the file search.php. Use get_template_directory_uri() instead. Line 21: <img src='<?php echo get_bloginfo(‘template_url’) ?>/img/no_results_found.png’/> I acted and made the changes, but the image is now not coming in live webpage → <img src='<?php echo get_template_directory_uri() ?>/img/no_results_found.png’/> Is there any mistake in the above?

RTL Stylesheet Confusion with WordPress

All I understand about RTL is that some languages are written right-to-left. In a WordPress theme, what role does the rtl.css stylesheet have? I was under the impression that the only difference was paragraph alignment, but the WordPress themes that I have seen have massive rtl.css files. What other requirements are there of CSS to […]

site_url and $current_user producing undesired results

I am trying to make the link like this: using the code below. I think I messed it up though because it keeps producing an error on this line. $buttons[‘Edit My Profile’] = site_url(‘/forums/user/’)$current_user->user_login; Here is more of the surrounding code: <?php if ( is_user_logged_in() ) { global $current_user; get_currentuserinfo(); $buttons = array(); if […]

Make Current/Active Page Number a Link (WP_LINK_PAGES)

With the default wp_link_pages the current/active page number is not a link. I would like to find a code/hack which turns the current/active page into a link to the top of the page. I am already using a custom code for wp_link_pages which can be found below: <?php wp_link_pages(array( ‘before’ => ‘<p class=”pagelinks”>’ . __(”), […]

Convert WordPress date format to jQuery UI Datepicker format

I wrote the following function to convert the current WordPress date format into a format that can be recognized by the jQuery UI Datepicker: From: To: /** * Convert a date format to a jQuery UI DatePicker format * * @param string $dateFormat a date format * @return string */ function dateFormatTojQueryUIDatePickerFormat($dateFormat) { […]

Change page title from page using php via php executed from page/post itself

I am running a plugin from a WP page to execute PHP and it works great. I’d like to edit the page title and description based on POST data. I am already using POST data in the PHP code to alter the page output and it works great but if I try to insert POST […]

I want to remove the links from the term list returned by get_the_term_list

I want to keep this category title on my pages, but I don’t want it to be a link. <?php echo get_the_term_list( get_the_ID(), ‘portfolio_cats’, ‘ ‘, ‘ , ‘, ‘ ‘); ?> Can anyone help? Thanks

PHP Syntax Error on get_posts

I have the following coding: <?php global $post; $args = array( ‘numberposts’ => 8); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post);         echo ‘<a href=’.the_permalink().’>’.the_title().'</a><br />’;         endforeach; ?> Dreamweaver is highlighting a potential syntax error on line 6 & 7. I’m sure it’s […]

Showing latest post without 301 redirect

My WordPress website is now redirected to latest post by adding below function to function.php add_action( ‘template_redirect’, ‘redirect’ ); function redirect() { $args = array( ‘numberposts’ => 1, ‘post_type’ => ‘seller’, ‘post_status’ => ‘publish’); $last = wp_get_recent_posts($args); $last_id = $last[‘0’][‘ID’]; if ( is_home() && ! is_paged() && ! is_archive() && ! is_tag() && !isset($_GET[‘ptype’]) ) […]