Use the_title_attribute() for the WHERE parameter in a page template

Answer provided by @Howdy_McGee who commented on the question. Using the prepare statement allowed the results to be pulled at the correct time and using %s is for strings and %d would be for a decimal or number value. $sql = $wpdb->prepare(“SELECT * FROM <databaseName>.<tableName> WHERE name=”%s””, get_the_title()); $results = $wpdb->get_results($sql, OBJECT);

Can two custom templates be used to create a single page?

No, you would not use two page-templates on a single page. Yes, you can have a different admin-page layout / configuration for different page-templates. Page-template-A could have two post-editors and page-template-B (or post-format for that matter) could have only a name, email, and featured-image. You could use a single page template and separate includes to … Read more

Change content of page in child theme using plugin

It depends on where you want to put the ‘hello’ thing. For instance, you could use the_content filter to put it before or after the content: function wp_add_to_the_content($content) { $content=”Text before the content.” . $content . ‘Text after the content’; return $content add_filter(‘the_content’, ‘wp_add_to_the_content’,10,1); You’d need to add any CSS and other tags to format … Read more

Pre get posts where template is not equal to one specified?

You should use meta_query to pass meta query arguments. add_action(‘parse_query’, ‘se334731_filter_admin_post_list’); function se334731_filter_admin_post_list( $query ) { $screen = get_current_screen(); if ( is_admin() && $screen->post_type == ‘page’ && $screen->base == ‘edit’ ) { $query->query_vars[‘meta_query’][] = [ ‘relation’ => ‘OR’, [ ‘key’ => ‘_wp_page_template’, ‘value’ => ‘page-some-template.php’, ‘compare’ => ‘!=’, //’value’ => array( ‘page-some-template.php’ ), //’compare’ => … Read more

Creating a custom archive template that sorts post by date

I’ve taken the answer from here, where they are changing the order in a different way, but it should work for you. It uses the pre_get_posts hook to change the ordering for the archive page only. add_action( ‘pre_get_posts’, ‘my_change_sort_order’); function my_change_sort_order($query){ if(is_archive()): //If you wanted it for the archive of a custom post type use: … Read more

Visual Editor Templates

Short answer: kinda The visual editor is the open source Tiny MCE WYSIWYG editor. You can style it however you want (i.e. so that it presents the same colors and fonts as the finished posts and pages) by writing a stylesheet to do so and loading it with the add_editor_style hook. However, it sounds more … Read more

Excerpts for Pages

Using the “more” tag does not create an excerpt. It simply creates a “Read More” link when displaying the_content() on index pages. Excerpts are created/displayed as follows: To display an excerpt, your template file needs to call “the_excerpt()” rather than “the_content()”. Note: you use the equivalent $post->post_excerpt, which should also work just fine. The “the_excerpt()” … Read more

Creating a new page template

Try this instead: <?php /** * Template name: About Us */ WordPress could be finicky about the short tags (<? vs <?php) and comment formatting – shouldn’t be, but better safe than sorry. Also, make sure that you have the Screen Option to display Page Attributes turned on and that you’re on Add New Page, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)