Tag Info

Hot answers tagged

4

To list all pages with title and permalink from one user you need $wpdb->get_results(). The following code is based on this answer: How to count current user's pages? First, we move the counter into a separate helper function; we might need it later again: /** * Get all post IDs and titles of a type for a user. * * @param int $user_id * @param ...


3

The Navigation Menus system is adding a lot of classes, including matching current page (rather intelligently, it will even try to detect custom URLs, that were input explicitly). The simplest class to make use of is current-menu-item, but there are quite a few more dealing with parents/ancestors and more. Codex has them documented at wp_nav_menu() > Menu ...


3

PHP does not ever display in source, if things are working correctly. PHP executes on the server. If things are working the way they should you never see the PHP source. I don't know what your conditions are for this project, but the most straightforward way to access a script is to make a custom page template for it. You would ... create your template, ...


3

You are under a fundamentally wrong assumption: The content you input via the administrative back-end does not live in a file, but in the database, specifically in the wp_posts table. Do not be misguided by the table's name, a "page" is technically a post of type page. If you attempted to find the content you created via your "hosting file manager", it is ...


2

You are calling get_page_by_title( $page_title ) already. Use it! if ( ! get_page_by_title( _x( 'Homepage Template', 'home page title', 'your_theme_textdomain' ) ) ) { // create the page } Do not delete user content on theme deactivation. The user might have put much energy into that page, and maybe he is not aware you delete his work. But ...


2

<?php the_content(); ?> That's the function that displays everything you saved in Pages - > Contact Page. You just need to move that anywhere you would like. Just keep in mind the_content() must be between the while loop for it to work. <?php if (have_posts()) : while (have_posts()) : the_post(); ?> // Begins loop <?php endwhile; ?> // ...


1

I would use the built in Wordpress Menu Manager (Appearance -> Menus) to create my menu structure. For each of the 'dummy' parent pages you can just use a second link to that pages first child page, and rename it to read however you want. So if your structure is: -Parent A Child A Child B Child C And you want to make it so that clicking on Parent A ...


1

I would create an "Events" custom post type and then create a "Call to Action" custom taxonomy and associate this taxonomy with the custom post type. This way you can have an unlimited amount of events which can be associated with taxonomy terms (your Call to Action). This makes much more sense since you project that you will have few Call to Action types ...


1

The wpdb object can be used to run arbitrary queries against the WordPress database. Let's say you want to list the most recent 4 posts: $results = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE `post_type`='post' LIMIT 4" ); The $wpdb->posts variable will output the table name for posts. It's usually wp_posts, but if you're using a ...


1

Put this in your functions.php: function my_title() { if (is_home()) echo 'News'; else { global $post; if ($post->post_parent) echo get_post($post->post_parent)->post_title; else echo $post->post_title; } } // function my_title and then use <?php my_title(); ?> anywhere you want. ...


1

This is my Solution, I used Onclick attributes for the radio buttons to change the 'actions' of elements within the form. <form id="searchme" action="<?php echo site_url(); ?>/postersearch" method="get"> <ul class=" four columns inline-list offset-by-one"> <li><label for="radio4"><input name="post_type" CHECKED ...



Only top voted, non community-wiki answers of a minimum length are eligible